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

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

Open
robertbastian opened this issue Jun 26, 2024 · 9 comments
Open
Labels
C-bug Category: bug Z-build-std Nightly: build-std

Comments

@robertbastian
Copy link

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
Copy link
Member

bjorn3 commented Jun 26, 2024

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

@robertbastian
Copy link
Author

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

@robertbastian
Copy link
Author

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

@workingjubilee workingjubilee changed the title unresolved import crate::sys::thread_local::key::StaticKey document args for -Zbuild-std when folks aren't building everything Jun 27, 2024
@workingjubilee
Copy link
Member

probably in the unstable book for the option?

@workingjubilee
Copy link
Member

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

@Enselic
Copy link
Member

Enselic commented Dec 3, 2024

Triage: The job to fix a nicer "UI" for -Zbuild-std belongs to the cargo project. Can someone with sufficient privileges move this to the cargo project please? Thanks!

@workingjubilee
Copy link
Member

@rustbot transfer cargo

@rustbot rustbot transferred this issue from rust-lang/rust Dec 3, 2024
@weihanglo
Copy link
Member

There was a discussion on Zulip about why people building std for no_std targets. I saw this issue but still confused about the actual use case. Is it just for a simpler CI script setup?

@workingjubilee
Copy link
Member

@weihanglo Despite the name -Zbuild-std, it's also quite useful for building libcore, and that's basically the main reason.

Embedded often wants this. For instance, there are cases where there is a target, but its baseline features don't include a feature your CPU has, so you want to rebuild the stdlib, which was compiled against that baseline, against your actual available features.

@weihanglo weihanglo added Z-build-std Nightly: build-std and removed -Zbuild-std labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Z-build-std Nightly: build-std
Projects
None yet
Development

No branches or pull requests

7 participants