Skip to content

Commit

Permalink
fix: generate std roots based on all collected targets
Browse files Browse the repository at this point in the history
fixes rust-lang#10444 by using the same `CompileKind`s that artifact dependencies produces
  • Loading branch information
JonasKruckenberg committed Sep 1, 2024
1 parent c1fa840 commit f339df2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ impl<'gctx> RustcTargetData<'gctx> {
let mut res = RustcTargetData {
rustc,
gctx,
requested_kinds: requested_kinds.into(),
requested_kinds: Vec::new(),
host_config,
host_info,
target_config,
Expand Down Expand Up @@ -948,6 +948,7 @@ impl<'gctx> RustcTargetData<'gctx> {
}));
for kind in all_kinds {
res.merge_compile_kind(kind)?;
res.requested_kinds.push(kind);
}

Ok(res)
Expand Down Expand Up @@ -1023,6 +1024,10 @@ impl<'gctx> RustcTargetData<'gctx> {
CompileKind::Target(s) => &self.target_config[&s],
}
}

pub fn requested_kinds(&self) -> &[CompileKind] {
&self.requested_kinds
}
}

/// Structure used to deal with Rustdoc fingerprinting
Expand Down
3 changes: 1 addition & 2 deletions src/cargo/core/compiler/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub fn generate_std_roots(
crates: &[String],
std_resolve: &Resolve,
std_features: &ResolvedFeatures,
kinds: &[CompileKind],
package_set: &PackageSet<'_>,
interner: &UnitInterner,
profiles: &Profiles,
Expand All @@ -150,7 +149,7 @@ pub fn generate_std_roots(
// significant.
let mode = CompileMode::Build;
let features = std_features.activated_features(pkg.package_id(), FeaturesFor::NormalOrDev);
for kind in kinds {
for kind in target_data.requested_kinds() {
let list = ret.entry(*kind).or_insert_with(Vec::new);
let unit_for = UnitFor::new_normal(*kind);
let profile = profiles.get_profile(
Expand Down
9 changes: 0 additions & 9 deletions src/cargo/ops/cargo_compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,6 @@ pub fn create_bcx<'a, 'gctx>(
// assuming `--target $HOST` was specified. See
// `rebuild_unit_graph_shared` for more on why this is done.
let explicit_host_kind = CompileKind::Target(CompileTarget::new(&target_data.rustc.host)?);
let explicit_host_kinds: Vec<_> = build_config
.requested_kinds
.iter()
.map(|kind| match kind {
CompileKind::Host => explicit_host_kind,
CompileKind::Target(t) => CompileKind::Target(*t),
})
.collect();

// Passing `build_config.requested_kinds` instead of
// `explicit_host_kinds` here so that `generate_root_units` can do
Expand Down Expand Up @@ -396,7 +388,6 @@ pub fn create_bcx<'a, 'gctx>(
&crates,
std_resolve,
std_features,
&explicit_host_kinds,
&pkg_set,
interner,
&profiles,
Expand Down

0 comments on commit f339df2

Please sign in to comment.