[Pkg-rust-maintainers] Bug#1028629: rustc: (some) atomic intrinsics on armel broken

Fabian Grünbichler debian at fabian.gruenbichler.email
Fri Jan 13 21:57:26 GMT 2023


Package: rustc
Version: 1.63.0+dfsg1-1
Severity: important
X-Debbugs-Cc: pkg-rust-maintainers at alioth-lists.debian.net

rustc fails to (successfully) link crates using parts of
std::sync::atomic, e.g. the following code in (lib) crate bar:

------8<-----
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering;

pub fn max(left: AtomicU32, right: u32) -> u32 {
    left.fetch_max(right, Ordering::SeqCst)
}
------>8-----

and the following code in (bin) crate foo:

------8<-----
use std::sync::atomic::AtomicU32;

use bar;

fn main() {
    println!("{}", bar::max(AtomicU32::new(7), 5));
}
------>8-----

will lead to the following linking error on armel:

------8<-----
# cargo run --release
   Compiling foo v0.1.0 (/build/test/foo)
error: linking with `cc` failed: exit status: 12: foo(bin)
  |
  = note: "cc" "/tmp/rustcTFx4i9/symbols.o" "/build/test/foo/target/release/deps/foo-59f27b1de92f2acd.foo.1afac17f-cgu.0.rcgu.o" "/build/test/foo/target/release/deps/foo-59f27b1de92f2acd.foo.1afac17f-cgu.1.rcgu.o" "/build/test/foo/target/release/deps/foo-59f27b1de92f2acd.foo.1afac17f-cgu.2.rcgu.o" "/build/test/foo/target/release/deps/foo-59f27b1de92f2acd.20wjxsqwz98t4wkq.rcgu.o" "-Wl,--as-needed" "-L" "/build/test/foo/target/release/deps" "-L" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "/build/test/foo/target/release/deps/libbar-7fb8e41530f4ad06.rlib" "-Wl,--start-group" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd-6a651d83c44843bb.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libpanic_unwind-98224a094117fb61.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libobject-6353760ce6c6ab47.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libmemchr-b7d0d45279218739.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libaddr2line-eda5e1e22d9f768c.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libgimli-f2321664649c6488.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/librustc_demangle-1882c2f330ea3722.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd_detect-1e9ab0673b70075d.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libhashbrown-a18bf1b0b60baadc.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libminiz_oxide-eb7e10deb950ff71.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libadler-ebe0d9eb71624a17.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/librustc_std_workspace_alloc-d0b17dce6de8f743.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libunwind-b85b839502ab2b62.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcfg_if-2adecf55c5fb13fa.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liblibc-3cb92b5edcc2e566.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liballoc-657f47a57064518b.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/librustc_std_workspace_core-bc3b35b3d32be632.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcore-c809391b20961e50.rlib" "-Wl,--end-group" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-bc99d51bba3f7a8e.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "-o" "/build/test/foo/target/release/deps/foo-59f27b1de92f2acd" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
  = note: /usr/bin/ld: /build/test/foo/target/release/deps/libbar-7fb8e41530f4ad06.rlib(bar-7fb8e41530f4ad06.bar.b0a8f44d-cgu.0.rcgu.o): in function `bar::add':
          bar.b0a8f44d-cgu.0:(.text._ZN3bar3add17hce88dc9d839331b9E+0x24): undefined reference to `__sync_fetch_and_umax_4'
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `foo` due to previous error
(debian-test-armel-sbuild)root at zen:/build/test/foo# cargo clean
(debian-test-armel-sbuild)root at zen:/build/test/foo# cargo run
   Compiling bar v0.1.0 (/build/test/bar)
   Compiling foo v0.1.0 (/build/test/foo)  ] 0/2: bar
