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

Misdetects arm_llsc and fails to build on thumbv6m-none-eabi with -C linker-plugin-lto=y #463

Open
kevinmehall opened this issue Mar 16, 2024 · 0 comments
Labels

Comments

@kevinmehall
Copy link

kevinmehall commented Mar 16, 2024

After updating heapless to 0.8 in my project (as a transitive dependency of usb-device 0.3.2), it fails to build with:

error[E0599]: no method named `fetch_add` found for struct `AtomicUsize` in the current scope
   --> src/pool/arc.rs:235:44
    |
235 |         let old_size = self.inner().strong.fetch_add(1, Ordering::Relaxed);
    |                                            ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
   --> src/pool/arc.rs:282:32
    |
282 |         if self.inner().strong.fetch_sub(1, Ordering::Release) != 1 {
    |                                ^^^^^^^^^ method not found in `AtomicUsize`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `heapless` (lib) due to 2 previous errors

I noticed in cargo build -v that it was building with --cfg arm_llsc, and tracked this down to my -C linker-plugin-lto=y in RUSTFLAGS. It seems that the asm in ARM_LLSC_PROBE in build.rs gets optimized out and successfully builds in this configuration, despite thumbv6m not supporting atomics.

This is reproducible in this repository with

cargo clean
RUSTFLAGS='-Clinker-plugin-lto=y' cargo build --target thumbv6m-none-eabi -v
$ cat target/thumbv6m-none-eabi/debug/build/heapless-*/output         
cargo:rustc-cfg=has_atomic_load_store
cargo:rustc-cfg=arm_llsc
@newAM newAM added the bug label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants