rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.86k stars 12.67k forks source link

document args for `-Zbuild-std` when folks aren't building everything #126992

Open robertbastian opened 3 months ago

robertbastian commented 3 months ago

I tried this code:

$ cargo init repro
$ cd repro
$ cargo +nightly check --target thumbv8m.main-none-eabihf -Zbuild-std=std

I expected to see this happen: builds successfully

Instead, this happened:

   Compiling std v0.0.0 (.../.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
error[E0432]: unresolved import `crate::sys::thread_local::key::StaticKey`
 --> .../.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/thread_local/os.rs:5:5
  |
5 | use crate::sys::thread_local::key::StaticKey as OsKey;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `StaticKey` in `sys::thread_local::key`

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

Meta

$ rustc +nightly --version --verbose
rustc 1.81.0-nightly (fda509e81 2024-06-25)
binary: rustc
commit-hash: fda509e817abeeecb5b76bc1de844f355675c81e
commit-date: 2024-06-25
host: aarch64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7
bjorn3 commented 3 months ago

Isn't thumbv8m.main-none-eabihf (supposed to be) a no_std target? There is no OS such code runs on.

robertbastian commented 3 months ago

We're using -Zbuild-std=std to get -Zbuild-std-features=panic_immediate_abort. This works on older nightlies but might have changed?

robertbastian commented 3 months ago

We probably need to use -Zbuild-std=core,alloc -Zbuild-std-features=panic_immediate_abort

workingjubilee commented 3 months ago

probably in the unstable book for the option?

workingjubilee commented 3 months ago

sorry for absconding with your issue @robertbastian but it seems to me that not being able to build std is uhhh expected on a no_std target, even if it might have slightly funny results, whereas "how to steer -Zbuild-std correctly" seems to be inadequately documented for your particular usage, based on your remarks in unicode-org/icu4x#5132