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

fix(build-std): determining root crates by target spec std:bool #74

Closed
wants to merge 6 commits into from

Conversation

weihanglo
Copy link
Owner

No description provided.

The only functionality of `standard_lib::std_crates` is adding `test` to
the requested crate list. `resolve_std` already unconditionally adds
`sysroot` to the list, which always includes `test` in dependency graph.
Therefore calling `std_crates` is redundant.
@weihanglo weihanglo force-pushed the build-std branch 4 times, most recently from d744afe to f25bf82 Compare December 6, 2024 04:01
Instead of altering the original `-Zbuild-std` arg value,
this defers the timing of detereming which crate to build
to when Cargo generates std root units.
sysroot depends on `std`, `proc_macro`, and `test` [1],
which includes everything we need from the default set of crates.

Passing `sysroot` alone as spec should produce the same resolution.

[1]: https://github.com/rust-lang/rust/blob/acabb5248231987ae1f0c215208d1005a5db402d/library/sysroot/Cargo.toml#L7-L11
Will let `std:bool` to determine necessary deps for `-Zbuild-std`,
instead of erroring out.
In rust-lang#14183 Cargo starts bailing out if the `metadata.std`
field in a target spec JSON is set to `false`.
This is problematic because std for some targets are actually buildable
even they've declared as std-unsupported.

This patch removes the hard error, and instead determines the required
root crates by the `metadata.std` field. That is to say, if a target
is explicitly declared as `std: false`, `-Zbuild-std` will build `core`
and `compiler-builtins` only, no `std` will be built.

This patch doesn't change the behavior of `-Zbuild-std` with explicit
crates set. For example `-Zbuild-std=std` will force building `std`.

See Zulip discussion:
https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/help.20debugging.20a.20docs.2Ers.20issue.20with.20a.20new.20cargo.20error
@weihanglo weihanglo closed this Dec 6, 2024
@weihanglo weihanglo deleted the build-std branch December 10, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant