Skip to content

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

Closed
@dcsommer

Description

@dcsommer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions