Skip to content

undefined reference to __atomic_load_4 when compiling the agb crate #100619

Closed

Description

@Lymia

If you try to compile the agb crate with just build-roms, it fails with the following error:

+ cargo build --release --target thumbv4t-none-eabi
   Compiling the-purple-night v0.1.0 (/home/aino/data/projects/crates/agb/examples/the-purple-night)
error: linking with `arm-none-eabi-ld` failed: exit status: 1
  |
  = note: "arm-none-eabi-ld" "/tmp/rustconD6i5/symbols.o" "/home/aino/data/projects/crates/agb/target/thumbv4t-none-eabi/release/deps/the_purple_night-b8ba75b4faeb98b5.the_purple_night.62ef94b1-cgu.0.rcgu.o" "--as-needed" "-L" "/home/aino/data/projects/crates/agb/target/thumbv4t-none-eabi/release/deps" "-L" "/home/aino/data/projects/crates/agb/target/release/deps" "-L" "/home/aino/data/projects/crates/agb/target/thumbv4t-none-eabi/release/build/agb-5ac9222d9e5ae2ce/out" "-L" "/home/aino/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv4t-none-eabi/lib" "--start-group" "--end-group" "-Bstatic" "/home/aino/data/projects/crates/agb/target/thumbv4t-none-eabi/release/deps/libcompiler_builtins-3b5407e0191965f8.rlib" "-Bdynamic" "--eh-frame-hdr" "-znoexecstack" "-L" "/home/aino/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv4t-none-eabi/lib" "-o" "/home/aino/data/projects/crates/agb/target/thumbv4t-none-eabi/release/deps/the_purple_night-b8ba75b4faeb98b5" "--gc-sections" "-O1" "-Tgba.ld"
  = note: arm-none-eabi-ld: /home/aino/data/projects/crates/agb/target/thumbv4t-none-eabi/release/deps/libcompiler_builtins-3b5407e0191965f8.rlib(compiler_builtins-3b5407e0191965f8.compiler_builtins.01837706-cgu.0.rcgu.o): in function `compiler_builtins::mem::memmove':
          compiler_builtins.01837706-cgu.0:(.text._ZN17compiler_builtins3mem7memmove17h382c238f4a6131d3E+0x66): undefined reference to `__atomic_load_4'
          arm-none-eabi-ld: compiler_builtins.01837706-cgu.0:(.text._ZN17compiler_builtins3mem7memmove17h382c238f4a6131d3E+0xe8): undefined reference to `__atomic_load_4'
          
  = 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 `the-purple-night` due to previous error
error: Recipe `_build-rom` failed with exit code 101
error: Recipe `build-roms` failed on line 51 with exit code 101

This seems to be a regression from nightly-2022-08-12 to nightly-2022-08-13, and my best guess for the change that caused it is this pull request: #99464

Activity

  1. changed the title [-]undefined reference to `__atomic_load_4' when compiling the `agb` crate[/-] [+]undefined reference to `__atomic_load_4` when compiling the `agb` crate[/+] on Aug 16, 2022
  2. taiki-e commented on Aug 16, 2022

    @taiki-e
    Member

    Filed #100621 to fix this.
    FYI, a short-term workaround is to enable the atomics-32 target feature (-C target-feature=+atomics-32).

    @rustbot claim

  3. added a commit that references this issue on Aug 17, 2022
    3284895
  4. added
    O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
    A-atomicArea: Atomics, barriers, and sync primitives
    O-bare-metalTarget: Rust without an operating system
    on Aug 17, 2022
  5. added a commit that references this issue on Aug 17, 2022
    64cd657
  6. John-Nagle commented on Feb 20, 2023

    @John-Nagle

    Possibly related: https://users.rust-lang.org/t/cross-compile-works-in-debug-mode-fails-in-release-mode/89574

    This is seen cross-compiling from Linux to Windows. Giant 1MB linker error message related to atomic_load, only in release mode, for target x86_64-pc-windows-gnu. Failing in rustc 1.67.1 stable. Currently asking for help comments; will file an issue in a day or two if nobody reports a known fix.

  7. taiki-e commented on Feb 20, 2023

    @taiki-e
    Member

    @John-Nagle
    Since native atomic ops exist in x86_64, I don't believe this and #92897 are related to your problem.

    Given that rend3 has enabled thin LTO, your problem may be related to #98302.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-atomicArea: Atomics, barriers, and sync primitivesC-bugCategory: This is a bug.O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 stateO-bare-metalTarget: Rust without an operating system

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions