1.15.1 (and earlier) armhf nondeterministically uses locking to implement atomic instructions when cross-compiling to x64 but not x86
This was originally reported over at #33809 with the full build log here but back then I dismissed it as "just install binutils-multiarch". However, we just saw the exact same issue crop up when trying to bring rustc to Debian armhf.
Build machine: hasse.debian.org Raw build log: https://buildd.debian.org/status/fetch.php?pkg=rustc&arch=armhf&ver=1.15.1%2Bdfsg1-1%7Eexp2&stamp=1488549003&raw=1
The relevant part is here, visible in both build logs:
error: make failed
status: exit code: 2
command: "make"
stdout:
------------------------------------------
make[3]: Entering directory '/«BUILDDIR»/rustc-1.15.1+dfsg1/src/test/run-make/atomic-lock-free'
LD_LIBRARY_PATH="[..]" '[..]/rustc' [..] -C link-args=-Wl,-z,relro --target=i686-unknown-linux-gnu atomic_lock_free.rs
nm "[..]/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
LD_LIBRARY_PATH="[..]" '[..]/rustc' [..] -C link-args=-Wl,-z,relro --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
nm "[..]/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
Makefile:9: recipe for target 'all' failed
make[3]: Leaving directory '/«BUILDDIR»/rustc-1.15.1+dfsg1/src/test/run-make/atomic-lock-free'
------------------------------------------
stderr:
------------------------------------------
nm: rust.metadata.bin: File format not recognized
nm: atomic_lock_free.0.bytecode.deflate: File format not recognized
nm: atomic_lock_free.0.o: File format not recognized
nm: rust.metadata.bin: File format not recognized
nm: atomic_lock_free.0.bytecode.deflate: File format not recognized
make[3]: *** [all] Error 1
Note how, for atomic_lock_free.0.o for i686, nm complains "File format not recognized" but we get no such complaint for x86_64. This suggests that it did in fact read the file correctly, and grep -v is what caused make to fail.
However, I cannot reproduce this issue on another armhf machine, abel.debian.org where this test passes.
This test also passes on all other architectures on Debian. It is very likely that all of the target architectures mentioned in src/test/run-make/atomic-lock-free/Makefile are being tested (on each host architecture that is running the tests), since llvm-config --components on Debian outputs all of the target architectures mentioned.
Arguably there is another bug here - if nm gives "File format not recognized" then this should fail the test, rather than causing it to pass (because grep -v finds nothing).
Ping @sanxiyn who lasted touched the test, and @Amanieu who wrote the original version.
Btw, is
nmsupposed to be from binutils-multiarch or insteadllvm-nm?Ximin Luo at 2017-03-04 16:30:53
Triage: @infinity0 are you still seeing this?
Steve Klabnik at 2020-02-08 15:56:07