Skip to content

Compilation error on platforms that do not have AtomicU32 from #896 #908

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

Closed
allanlw opened this issue May 6, 2025 · 2 comments · Fixed by #909
Closed

Compilation error on platforms that do not have AtomicU32 from #896 #908

allanlw opened this issue May 6, 2025 · 2 comments · Fixed by #909

Comments

@allanlw
Copy link

allanlw commented May 6, 2025

I hope this is the correct place to file this issue, I'm not too familiar with rust internals.

The recent change #896 adds an import for AtomicU32, but this is not available on the "bpfel-unknown-none" target. This is causing a downstream build issue in aya.

Reproduction:

$ cargo init --lib
    Creating library package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
$ cargo +nightly build --target=bpfel-unknown-none -Z build-std=core --release
   Compiling core v0.0.0 (/home/intr/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling compiler_builtins v0.1.157
   Compiling rustc-std-workspace-core v1.99.0 (/home/intr/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error[E0432]: unresolved import `core::sync::atomic::AtomicU32`
 --> /home/intr/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/compiler_builtins-0.1.157/src/math/libm_math/support/feature_detect.rs:3:26
  |
3 | use core::sync::atomic::{AtomicU32, Ordering};
  |                          ^^^^^^^^^
  |                          |
  |                          no `AtomicU32` in `sync::atomic`
  |                          help: a similar name exists in the module: `AtomicU64`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `compiler_builtins` (lib) due to 1 previous error

Downstream issue

This can be seen in a real-life example by following the instructions here for setting up an aya template repository, which will fail to build with the same error

@tamird
Copy link
Contributor

tamird commented May 6, 2025

@tgross35 flagging this for your consideration.

tgross35 added a commit to tgross35/compiler-builtins that referenced this issue May 6, 2025
The `feature_detect` module is currently being built on all targets, but
the use of `AtomicU32` causes a problem if atomics are not available
(such as with `bpfel-unknown-none`). Gate this module behind
`target_has_atomic = "ptr"`.

The below now completes successfully:

    cargo build -p compiler_builtins --target=bpfel-unknown-none -Z build-std=core

Fixes: rust-lang#908
@tgross35
Copy link
Contributor

tgross35 commented May 6, 2025

Thanks for reporting, this is indeed the correct place. #909 should resolve this.

tgross35 added a commit to tgross35/compiler-builtins that referenced this issue May 6, 2025
The `feature_detect` module is currently being built on all targets, but
the use of `AtomicU32` causes a problem if atomics are not available
(such as with `bpfel-unknown-none`). Gate this module behind
`target_has_atomic = "ptr"`.

The below now completes successfully:

    cargo build -p compiler_builtins --target=bpfel-unknown-none -Z build-std=core

Fixes: rust-lang#908
tgross35 added a commit that referenced this issue May 6, 2025
The `feature_detect` module is currently being built on all targets, but
the use of `AtomicU32` causes a problem if atomics are not available
(such as with `bpfel-unknown-none`). Gate this module behind
`target_has_atomic = "ptr"`.

The below now completes successfully:

    cargo build -p compiler_builtins --target=bpfel-unknown-none -Z build-std=core

Fixes: #908
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