Skip to content

Commit

Permalink
refactor(build-std): sysroot has everything we need for Resolve
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weihanglo committed Dec 6, 2024
1 parent 30d11ce commit 125e873
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/cargo/core/compiler/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ pub fn resolve_std<'gctx>(
// `[dev-dependencies]`. No need for us to generate a `Resolve` which has
// those included because we'll never use them anyway.
std_ws.set_require_optional_deps(false);
// `sysroot` is not in the default set because it is optional, but it needs
// to be part of the resolve in case we do need it or `libtest`.
let mut spec_pkgs: Vec<String> = crates.iter().map(|s| s.to_string()).collect();
spec_pkgs.push("sysroot".to_string());
let spec = Packages::Packages(spec_pkgs);
let specs = spec.to_package_id_specs(&std_ws)?;
// `sysroot` + the default feature set below should give us a good default
// Resolve, which includes `libtest` as well.
let specs = Packages::Packages(vec!["sysroot".into()]);
let specs = specs.to_package_id_specs(&std_ws)?;
let features = match &gctx.cli_unstable().build_std_features {
Some(list) => list.clone(),
None => vec![
Expand Down

0 comments on commit 125e873

Please sign in to comment.