error: linking with `cc` failed: exit status: 12: foo(bin)
  |
  = note: "cc" "/tmp/rustckvzoGP/symbols.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.2e9m1dxvxhlpjv6f.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.2kv2r3chzehpy591.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.2w6od5db0a6s353m.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.35evzsnqbqvn39ld.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.3yygjnxroz9tmefv.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.48oa1oyzhlw2s0yn.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.4yrs2bs7ga5tcxkm.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.50n9myic4x4ni1vl.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.59pg060x0csuwdni.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.5dyoc2mxjoyzc19o.rcgu.o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8.3c7gfoqt6aheh1qz.rcgu.o" "-Wl,--as-needed" "-L" "/build/test/foo/target/debug/deps" "-L" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "/build/test/foo/target/debug/deps/libbar-9c3d467fdf627c5e.rlib" "-Wl,--start-group" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd-6a651d83c44843bb.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libpanic_unwind-98224a094117fb61.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libobject-6353760ce6c6ab47.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libmemchr-b7d0d45279218739.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libaddr2line-eda5e1e22d9f768c.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libgimli-f2321664649c6488.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/librustc_demangle-1882c2f330ea3722.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd_detect-1e9ab0673b70075d.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libhashbrown-a18bf1b0b60baadc.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libminiz_oxide-eb7e10deb950ff71.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libadler-ebe0d9eb71624a17.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/librustc_std_workspace_alloc-d0b17dce6de8f743.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libunwind-b85b839502ab2b62.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcfg_if-2adecf55c5fb13fa.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liblibc-3cb92b5edcc2e566.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liballoc-657f47a57064518b.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/librustc_std_workspace_core-bc3b35b3d32be632.rlib" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcore-c809391b20961e50.rlib" "-Wl,--end-group" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-bc99d51bba3f7a8e.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/usr/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "-o" "/build/test/foo/target/debug/deps/foo-f1598fa86eee5ab8" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /build/test/foo/target/debug/deps/libbar-9c3d467fdf627c5e.rlib(bar-9c3d467fdf627c5e.fpbiq7drr8wt5kg.rcgu.o): in function `core::sync::atomic::atomic_umax':
          /usr/src/rustc-1.63.0/library/core/src/sync/atomic.rs:2808: undefined reference to `__sync_fetch_and_umax_4'
          /usr/bin/ld: /usr/src/rustc-1.63.0/library/core/src/sync/atomic.rs:2806: undefined reference to `__sync_fetch_and_umax_4'
          /usr/bin/ld: /usr/src/rustc-1.63.0/library/core/src/sync/atomic.rs:2805: undefined reference to `__sync_fetch_and_umax_4'
          /usr/bin/ld: /usr/src/rustc-1.63.0/library/core/src/sync/atomic.rs:2807: undefined reference to `__sync_fetch_and_umax_4'
          /usr/bin/ld: /usr/src/rustc-1.63.0/library/core/src/sync/atomic.rs:2809: undefined reference to `__sync_fetch_and_umax_4'
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `foo` due to previous error
----->8-----

this is just a sample, there are other parts of the atomic module that
work, and other parts that also don't.

the same issue is also found in rust-portable-atomic's autopkgtest on armel:
https://ci.debian.net/data/autopkgtest/testing/armel/r/rust-portable-atomic/30099189/log.gz

as well as in rustc 1.64.0+dfsg1-1~exp1 (failed) build attempt on armel:
https://buildd.debian.org/status/fetch.php?pkg=rustc&arch=armel&ver=1.64.0%2Bdfsg1-1%7Eexp1&stamp=1671720801&raw=0

I am fairly certain the following two commits (part of 1.64.0+dfsg1-1~exp2) fix the issue:
https://salsa.debian.org/rust-team/rust/-/commit/9d0c1f2042b4eba728e84d97245227e0121f1b1c
https://salsa.debian.org/rust-team/rust/-/commit/af9e9923ea3d0a8a7fa9c48d369c0c09445b8656

just disabling the hacky workaround or adding either of the two
compiler_builtins cherry-picks still lead to the rustc build failing,
but the current version in experimental not only built fine on armel, it
also runs both the linked rust-portable-atomic autopkgtest and the
minimal reproducer in this bug successfully on armel.

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-1-amd64 (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages rustc depends on:
ii  binutils              2.39.90.20230110-1
ii  gcc                   4:12.2.0-3
ii  libc6                 2.36-8
ii  libc6-dev [libc-dev]  2.36-8
ii  libgcc-s1             12.2.0-14
ii  libstd-rust-dev       1.63.0+dfsg1-1

Versions of packages rustc recommends:
ii  cargo    0.66.0+ds1-1
ii  llvm-14  1:14.0.6-10+b1

Versions of packages rustc suggests:
ii  clang-14  1:14.0.6-10+b1
pn  lld-14    <none>

-- no debconf information



More information about the Pkg-rust-maintainers mailing list