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

Attempting to use Atomics larger than max. atomic width #731

Closed
utsavm9 opened this issue Aug 6, 2021 · 2 comments
Closed

Attempting to use Atomics larger than max. atomic width #731

utsavm9 opened this issue Aug 6, 2021 · 2 comments

Comments

@utsavm9
Copy link

utsavm9 commented Aug 6, 2021

I am trying to compile crossbeam-utils = "0.8" for a non-unix target and I get this error:

error[E0432]: unresolved imports `core::sync::atomic::AtomicI64`, `core::sync::atomic::AtomicU64`
  --> /home/utsav/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.5/src/lib.rs:79:49
   |
79 |             pub(crate) use core::sync::atomic::{AtomicI64, AtomicU64}; 
   |                                                 ^^^^^^^^^  ^^^^^^^^^ no `AtomicU64` in `sync::atomic`
   |                                                 |
   |                                                 no `AtomicI64` in `sync::atomic`
   |

The target I am compiling to has max_atomic_width: Some(32), set similar to what it is here:
https://github.com/rust-lang/rust/blob/e3231e35b6bbfabca1d9ceff9c4690af00328706/src/librustc_back/target/armv4t_unknown_linux_gnueabi.rs#L31

So, I think it makes sense why AtomicI64, AtomicU64 are not available from the standard library for my target. I see that you have a crossbeam_no_atomic_64 cfg available, but I could not set it like:

crossbeam-utils = { version = "0.8", features = ["crossbeam_no_atomic_64"]}
// errors with:
// the package `testdep` depends on `crossbeam-utils`, with features: `crossbeam_no_atomic_64` but `crossbeam-utils` does not have these features.

Do you know a way I can make it compile where maximum atomic width is 32 bits?

@utsavm9 utsavm9 changed the title Attempting to use more than max. atomic width Attempting to use Atomics larger than max. atomic width Aug 6, 2021
@taiki-e
Copy link
Member

taiki-e commented Aug 7, 2021

Currently, crossbeam's build script only handles built-in targets. For custom targets, it is recommended that set rustflags for now. See also #698, rust-lang/futures-rs#2400, rust-lang/futures-rs#2294.

So, I think it makes sense why AtomicI64, AtomicU64 are not available from the standard library for my target. I see that you have a crossbeam_no_atomic_64 cfg available, but I could not set it like:

To enable cfg, use RUSTFLAGS environment variable or rustflags config, instead of cargo feature.

bors bot added a commit that referenced this issue Aug 7, 2021
732: Add comment about cfgs to build script r=taiki-e a=taiki-e

cc #731 #433

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@utsavm9
Copy link
Author

utsavm9 commented Aug 10, 2021

This way of specifying rustflags in rust-project/.cargo/config.toml worked for me:

[target.my-custom-target]
rustflags = ["--cfg", "crossbeam_no_atomic_64"]

Thanks for helping!

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

No branches or pull requests

2 participants