Skip to content

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

Open

Description

@robertbastian

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

Activity

  1. bjorn3 commented on Jun 26, 2024

    @bjorn3
    Member

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

  2. robertbastian commented on Jun 26, 2024

    @robertbastian
    Author

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

  3. robertbastian commented on Jun 26, 2024

    @robertbastian
    Author

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

  4. changed the title [-]unresolved import `crate::sys::thread_local::key::StaticKey`[/-] [+]document args for `-Zbuild-std` when folks aren't building everything[/+] on Jun 27, 2024
  5. workingjubilee commented on Jun 27, 2024

    @workingjubilee
    Member

    probably in the unstable book for the option?

  6. workingjubilee commented on Jun 27, 2024

    @workingjubilee
    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

  7. Enselic commented on Dec 3, 2024

    @Enselic
    Member

    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!

  8. workingjubilee commented on Dec 3, 2024

    @workingjubilee
    Member

    @rustbot transfer cargo

  9. transferred this issue fromrust-lang/ruston Dec 3, 2024
  10. weihanglo commented on Dec 4, 2024

    @weihanglo
    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?

  11. workingjubilee commented on Dec 4, 2024

    @workingjubilee
    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.

  12. ConnorBP commented on Jan 15, 2025

    @ConnorBP

    Looks like thread locals are messing everyone’s day up huh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions