Closed
Description
I see broken staticlib compilation when targeting armv7-linux-androideabi
using any version of rustc >= 1.54, including 1.58.1. Specifically, there are a few symbols that are duplicated. Minimal repro below:
$ cat ~/test_c_abi.rs
#[allow(non_snake_case)]
pub unsafe extern "system" fn test_c_abi() {
println!("Hello world, via C ABI");
}
# Works
$ rustup default 1.53.0
$ rustup target add armv7-linux-androideabi
$ rustc --edition 2018 --crate-type staticlib --target armv7-linux-androideabi ~/test_c_abi.rs
$ nm libtest_c_abi.a | grep __sync_fetch_and_xor_4
nm: sync_synchronize.o: no symbols
00000000 T __sync_fetch_and_xor_4
# Broken
$ rustup default 1.54.0
$ rustup target add armv7-linux-androideabi
$ rustc --edition 2018 --crate-type staticlib --target armv7-linux-androideabi ~/test_c_abi.rs
$ nm libtest_c_abi.a | grep __sync_fetch_and_xor_4
00000000 T __sync_fetch_and_xor_4
nm: sync_synchronize.o: no symbols
00000000 T __sync_fetch_and_xor_4
# Broken
$ rustup default stable
$ rustup target add armv7-linux-androideabi
$ rustc --edition 2018 --crate-type staticlib --target armv7-linux-androideabi ~/test_c_abi.rs && nm ~/libtest_c_abi.a | grep __sync_fetch_and_max_4
nm: rustc_std_workspace_alloc-6ce654723e7de624.rustc_std_workspace_alloc.2741db18-cgu.0.rcgu.o: no symbols
nm: cfg_if-ca080555ae93982b.cfg_if.454341be-cgu.0.rcgu.o: no symbols
00000000 T __sync_fetch_and_max_4
nm: sync_synchronize.o: no symbols
00000001 T __sync_fetch_and_max_4
nm: rustc_std_workspace_core-4ee656067d958762.rustc_std_workspace_core.d8c25046-cgu.0.rcgu.o: no symbols
An even easier way to confirm the issue is to directly look at the compiler builtins rlib for armv7-linux-androideabi
:
$ cd ~/.rustup/toolchains
$ for x in */lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins*; do [ $(nm $x 2> /dev/null | grep -c __sync_fetch_and_xor_4) -gt 1 ] && echo "$x is broken" || echo "$x is okay"; done
1.53-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-51d05124e2182428.rlib is okay
1.54-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-b7a2613b4e9e1737.rlib is broken
stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-528fe7b1fd2894b6.rlib is broken
The regression may have happened in compiler_builtins between its version 0.1.39 and 0.1.45:
~/src/rust$ git show 1.53.0:Cargo.lock | grep -A 1 'name = "compiler_builtins"'
name = "compiler_builtins"
version = "0.1.39"
~/src/rust$ git show 1.54.0:Cargo.lock | grep -A 1 'name = "compiler_builtins"'
name = "compiler_builtins"
version = "0.1.45"
Linking this staticlib later results in duplicate symbol errors because of the above.
Metadata
Metadata
Assignees
Labels
No labels