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

Failing to build on certain embedded platforms #2400

Open
1 of 2 tasks
joshlf opened this issue Feb 27, 2025 · 5 comments
Open
1 of 2 tasks

Failing to build on certain embedded platforms #2400

joshlf opened this issue Feb 27, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@joshlf
Copy link
Member

joshlf commented Feb 27, 2025

Progress

  • Fix build failures: Support 16-bit target platforms #2401
  • Add a regression test
    • Note that this is blocked on being able to roll our pinned nightly toolchain in order to bring in this upstream commit
    • The relevant build command is: RUSTFLAGS='-C target-cpu=atmega328p' cargo +nightly-2025-02-25 check --target=avr-none -Zbuild-std=core

Originally reported by @ErickTorresBrownU in rust-random/rand#1574 (comment):

For instance, I can no longer compile my embedded Rust code because rand/rand_core now depends on zerocopy.

error[E0080]: evaluation of constant value failed
   --> C:\Users\erick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\zerocopy-0.8.20\src\layout.rs:120:80
    |
120 |     pub(crate) const CURRENT_MAX_ALIGN: NonZeroUsize = match NonZeroUsize::new(1 << 28) {
    |                                                                                ^^^^^^^ attempt to shift left by `28_i32`, which would overflow

@ErickTorresBrownU, what platform are you building for here? We would like to support this use case and add this platform to our CI so we don't regress.

@joshlf joshlf added the bug Something isn't working label Feb 27, 2025
@ErickTorresBrownU
Copy link

Arduino Nano ~ avr-atmega328p

@joshlf
Copy link
Member Author

joshlf commented Feb 27, 2025

EDIT: Nevermind, figured it out 🙂


Okay thanks. What build command are you using? I'm trying but getting this failure:

$ RUSTFLAGS='-C target-cpu=atmega328p' cargo +nightly-2025-02-25 check --target=avr-none -Zbuild-std
   Compiling gimli v0.31.1
   Compiling miniz_oxide v0.8.3
error[E0432]: unresolved import `alloc::sync`
 --> .../.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gimli-0.31.1/src/read/dwarf.rs:2:12
  |
2 | use alloc::sync::Arc;
  |            ^^^^ could not find `sync` in `alloc`

error[E0432]: unresolved import `alloc::sync`
 --> .../.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gimli-0.31.1/src/read/abbrev.rs:4:12
  |
4 | use alloc::sync::Arc;
  |            ^^^^ could not find `sync` in `alloc`

error: values of the type `[u8; 32768]` are too big for the target architecture
  --> .../.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/miniz_oxide-0.8.3/src/inflate/stream.rs:86:5
   |
86 |     fn default() -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^

error: could not compile `miniz_oxide` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
For more information about this error, try `rustc --explain E0432`.
error: could not compile `gimli` (lib) due to 2 previous errors

By contrast, if I build without -Zbuild-std, I get:

$ RUSTFLAGS='-C target-cpu=atmega328p' cargo +nightly-2025-02-25 check --target=avr-none
    Checking zerocopy v0.8.20 (.../workspace/zerocopy)
error[E0463]: can't find crate for `core`
  |
  = note: the `avr-none` target may not be installed
  = help: consider downloading the target with `rustup target add avr-none`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

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

joshlf added a commit that referenced this issue Feb 27, 2025
Since we currently can't roll our pinned nightly toolchain, and since
support for the avr target which initially caused us to notice this
issue was only added on nightly recently, this commit does not add a
regression test. That will be done later as part of #2400 once we are
able to roll our pinned nightly toolchain.

Makes progress on #2400

gherrit-pr-id: I2ce6e9e0c2ba1cbe24c8cc5686e5b9b519bbf102
github-merge-queue bot pushed a commit that referenced this issue Feb 27, 2025
Since we currently can't roll our pinned nightly toolchain, and since
support for the avr target which initially caused us to notice this
issue was only added on nightly recently, this commit does not add a
regression test. That will be done later as part of #2400 once we are
able to roll our pinned nightly toolchain.

Makes progress on #2400

gherrit-pr-id: I2ce6e9e0c2ba1cbe24c8cc5686e5b9b519bbf102
@joshlf
Copy link
Member Author

joshlf commented Feb 27, 2025

We've published a fix in 0.8.21. @ErickTorresBrownU can you confirm that this fixes your issue?

@ErickTorresBrownU
Copy link

Just applied the changes and yes, the issue is resolved with your changes. Good job! 🤗

@joshlf
Copy link
Member Author

joshlf commented Feb 28, 2025

Okay great, thanks for testing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants