Auto merge of #99130 - jyn514:std-cache-invalidation, r=Mark-Simulacrum
Fix `x build library/std compiler/rustc` Previously, this was broken because of improper caching: 1. `StepDescription::maybe_run` builds `Compile::Std`, which only built `std` and not `proc_macro` 1. `Std` calls `builder.ensure(StdLink)` 1. `Rustc` calls `ensure(Std)`, which builds all crates, including `proc_macro` 1. `Rustc` calls `ensure(StdLink)`. `ensure` would see that it had already been run and do nothing. <-- bug is here 1. Cargo gives an error that `proc_macro` doesn't exist. This fixes the caching by adding `crates` to `StdLink`, so it will get rerun if the crates that are built change. Fixes https://github.com/rust-lang/rust/issues/99129.
This commit is contained in:
commit
a51fb2ba82
1 changed files with 38 additions and 22 deletions
|
@ -104,7 +104,7 @@ impl Step for Std {
|
||||||
|| builder.config.keep_stage_std.contains(&compiler.stage)
|
|| builder.config.keep_stage_std.contains(&compiler.stage)
|
||||||
{
|
{
|
||||||
builder.info("Warning: Using a potentially old libstd. This may not behave well.");
|
builder.info("Warning: Using a potentially old libstd. This may not behave well.");
|
||||||
builder.ensure(StdLink { compiler, target_compiler: compiler, target });
|
builder.ensure(StdLink::from_std(self, compiler));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +122,7 @@ impl Step for Std {
|
||||||
copy_third_party_objects(builder, &compiler, target);
|
copy_third_party_objects(builder, &compiler, target);
|
||||||
copy_self_contained_objects(builder, &compiler, target);
|
copy_self_contained_objects(builder, &compiler, target);
|
||||||
|
|
||||||
builder.ensure(StdLink {
|
builder.ensure(StdLink::from_std(self, compiler_to_use));
|
||||||
compiler: compiler_to_use,
|
|
||||||
target_compiler: compiler,
|
|
||||||
target,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,11 +145,10 @@ impl Step for Std {
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.ensure(StdLink {
|
builder.ensure(StdLink::from_std(
|
||||||
compiler: builder.compiler(compiler.stage, builder.config.build),
|
self,
|
||||||
target_compiler: compiler,
|
builder.compiler(compiler.stage, builder.config.build),
|
||||||
target,
|
));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +389,19 @@ struct StdLink {
|
||||||
pub compiler: Compiler,
|
pub compiler: Compiler,
|
||||||
pub target_compiler: Compiler,
|
pub target_compiler: Compiler,
|
||||||
pub target: TargetSelection,
|
pub target: TargetSelection,
|
||||||
|
/// Not actually used; only present to make sure the cache invalidation is correct.
|
||||||
|
crates: Interned<Vec<String>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StdLink {
|
||||||
|
fn from_std(std: Std, host_compiler: Compiler) -> Self {
|
||||||
|
Self {
|
||||||
|
compiler: host_compiler,
|
||||||
|
target_compiler: std.compiler,
|
||||||
|
target: std.target,
|
||||||
|
crates: std.crates,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Step for StdLink {
|
impl Step for StdLink {
|
||||||
|
@ -614,7 +622,7 @@ impl Step for Rustc {
|
||||||
if builder.config.keep_stage.contains(&compiler.stage) {
|
if builder.config.keep_stage.contains(&compiler.stage) {
|
||||||
builder.info("Warning: Using a potentially old librustc. This may not behave well.");
|
builder.info("Warning: Using a potentially old librustc. This may not behave well.");
|
||||||
builder.info("Warning: Use `--keep-stage-std` if you want to rebuild the compiler when it changes");
|
builder.info("Warning: Use `--keep-stage-std` if you want to rebuild the compiler when it changes");
|
||||||
builder.ensure(RustcLink { compiler, target_compiler: compiler, target });
|
builder.ensure(RustcLink::from_rustc(self, compiler));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,11 +631,7 @@ impl Step for Rustc {
|
||||||
builder.ensure(Rustc::new(compiler_to_use, target));
|
builder.ensure(Rustc::new(compiler_to_use, target));
|
||||||
builder
|
builder
|
||||||
.info(&format!("Uplifting stage1 rustc ({} -> {})", builder.config.build, target));
|
.info(&format!("Uplifting stage1 rustc ({} -> {})", builder.config.build, target));
|
||||||
builder.ensure(RustcLink {
|
builder.ensure(RustcLink::from_rustc(self, compiler_to_use));
|
||||||
compiler: compiler_to_use,
|
|
||||||
target_compiler: compiler,
|
|
||||||
target,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,11 +692,10 @@ impl Step for Rustc {
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.ensure(RustcLink {
|
builder.ensure(RustcLink::from_rustc(
|
||||||
compiler: builder.compiler(compiler.stage, builder.config.build),
|
self,
|
||||||
target_compiler: compiler,
|
builder.compiler(compiler.stage, builder.config.build),
|
||||||
target,
|
));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,6 +810,19 @@ struct RustcLink {
|
||||||
pub compiler: Compiler,
|
pub compiler: Compiler,
|
||||||
pub target_compiler: Compiler,
|
pub target_compiler: Compiler,
|
||||||
pub target: TargetSelection,
|
pub target: TargetSelection,
|
||||||
|
/// Not actually used; only present to make sure the cache invalidation is correct.
|
||||||
|
crates: Interned<Vec<String>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RustcLink {
|
||||||
|
fn from_rustc(rustc: Rustc, host_compiler: Compiler) -> Self {
|
||||||
|
Self {
|
||||||
|
compiler: host_compiler,
|
||||||
|
target_compiler: rustc.compiler,
|
||||||
|
target: rustc.target,
|
||||||
|
crates: rustc.crates,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Step for RustcLink {
|
impl Step for RustcLink {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue