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

Supported target_pointer_width: 32, 64-bit only? #1468

Closed
dhardy opened this issue Jul 17, 2024 · 1 comment
Closed

Supported target_pointer_width: 32, 64-bit only? #1468

dhardy opened this issue Jul 17, 2024 · 1 comment
Labels
E-question Participation: opinions wanted

Comments

@dhardy
Copy link
Member

dhardy commented Jul 17, 2024

All tier 1 and tier 2 platforms supported by Rust are 32- or 64-bit.

#1144 is the only issue I see regarding 16-bit support. Apparently this worked, but has been disabled since (#1269). Attempting to compile now:

$ rustc -V
rustc 1.81.0-nightly (24d2ac0b5 2024-07-15)

$ cargo build -Z build-std=core --target=avr-unknown-gnu-atmega328 --no-default-features
  Downloaded addr2line v0.22.0
  Downloaded gimli v0.29.0
  Downloaded object v0.36.0
  Downloaded 3 crates (636.7 KB) in 0.25s
   Compiling compiler_builtins v0.1.109
   Compiling core v0.0.0 (/home/dhardy-extra/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
error: ran out of registers during register allocation

   Compiling rustc-std-workspace-core v1.99.0 (/home/dhardy-extra/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: could not compile `core` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

$ cargo build -Z build-std=core --target=msp430-none-elf --no-default-features
   Compiling core v0.0.0 (/home/dhardy-extra/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling compiler_builtins v0.1.109
   Compiling rustc-std-workspace-core v1.99.0 (/home/dhardy-extra/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling zerocopy v0.7.35
error[E0080]: evaluation of constant value failed
  --> /home/dhardy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/macro_util.rs:69:21
   |
69 | const _64K: usize = 1 << 16;
   |                     ^^^^^^^ attempt to shift left by `16_i32`, which would overflow

error[E0080]: evaluation of constant value failed
   --> /home/dhardy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:456:69
    |
456 |     const CURRENT_MAX_ALIGN: NonZeroUsize = match NonZeroUsize::new(1 << 28) {
    |                                                                     ^^^^^^^ attempt to shift left by `28_i32`, which would overflow

note: erroneous constant encountered
   --> /home/dhardy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:575:47
    |
575 |             debug_assert!(self.align.get() <= DstLayout::CURRENT_MAX_ALIGN.get());
    |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: erroneous constant encountered
   --> /home/dhardy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:576:48
    |
576 |             debug_assert!(field.align.get() <= DstLayout::CURRENT_MAX_ALIGN.get());
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: erroneous constant encountered
   --> /home/dhardy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zerocopy-0.7.35/src/lib.rs:578:52
    |
578 |                 debug_assert!(repr_packed.get() <= DstLayout::CURRENT_MAX_ALIGN.get());
    |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

As far as I can tell, these are the only 16-bit Tier 3 targets, and the first fails to build the core library while zerocopy fails to build the second (@josephlr).

I don't see Rust support for any other pointer width.


Summary: our code can assume that the pointer width is 32 or 64 bits.

We should make this assumption explicit where code depends on this, e.g.:

#[cfg(not(any(target_pointer_width = "32", target_pointer_width = "64")))]
const _: () = assert!(false, "unsupported pointer width");

(I'm working on a related PR.)

If anyone wishes to revive 16-bit support, then first we need a functional test platform (including dependencies). It may make sense to limit support to a small subset of rand. It will be considered at best a second-class platform, and tests will be disabled if they become problematic again.

@dhardy
Copy link
Member Author

dhardy commented Jul 17, 2024

Value-portability: we make some effort to make results like sequence shuffling reproducible across 32- and 64-bit platforms (for lists up to u32::MAX long). 16-bit platforms are excluded (and may skip value stability tests).

@dhardy dhardy mentioned this issue Jul 19, 2024
1 task
@dhardy dhardy added the E-question Participation: opinions wanted label Jul 23, 2024
@dhardy dhardy closed this as completed Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-question Participation: opinions wanted
Projects
None yet
Development

No branches or pull requests

1 participant