Description
I'm trying to build for mipsel-unknown-linux-gnu
x86_64 host, ubuntu 22.04
Freshly built from github source toolchain, with profiler = true in config.toml and mipsel-unknown-linux-gnu target as well as the host target. Built with x.py dist, using the stage 2 results as my build toolchain.
Building anything with RUSTFLAGS="-C instrument-coverage" set, leads to the following link error on several object files :
Single example:
src/index.crates.io-6f17d22bba15001f/hyper-0.14.26/src/common/buf.rs:33: undefined reference to `__sync_fetch_and_add_8'
Building the same code without the flag works fine. Resulting binary works fine.
Per the following GCC bug, MIPS 32 doesn't support 8 byte atomic operations:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56300
In the project/target/mipsel-unknown-linux-gnu folder, running
grep -r __sync_fetch_and_add_8
Shows that nearly every file includes a call to this non-existent function. I assume it's coming from the profiler somehow.
Executing the same command in my toolchain build/x86_64-unknown-linux-gnu/stage2
grep: lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-16-rust-1.72.0-nightly.so: binary file matches
grep: lib/libLLVM-16-rust-1.72.0-nightly.so: binary file matches
This is where I get stuck. The mipsel rust standard lib is under that directory, so my grep should catch any calls to __sync_fetch_and_add_8 contained in the standard lib. There don't appear to be any. The only cases I find are in libLLVM, which is built for x86_64. It's reasonable for them to be there, since x86_64 does support __sync_fetch_and_add_8.
You'll have to forgive my ignorance here, I'm still quite new to rust. I don't understand the intricacies of the build process well enough to figure out how a call to __sync_fetch_and_add_8 is getting pulled into object files targeting MIPS, when the only library instance of a call to there is in the x86_64 library.
What I am fairly certain of though is that it shouldn't be getting pulled in.