Description
The project is closed source but when upgrading from rust 1.57.0 to rust 1.58.0, I encountered build failure with address sanitizer enabled on native aarch64 architecture using the follow RUSTFLAGS env variable:
RUSTFLAGS="-Zsanitizer=address -Csymbol-mangling-version=v0"
and the following cargo command:
cargo test -Zbuild-std -Ztimings --target $(arch)-unknown-linux-gnu --release --locked
I expected to see this happen: the project build successfully
Instead, this happened: a bunch of weird undefined symbol errors like
= note: /usr/bin/ld: /var/lib/cargo/target/aarch64-unknown-linux-gnu/release/deps/segments_rpc-3f0b579b639a6019.std-cec2ce27c1d4a978.std.3f2a3861-cgu.13.rcgu.o.rcgu.o: in function `_RINvNtNtCscmLdO7Nx2xx_4core4sync6atomic10atomic_subjECsfotvtIokYKH_3std':
/home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2412: undefined reference to `__aarch64_ldadd8_rel'
/usr/bin/ld: /var/lib/cargo/target/aarch64-unknown-linux-gnu/release/deps/segments_rpc-3f0b579b639a6019.std-cec2ce27c1d4a978.std.3f2a3861-cgu.15.rcgu.o.rcgu.o: in function `_RINvNtNtCscmLdO7Nx2xx_4core4sync6atomic10atomic_subjECsfotvtIokYKH_3std':
/home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2412: undefined reference to `__aarch64_ldadd8_rel'
/usr/bin/ld: /home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2412: undefined reference to `__aarch64_ldadd8_rel'
/usr/bin/ld: /home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2412: undefined reference to `__aarch64_ldadd8_rel'
/usr/bin/ld: /home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2412: undefined reference to `__aarch64_ldadd8_rel'
/usr/bin/ld: /var/lib/cargo/target/aarch64-unknown-linux-gnu/release/deps/segments_rpc-3f0b579b639a6019.std-cec2ce27c1d4a978.std.3f2a3861-cgu.15.rcgu.o.rcgu.o:/home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2412: more undefined references to `__aarch64_ldadd8_rel' follow
/usr/bin/ld: /var/lib/cargo/target/aarch64-unknown-linux-gnu/release/deps/segments_rpc-3f0b579b639a6019.std-cec2ce27c1d4a978.std.3f2a3861-cgu.15.rcgu.o.rcgu.o: in function `_RINvNtNtCscmLdO7Nx2xx_4core4sync6atomic11atomic_swaphECsfotvtIokYKH_3std':
/home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2383: undefined reference to `__aarch64_swp1_acq_rel'
/usr/bin/ld: /var/lib/cargo/target/aarch64-unknown-linux-gnu/release/deps/segments_rpc-3f0b579b639a6019.std-cec2ce27c1d4a978.std.3f2a3861-cgu.15.rcgu.o.rcgu.o: in function `_RINvNtNtCscmLdO7Nx2xx_4core4sync6atomic10atomic_addjECsfotvtIokYKH_3std':
/home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2398: undefined reference to `__aarch64_ldadd8_relax'
/usr/bin/ld: /var/lib/cargo/target/aarch64-unknown-linux-gnu/release/deps/segments_rpc-3f0b579b639a6019.std-cec2ce27c1d4a978.std.3f2a3861-cgu.15.rcgu.o.rcgu.o: in function `_RINvNtNtCscmLdO7Nx2xx_4core4sync6atomic10atomic_subjECsfotvtIokYKH_3std':
/home/builder/.rustup/toolchains/nightly-2022-01-20-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2414: undefined reference to `__aarch64_ldadd8_relax'
Meta
rustc --version --verbose
:
$ rustc --version --verbose
rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0
Workaround
Adding -Ctarget-feature=-outline-atomics
to the RUSTFLAGS environment variable to disable the outline-atomics
aarch64 target feature circumvents the issue.
Additionally, the problem happens on Debian Buster but not on Debian Bullseye with the exact same rust binary installed through rustup.
No idea if that's related but we do compile some C and C++ code as part of some build.rs
files using the cc crate and clang-12 as compiler that gets linked with the project.