Stage0 recompiled std misses symbols like `__aarch64_ldadd4_relax`

Hello, I'm trying to build rust on my local aarch64 machine. The commands I used are exactly what GitHub - rust-lang/rust: Empowering everyone to build reliable and efficient software. suggests:

git clone https://github.com/rust-lang/rust.git
cd rust
./configure --set install.prefix=$RUST_DIR/install
./x.py build && ./x.py install

Then I got the following errors:

Building compiler artifacts (stage0 -> stage1)
   Compiling rustc_driver v0.0.0 (/home/chenmindong/rust/compiler/rustc_driver)
   Compiling rustc-main v0.0.0 (/home/chenmindong/rust/compiler/rustc)
error: linking with `cc` failed: exit status: 1
/usr/bin/ld: $HOME/rust/build/aarch64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-d0f55b1b575b8363.so: undefined reference to `__aarch64_ldadd4_relax'
          /usr/bin/ld: $HOME/rust/build/aarch64-unknown-linux-gnu/stage0-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_driver-0e51d15bced64312.so: undefined reference to `__aarch64_ldset1_relax'
          /usr/bin/ld: $HOME/rust/build/aarch64-unknown-linux-gnu/stage0-rustc/aarch64-unknown-linux-gnu/release/deps/librustc_driver-0e51d15bced64312.so: undefined reference to `__aarch64_swp4_rel'

I can find these symbols in stage0 std:

nm stage0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-005479bee49a9ef6.so | grep __aarch64_ldadd4_relax
0000000000126070 t __aarch64_ldadd4_relax

but not in the recompiled(if I understand correctly) stage0-sysroot:

nm stage0-sysroot/./lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-d0f55b1b575b8363.so | grep __aarch64_ldadd4_relax
U __aarch64_ldadd4_relax

Any suggestions are welcome!

Environment: ldd (GNU libc) 2.28/ GCC 7.3.0

-moutline-atomics support was added to GCC in 9.4. Older versions miss the corresponding intrinsics in libgcc. Given that we enable this option for all rust code compiled to aarch64-unknown-linux-gnu, you need a new enough libgcc to link into libstd. You can try building with RUSTFLAGS_BOOTSTRAP="-Ctarget-feature=-outline-atomics" and edit rust/aarch64_unknown_linux_gnu.rs at b92a41c6760801a7128ca0ec69ba4ba9c9194054 · rust-lang/rust · GitHub to remove the ,+outline-atomics.

1 Like

Thanks! I followed your suggestion and the build process can progress to stage1 now. To understand things better, I suppose "-Ctarget-feature=-outline-atomics" tells rust to enable this feature for stage0 but isn't it the case that I should turn that off for my environment? I tried not modifying RUSTFLAGS_BOOTSTRAP and then it fails as before. Could you further explain the purpose of this environment variable change for me?

Also, if not invoking x.py directly, which file should I modify to set RUSTFLAGS_BOOTSTRAP?

-outline-atomics disables the feature, while +outline-atomics enbles it.

RUSTFLAGS_BOOTSTRAP is an env var. You need to set it before running the command that builds rustc.

Uhh I see, thanks!

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