Description
There is a policy that Rust's core
does not depend on the libc implementation for a given target. This has caused us quite a deal of heartache in the past, and it is about to cause us more, but I believe it is and has been the right choice. Rust code relying only on our core library should not really require participation from any other toolchain or library beyond our own code. We should be able to have "pure Rust" targets without being entangled with implementation details. We should be able to, in the long run, build and link our own code. And we should not close the door on that, certainly not at this stage where people are actually building pure Rust runtime libraries and operating systems.
In #83655 I made a mistake that violated this policy. I was not familiar with how the function definitions would be resolved, and I thought they only depended on the linker somehow. It had not occurred to me, at the time, that it induced a dependency on glibc, and I was somehow not tipped off by the other bugs that started showing up. It has caused recurring issues even until relatively recently:
- Undefined reference to
getauxval
in functioninit_have_lse_atomics
when compiling to nightlyaarch64-unknown-linux-musl
#89626 (comment) - bootstrap cannot check library/std for windows from macOS (and possibly others) #101172
- undefined reference errors on aarch64 wg-cargo-std-aware#74
I have personally also run into this in another project, even with very recent compilers.
A lot of work has been done to make my mistake compile anyways, and it's still not enough.
Obviously, this deeply hurts our ability to implement things like -Zbuild-std
.
Fortunately, it is easily corrected: simply remove the feature from the aarch64-unknown-linux-gnu target spec unless and until we arrive at an implementation that does not require participation from glibc. This will lead to a performance regression using atomic instructions in some cases, but that's an acceptable loss if the alternative is continually trashing everyone's ability to build Rust code.
This may require retouching code in compiler-builtins as well.