Possible to build rustc with libgcc instead of compiler-rt?

libgcc provides native, optimal support for a platform I’m trying to build on, and llvm appears to defaults to using libgcc on that platform for compatibility reasons. However, it appears that rust always requires compiler-rt instead. Is it possible to build rust such that it uses libgcc instead of compiler-rt or that it least builds compiler-rt but links against libgcc instead?

Am I misunderstanding how this works?

It is not presently possible, no. I’m curious which platform you are on and what the compatibility issue is. libgcc and compiler-rt are effectively compiler implementation details, and rust maintains its own fork of it that is tightly integrated with the rust toolchain. These libraries consist of small well known assembly routines and I would not expect significant differences between the two.

In addition to what brson says, I would like to ask what happens if you fake it: make a copy of the libgcc.a you want used, rename it to libcompiler-rt.a, and put it where rustc expects to find it.

GCC and LLVM don't always agree on calling conventions. See the discussion here about ARM:

Well, one of the platforms where I'm having issues is sparcv9 (aka sparc64) on Solaris. This appears to be because of issues I'm still investigating in the rust unwinding libraries / dwarf handling. gcc's equivalent functionality has no issue on the same platform.

Likewise, there are various math functions that have been hand-optimised in gcc for sparcv9 (and other platforms) that rust has no equivalent of. rust instead is relying on the optimisation and code generation capabilities of either LLVM or gcc, which are not always as optimal.

I'm currently resyncing my existing sparcv9 port work and getting it into the appropriate rust-related repositories. Once I've done that, I intend to revisit the unwinding issue to see if recent alignment fixes have resolved it, or if there's still more work to be done.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.