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

Multiple definitions of atomic builtins on armv5te-unknown-linux-gnu #48625

Open
glaubitz opened this issue Mar 1, 2018 · 2 comments
Open

Multiple definitions of atomic builtins on armv5te-unknown-linux-gnu #48625

glaubitz opened this issue Mar 1, 2018 · 2 comments
Labels
C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@glaubitz
Copy link
Contributor

glaubitz commented Mar 1, 2018

Trying to cross-compile the Rust compiler for armv5te-unknown-linux-gnu fails with:

   Compiling panic_unwind v0.0.0 (file:///srv/glaubitz/rustc-1.24.0-src/src/libpanic_unwind)
error: linking with `arm-linux-gnueabi-gcc` failed: exit code: 1
  |
  = note: "arm-linux-gnueabi-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std0-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std1-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std10-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std11-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std12-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std13-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std14-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std15-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std2-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std3-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std4-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std5-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std6-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std7-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std8-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.std9-35a626bb176191a3631d2276b7a6938e.rs.rcgu.o" "-o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libstd-c05b4157967490d3.so" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.crate.metadata.rcgu.o" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/std-c05b4157967490d3.crate.allocator.rcgu.o" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/release/deps" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/armv5te-unknown-linux-gnueabi/native/libbacktrace/.libs" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/armv5te-unknown-linux-gnueabi/native/jemalloc/lib" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/build/compiler_builtins-830f2ed062697681/out" "-L" "/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-Wl,-Bstatic" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/libpanic_unwind-d795c34fd7eb72c9.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/libunwind-0f4b95d88e53e455.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/liballoc_jemalloc-276e820bb149c519.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/liballoc_system-6d9370e956155877.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/liblibc-f874e85b0fc1f5b8.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/liballoc-c7758873e5bedec1.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/libstd_unicode-c9b8ae6d904bd621.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/libcore-c80c8268f013635d.rlib" "-Wl,--no-whole-archive" "/tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib" "-Wl,-Bdynamic" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util" "-shared" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/lib/gcc-cross/arm-linux-gnueabi/7/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_add_4':
          (.text+0x0): multiple definition of `__sync_fetch_and_add_4'
          /tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib(compiler_builtins-6389cf691b0a8db6.compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs.rcgu.o):compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs:(.text.__sync_fetch_and_add_4+0x0): first defined here
          /usr/lib/gcc-cross/arm-linux-gnueabi/7/libgcc.a(linux-atomic.o): In function `__sync_fetch_and_sub_4':
          (.text+0x38): multiple definition of `__sync_fetch_and_sub_4'
          /tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib(compiler_builtins-6389cf691b0a8db6.compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs.rcgu.o):compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs:(.text.__sync_fetch_and_sub_4+0x0): first defined here
(...)
          /usr/lib/gcc-cross/arm-linux-gnueabi/7/libgcc.a(linux-atomic.o): In function `__sync_synchronize':
          (.text+0xda4): multiple definition of `__sync_synchronize'
          /tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib(compiler_builtins-6389cf691b0a8db6.compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs.rcgu.o):compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs:(.text.__sync_synchronize+0x0): first defined here
          /usr/lib/gcc-cross/arm-linux-gnueabi/7/libgcc.a(linux-atomic.o): In function `__sync_lock_test_and_set_4':
          (.text+0xdb0): multiple definition of `__sync_lock_test_and_set_4'
          /tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib(compiler_builtins-6389cf691b0a8db6.compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs.rcgu.o):compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs:(.text.__sync_lock_test_and_set_4+0x0): first defined here
          /usr/lib/gcc-cross/arm-linux-gnueabi/7/libgcc.a(linux-atomic.o): In function `__sync_lock_test_and_set_2':
          (.text+0xde8): multiple definition of `__sync_lock_test_and_set_2'
          /tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib(compiler_builtins-6389cf691b0a8db6.compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs.rcgu.o):compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs:(.text.__sync_lock_test_and_set_2+0x0): first defined here
          /usr/lib/gcc-cross/arm-linux-gnueabi/7/libgcc.a(linux-atomic.o): In function `__sync_lock_test_and_set_1':
          (.text+0xe48): multiple definition of `__sync_lock_test_and_set_1'
          /tmp/rustc.Z9Z1qX4dirp5/libcompiler_builtins-6389cf691b0a8db6.rlib(compiler_builtins-6389cf691b0a8db6.compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs.rcgu.o):compiler_builtins1-4ad3f5eb4daeb9d58eb1d1b812eea230.rs:(.text.__sync_lock_test_and_set_1+0x0): first defined here
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `std`.

Caused by:
  process didn't exit successfully: `/srv/glaubitz/rustc-1.24.0-src/build/bootstrap/debug/rustc --crate-name std src/libstd/lib.rs --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 --cfg feature="alloc_jemalloc" --cfg feature="backtrace" --cfg feature="jemalloc" --cfg feature="panic-unwind" --cfg feature="panic_unwind" -C metadata=c05b4157967490d3 -C extra-filename=-c05b4157967490d3 --out-dir /srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps --target armv5te-unknown-linux-gnueabi -L dependency=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps -L dependency=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --extern unwind=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libunwind-0f4b95d88e53e455.rlib --extern alloc_jemalloc=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/liballoc_jemalloc-276e820bb149c519.rlib --extern panic_unwind=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libpanic_unwind-d795c34fd7eb72c9.rlib --extern libc=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/liblibc-f874e85b0fc1f5b8.rlib --extern alloc_system=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/liballoc_system-6d9370e956155877.rlib --extern alloc=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/liballoc-c7758873e5bedec1.rlib --extern compiler_builtins=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libcompiler_builtins-6389cf691b0a8db6.rlib --extern panic_abort=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libpanic_abort-28e388772239c881.rlib --extern core=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libcore-c80c8268f013635d.rlib --extern std_unicode=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/deps/libstd_unicode-c9b8ae6d904bd621.rlib -L native=/srv/glaubitz/rustc-1.24.0-src/build/armv5te-unknown-linux-gnueabi/native/libbacktrace/.libs -l static=backtrace -l dl -l rt -l pthread -L native=/srv/glaubitz/rustc-1.24.0-src/build/armv5te-unknown-linux-gnueabi/native/jemalloc/lib -L native=/srv/glaubitz/rustc-1.24.0-src/build/x86_64-unknown-linux-gnu/stage1-std/armv5te-unknown-linux-gnueabi/release/build/compiler_builtins-830f2ed062697681/out` (exit code: 101)
thread 'main' panicked at 'command did not execute successfully: "/usr/local/bin/cargo" "build" "--target" "armv5te-unknown-linux-gnueabi" "-j" "64" "--release" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/srv/glaubitz/rustc-1.24.0-src/src/libstd/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101', src/bootstrap/compile.rs:886:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failed to run: /srv/glaubitz/rustc-1.24.0-src/build/bootstrap/debug/bootstrap build
Build completed unsuccessfully in 0:19:05
glaubitz@epyc:/srv/glaubitz/rustc-1.24.0-src$

This happens because Rust's own libcompiler_builtins provides atomic builtins like __sync_synchronize despite the fact that gcc already provides these builtins itself. The builtins provided by libcompiler_builtins should therefore be disabled.

I could not find where those are defined, but I could only find a reference to them: https://github.com/rust-lang/rust/blob/master/src/librustc_back/target/armv5te_unknown_linux_gnueabi.rs#L30

CC @jrtc27
CC @malbarbo

@sanxiyn sanxiyn added the O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Mar 2, 2018
@sanxiyn
Copy link
Member

sanxiyn commented Mar 2, 2018

__sync_synchronize is defined here.

@glaubitz
Copy link
Contributor Author

glaubitz commented Mar 2, 2018

@sanxiyn Thanks, this helps a lot! Will try to come up with a sensible patch.

@XAMPPRocky XAMPPRocky added A-cross Area: Cross compilation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 21, 2018
@sanxiyn sanxiyn removed the A-cross Area: Cross compilation label Mar 25, 2019
Centril added a commit to Centril/rust that referenced this issue Apr 7, 2020
…nits, r=alexcrichton

Keep codegen units unmerged when building compiler builtins

Make it possible to control how mono items are partitioned into code generation
units, when compiling the compiler builtins, by retaining the original partitioning.

Helps with rust-lang#48625, rust-lang#61063, rust-lang#67960, rust-lang#70489.

r? @alexcrichton
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 7, 2020
…nits, r=alexcrichton

Keep codegen units unmerged when building compiler builtins

Make it possible to control how mono items are partitioned into code generation
units, when compiling the compiler builtins, by retaining the original partitioning.

Helps with rust-lang#48625, rust-lang#61063, rust-lang#67960, rust-lang#70489.

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants