-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check build target supports std when building with -Zbuild-std=std (#…
…14183) **What does this PR try to resolve?** Ensures that Cargo first verifies whether a given target supports building the standard library when the `-Zbuild-std=std` option is passed to Cargo ([see issue here](rust-lang/wg-cargo-std-aware#87)). This information can be obtained by querying `rustc --print=target-spec-json`. The target spec "metadata" contains an `Option<bool>` determining whether the target supports building std. In the case this value is `false`, cargo will stop the build. This avoids the numerous "use of unstable library" errors, giving a cleaner, and simpler, "building std is not supported on this target". **How should we test and review this PR?** It can be manually tested by running `cargo build --target <target> -Zbuild-std=std`. If a target who's target-spec marks std as false is passed, cargo will exit. This works with multiple `--target`'s, and if any of them don't support std, cargo will exit. **Additional Information** This change relies on two things: * The target-spec metadata in rustc needs to be filled out. Currently, most fields are None, which is treated as OK with this change. Meaning this can be merged before the rustc changes. * The new test case added with this change will fail without at least `aarch64-unknown-none` having it's target-spec metadata completed. * Some targets have std support marked as "?". If this state is properly represented in the target-spec in the future, it needs to be determined whether this is allowed, so the build can continue, or whether it fails.
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters