Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcompiler_builtins.rlib for armv7-linux-androideabi includes multiple definitions of __sync_fetch_and_add_4 #449

Closed
dcsommer opened this issue Jan 27, 2022 · 6 comments · Fixed by #450

Comments

@dcsommer
Copy link
Contributor

dcsommer commented Jan 27, 2022

This may be related to #420 and #412, but this seems pretty straightforward. In investigating rust-lang/rust#93310 I determined it was a bug with compiler-builtins and root caused it to 186517b. By making a small change, I was able to compile a rust toolchain which did not have the duplicate symbols:

diff --git a/build.rs b/build.rs
index dc1cd1d..b51cfe7 100644
--- a/build.rs
+++ b/build.rs
@@ -83,7 +83,7 @@ fn main() {
     // rustc target (arm-linux-androideabi).
     if llvm_target[0] == "armv4t"
         || llvm_target[0] == "armv5te"
-        || llvm_target.get(2) == Some(&"androideabi")
+        // || llvm_target.get(2) == Some(&"androideabi")
     {
         println!("cargo:rustc-cfg=kernel_user_helpers")
     }

The change in 186517b seems intended to affect only arm-linux-androideabi by the comment, but it ended up affecting armv7-linux-androideabi. Anyway, it looks like after the change arm-linux-androideabi properly only has the symbols once, but armv7-linux-androideabi is defining them twice:

~/src/compiler-builtins$ nm ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/arm-linux-androideabi/lib/libcompiler_builtins-14ef5f7d25cebe09.rlib 2> /dev/null | grep __sync_fetch_and_add_4 | wc -l
1
~/src/compiler-builtins$ nm ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-be29c8b80b9c00b1.rlib 2> /dev/null | grep __sync_fetch_and_add_4 | wc -l
2

I'm not sure exactly how x.py ends up compiling compiler_builtins, since I was unable to reproduce the duplicate symbol issue in this repo alone (I tried cargo build --target armv7-linux-androideabi). I think there must be additional features enabled that cause the duplication in the end.

@dcsommer
Copy link
Contributor Author

The comment above this if doesn't make sense to me:

    // Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures. This
    // includes the old androideabi. It is deprecated but it is available as a
    // rustc target (arm-linux-androideabi).
    if llvm_target[0] == "armv4t"
        || llvm_target[0] == "armv5te"
        || llvm_target.get(2) == Some(&"androideabi")
    {
        println!("cargo:rustc-cfg=kernel_user_helpers")
    }

On https://doc.rust-lang.org/nightly/rustc/platform-support.html, the definition of arm-linux-androideabi is "ARMv7 Android", but the comment implies it targets pre-ARMv6.

dcsommer added a commit to dcsommer/compiler-builtins that referenced this issue Jan 27, 2022
The change in 186517b was intended to
affect only arm-linux-androideabi but also affected
`armv7-linux-androideabi` which is not a pre-ARMv6 architecture.
Fixes rust-lang#449
dcsommer added a commit to dcsommer/compiler-builtins that referenced this issue Jan 27, 2022
The change in 186517b was intended to
affect only `arm-linux-androideabi` but also affected
`armv7-linux-androideabi` which is not a pre-ARMv6 architecture.
Fixes rust-lang#449
@Amanieu
Copy link
Member

Amanieu commented Jan 28, 2022

I already published 0.1.67 with this change.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 1, 2022
Update compiler_builtins to fix duplicate symbols in `armv7-linux-androideabi` rlib

I ran `./x.py dist --host= --target=armv7-linux-androideabi` before this diff:
```
$ nm build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-3d9661a82c59c66a.rlib 2> /dev/null | grep __sync_fetch_and_add_4 | wc -l
2
```
And after:
```
$ nm build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-ffd2745070943321.rlib 2> /dev/null | grep __sync_fetch_and_add_4 | wc -l
1
```
Fixes rust-lang#93310

See also rust-lang/compiler-builtins#449 and rust-lang/compiler-builtins#450
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 1, 2022
Update compiler_builtins to fix duplicate symbols in `armv7-linux-androideabi` rlib

I ran `./x.py dist --host= --target=armv7-linux-androideabi` before this diff:
```
$ nm build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-3d9661a82c59c66a.rlib 2> /dev/null | grep __sync_fetch_and_add_4 | wc -l
2
```
And after:
```
$ nm build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-ffd2745070943321.rlib 2> /dev/null | grep __sync_fetch_and_add_4 | wc -l
1
```
Fixes rust-lang#93310

See also rust-lang/compiler-builtins#449 and rust-lang/compiler-builtins#450
@jameshilliard
Copy link

Seeing this bug on armv5te-unknown-linux-gnueabi as well looks like:

cd /home/buildroot/buildroot/output/build/bat-0.18.3 && PATH="/home/buildroot/buildroot/output/per-package/bat/host/bin:/home/buildroot/buildroot/output/per-package/bat/host/sbin:/home/buildroot/bin:/home/buildroot/.local/bin:/home/buildroot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" PATH="/home/buildroot/buildroot/output/per-package/bat/host/bin:/home/buildroot/buildroot/output/per-package/bat/host/sbin:/home/buildroot/bin:/home/buildroot/.local/bin:/home/buildroot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" AR="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gcc-ar" AS="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-as" LD="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-ld" NM="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gcc-nm" CC="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gcc" GCC="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gcc" CPP="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-cpp" CXX="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-g++" FC="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gfortran" F77="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gfortran" RANLIB="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-gcc-ranlib" READELF="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-readelf" STRIP="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-strip" OBJCOPY="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-objcopy" OBJDUMP="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-objdump" AR_FOR_BUILD="/usr/bin/ar" AS_FOR_BUILD="/usr/bin/as" CC_FOR_BUILD="/usr/bin/gcc" GCC_FOR_BUILD="/usr/bin/gcc" CXX_FOR_BUILD="/usr/bin/g++" LD_FOR_BUILD="/usr/bin/ld" CPPFLAGS_FOR_BUILD="-I/home/buildroot/buildroot/output/per-package/bat/host/include" CFLAGS_FOR_BUILD="-O2 -I/home/buildroot/buildroot/output/per-package/bat/host/include" CXXFLAGS_FOR_BUILD="-O2 -I/home/buildroot/buildroot/output/per-package/bat/host/include" LDFLAGS_FOR_BUILD="-L/home/buildroot/buildroot/output/per-package/bat/host/lib -Wl,-rpath,/home/buildroot/buildroot/output/per-package/bat/host/lib" FCFLAGS_FOR_BUILD="" DEFAULT_ASSEMBLER="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-as" DEFAULT_LINKER="/home/buildroot/buildroot/output/per-package/bat/host/bin/arm-none-linux-gnueabi-ld" CPPFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os -g0 -D_FORTIFY_SOURCE=1" CXXFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os -g0 -D_FORTIFY_SOURCE=1" LDFLAGS="" FCFLAGS=" -Os -g0" FFLAGS=" -Os -g0" PKG_CONFIG="/home/buildroot/buildroot/output/per-package/bat/host/bin/pkg-config" STAGING_DIR="/home/buildroot/buildroot/output/per-package/bat/host/arm-buildroot-linux-gnueabi/sysroot" INTLTOOL_PERL=/usr/bin/perl CARGO_HOME=/home/buildroot/buildroot/output/per-package/bat/host/share/cargo __CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS="nightly" CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" CARGO_TARGET_APPLIES_TO_HOST="false" CARGO_BUILD_TARGET="armv5te-unknown-linux-gnueabi" CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_GNUEABI_LINKER=arm-none-linux-gnueabi-gcc  cargo build --offline --release --manifest-path Cargo.toml --locked 
   Compiling libc v0.2.95
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.26
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.72
   Compiling pkg-config v0.3.19
   Compiling bitflags v1.2.1
   Compiling memchr v2.4.0
   Compiling serde_derive v1.0.126
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.126
   Compiling lazy_static v1.4.0
   Compiling encoding_index_tests v0.1.4
   Compiling tinyvec_macros v0.1.0
   Compiling log v0.4.14
   Compiling proc-macro-hack v0.5.19
   Compiling matches v0.1.8
   Compiling regex-syntax v0.6.25
   Compiling byteorder v1.4.3
   Compiling crc32fast v1.2.1
   Compiling ryu v1.0.5
   Compiling unicode-width v0.1.8
   Compiling serde_json v1.0.64
   Compiling percent-encoding v2.1.0
   Compiling fnv v1.0.7
   Compiling vec_map v0.8.2
   Compiling hashbrown v0.9.1
   Compiling ansi_term v0.11.0
   Compiling adler v1.0.2
   Compiling strsim v0.8.0
   Compiling linked-hash-map v0.5.4
   Compiling same-file v1.0.6
   Compiling ucd-trie v0.1.3
   Compiling safemem v0.3.3
   Compiling version_check v0.9.3
   Compiling xml-rs v0.8.3
   Compiling itoa v0.4.7
   Compiling bugreport v0.4.1
   Compiling base64 v0.13.0
   Compiling termcolor v1.1.2
   Compiling shell-escape v0.1.5
   Compiling lazycell v1.3.0
   Compiling std_prelude v0.2.12
   Compiling dtoa v0.4.8
   Compiling wild v2.0.4
   Compiling shell-words v1.0.0
   Compiling ansi_term v0.12.1
   Compiling tinyvec v1.2.0
   Compiling unicode-bidi v0.3.5
   Compiling encoding-index-singlebyte v1.20141219.5
   Compiling encoding-index-japanese v1.20141219.5
   Compiling encoding-index-tradchinese v1.20141219.5
   Compiling encoding-index-korean v1.20141219.5
   Compiling encoding-index-simpchinese v1.20141219.5
   Compiling line-wrap v0.1.1
   Compiling walkdir v2.3.2
   Compiling pest v2.1.3
   Compiling form_urlencoded v1.0.1
   Compiling regex-automata v0.1.9
   Compiling path_abs v0.5.1
   Compiling yaml-rust v0.4.5
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling miniz_oxide v0.4.4
   Compiling indexmap v1.6.2
   Compiling error-chain v0.12.4
   Compiling encoding v0.2.33
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.16
   Compiling content_inspector v0.2.4
   Compiling quote v1.0.9
   Compiling unicode-normalization v0.1.17
   Compiling semver-parser v0.10.2
   Compiling semver v0.11.0
   Compiling chrono v0.4.19
   Compiling atty v0.2.14
   Compiling term_size v0.3.2
   Compiling flate2 v1.0.20
   Compiling dirs-sys-next v0.1.2
   Compiling terminal_size v0.1.16
   Compiling textwrap v0.11.0
   Compiling dirs-next v2.0.0
   Compiling clap v2.33.3
   Compiling jobserver v0.1.22
   Compiling idna v0.2.3
   Compiling regex v1.5.4
   Compiling cc v1.0.67
   Compiling url v2.2.2
   Compiling libz-sys v1.1.3
   Compiling onig_sys v69.6.0
   Compiling sys-info v0.9.0
   Compiling libgit2-sys v0.12.21+1.1.0
   Compiling ansi_colours v1.0.4
   Compiling globset v0.4.8
   Compiling console v0.14.1
   Compiling grep-cli v0.1.6
   Compiling git-version-macro v0.3.4
   Compiling onig v6.1.1
   Compiling bat v0.18.3 (/home/buildroot/buildroot/output/build/bat-0.18.3)
   Compiling git-version v0.3.4
   Compiling git2 v0.13.20
   Compiling bincode v1.3.3
   Compiling plist v1.1.0
   Compiling serde_yaml v0.8.17
   Compiling clircle v0.3.0
   Compiling syntect v4.5.0
error: linking with `arm-none-linux-gnueabi-gcc` failed: exit status: 1
  |
  = note: "arm-none-linux-gnueabi-gcc" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/deps/bat-4471b2a57bffe2f9.bat.163418b7-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/deps" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/release/deps" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/build/ansi_colours-decaa8786ef1e93b/out" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/build/sys-info-054f71f505bff363/out" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/build/libgit2-sys-8134ffc088f48930/out/build" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/build/libz-sys-cc637e64eac095d8/out/lib" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/build/libz-sys-cc637e64eac095d8/out/lib" "-L" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/build/onig_sys-95f6c166737927e5/out" "-L" "/home/buildroot/buildroot/output/per-package/bat/host/lib64/rustlib/armv5te-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "/tmp/rustceCyJcC/libsys_info-f4b8a5896d118176.rlib" "/tmp/rustceCyJcC/libansi_colours-11e556d34e4e4d91.rlib" "/tmp/rustceCyJcC/liblibgit2_sys-ea6e3bc9089d1a8a.rlib" "/tmp/rustceCyJcC/liblibz_sys-7272aef01f904e4e.rlib" "/tmp/rustceCyJcC/libonig_sys-0993d1993b1cbd53.rlib" "-Wl,--start-group" "-Wl,--end-group" "/home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/buildroot/buildroot/output/per-package/bat/host/lib64/rustlib/armv5te-unknown-linux-gnueabi/lib" "-o" "/home/buildroot/buildroot/output/build/bat-0.18.3/target/armv5te-unknown-linux-gnueabi/release/deps/bat-4471b2a57bffe2f9" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
  = note: /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_add_4':
          linux-atomic.c:(.text+0x0): multiple definition of `__sync_fetch_and_add_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_sub_4':
          linux-atomic.c:(.text+0x38): multiple definition of `__sync_fetch_and_sub_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_or_4':
          linux-atomic.c:(.text+0x70): multiple definition of `__sync_fetch_and_or_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_and_4':
          linux-atomic.c:(.text+0xa8): multiple definition of `__sync_fetch_and_and_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_xor_4':
          linux-atomic.c:(.text+0xe0): multiple definition of `__sync_fetch_and_xor_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_nand_4':
          linux-atomic.c:(.text+0x118): multiple definition of `__sync_fetch_and_nand_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_add_2':
          linux-atomic.c:(.text+0x154): multiple definition of `__sync_fetch_and_add_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_sub_2':
          linux-atomic.c:(.text+0x1b8): multiple definition of `__sync_fetch_and_sub_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_or_2':
          linux-atomic.c:(.text+0x21c): multiple definition of `__sync_fetch_and_or_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_and_2':
          linux-atomic.c:(.text+0x280): multiple definition of `__sync_fetch_and_and_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_xor_2':
          linux-atomic.c:(.text+0x2e4): multiple definition of `__sync_fetch_and_xor_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_nand_2':
          linux-atomic.c:(.text+0x348): multiple definition of `__sync_fetch_and_nand_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_add_1':
          linux-atomic.c:(.text+0x3b0): multiple definition of `__sync_fetch_and_add_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_sub_1':
          linux-atomic.c:(.text+0x410): multiple definition of `__sync_fetch_and_sub_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_or_1':
          linux-atomic.c:(.text+0x470): multiple definition of `__sync_fetch_and_or_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_and_1':
          linux-atomic.c:(.text+0x4d0): multiple definition of `__sync_fetch_and_and_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_xor_1':
          linux-atomic.c:(.text+0x530): multiple definition of `__sync_fetch_and_xor_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_nand_1':
          linux-atomic.c:(.text+0x590): multiple definition of `__sync_fetch_and_nand_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_val_compare_and_swap_4':
          linux-atomic.c:(.text+0xc48): multiple definition of `__sync_val_compare_and_swap_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:102: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_val_compare_and_swap_2':
          linux-atomic.c:(.text+0xc94): multiple definition of `__sync_val_compare_and_swap_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:102: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_val_compare_and_swap_1':
          linux-atomic.c:(.text+0xd14): multiple definition of `__sync_val_compare_and_swap_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:102: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_synchronize':
          linux-atomic.c:(.text+0xdf4): multiple definition of `__sync_synchronize'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:209: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_lock_test_and_set_4':
          linux-atomic.c:(.text+0xe08): multiple definition of `__sync_lock_test_and_set_4'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_lock_test_and_set_2':
          linux-atomic.c:(.text+0xe40): multiple definition of `__sync_lock_test_and_set_2'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          /home/buildroot/buildroot/output/per-package/bat/host/opt/ext-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/libgcc.a(linux-atomic.o): In function `__sync_lock_test_and_set_1':
          linux-atomic.c:(.text+0xea0): multiple definition of `__sync_lock_test_and_set_1'
          /home/buildroot/buildroot/output/per-package/bat/host/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-7c9e64595edaafe9.rlib(compiler_builtins-7c9e64595edaafe9.compiler_builtins.37b1fe12-cgu.100.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.53/src/arm_linux.rs:94: first defined here
          collect2: error: ld returned 1 exit status
          

error: could not compile `bat` due to previous error

It appears this can be worked around with but that's not really a proper fix:

diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
index e74a8358bc..dca2fdb8c1 100644
--- a/package/pkg-cargo.mk
+++ b/package/pkg-cargo.mk
@@ -44,7 +44,8 @@ PKG_CARGO_ENV = \
        CARGO_UNSTABLE_TARGET_APPLIES_TO_HOST="true" \
        CARGO_TARGET_APPLIES_TO_HOST="false" \
        CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \
-       CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc
+       CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER="$(notdir $(TARGET_CROSS))gcc" \
+       CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_RUSTFLAGS="-Clink-arg=-Wl,--allow-multiple-definition"
 
 HOST_PKG_CARGO_ENV = \
        $(PKG_COMMON_CARGO_ENV)

@dcsommer
Copy link
Contributor Author

dcsommer commented Feb 3, 2022

@jameshilliard that looks potentially different. My symptom was duplicate symbols in the binary artifact distribution, but I only see 1 symbol for the ones where you are getting duplicate symbols during linking.

$ nm ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-0a549d41c237984e.rlib  | grep __sync_lock_test_and_set_1
00000000 T __sync_lock_test_and_set_1
nm: lib.rmeta: no symbols

@jameshilliard
Copy link

hmm, guess I'm getting a symbol conflict between compiler-builtins and the cross libgcc or something?

@Amanieu
Copy link
Member

Amanieu commented Feb 6, 2022

Hopefully this should be fixed by #452 which will be included in rust-lang/rust#93696. Please try it in the next nightly once that is merged.

vladimir-ea pushed a commit to vladimir-ea/compiler-builtins that referenced this issue Mar 8, 2022
The change in 186517b was intended to
affect only `arm-linux-androideabi` but also affected
`armv7-linux-androideabi` which is not a pre-ARMv6 architecture.
Fixes rust-lang#449
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants