Rollup merge of #120058 - onur-ozkan:compiler-assemble, r=Mark-Simulacrum
bootstrap: improvements for compiler builds Reverted https://github.com/rust-lang/rust/pull/108288 and applied a proper fix with the following commit. r? ```@Mark-Simulacrum```
This commit is contained in:
commit
5f8988b7da
1 changed files with 34 additions and 28 deletions
|
@ -803,7 +803,14 @@ impl Rustc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Step for Rustc {
|
impl Step for Rustc {
|
||||||
type Output = ();
|
// We return the stage of the "actual" compiler (not the uplifted one).
|
||||||
|
//
|
||||||
|
// By "actual" we refer to the uplifting logic where we may not compile the requested stage;
|
||||||
|
// instead, we uplift it from the previous stages. Which can lead to bootstrap failures in
|
||||||
|
// specific situations where we request stage X from other steps. However we may end up
|
||||||
|
// uplifting it from stage Y, causing the other stage to fail when attempting to link with
|
||||||
|
// stage X which was never actually built.
|
||||||
|
type Output = u32;
|
||||||
const ONLY_HOSTS: bool = true;
|
const ONLY_HOSTS: bool = true;
|
||||||
const DEFAULT: bool = false;
|
const DEFAULT: bool = false;
|
||||||
|
|
||||||
|
@ -834,7 +841,7 @@ impl Step for Rustc {
|
||||||
/// This will build the compiler for a particular stage of the build using
|
/// This will build the compiler for a particular stage of the build using
|
||||||
/// the `compiler` targeting the `target` architecture. The artifacts
|
/// the `compiler` targeting the `target` architecture. The artifacts
|
||||||
/// created will also be linked into the sysroot directory.
|
/// created will also be linked into the sysroot directory.
|
||||||
fn run(self, builder: &Builder<'_>) {
|
fn run(self, builder: &Builder<'_>) -> u32 {
|
||||||
let compiler = self.compiler;
|
let compiler = self.compiler;
|
||||||
let target = self.target;
|
let target = self.target;
|
||||||
|
|
||||||
|
@ -848,7 +855,7 @@ impl Step for Rustc {
|
||||||
compiler,
|
compiler,
|
||||||
builder.config.ci_rustc_dev_contents(),
|
builder.config.ci_rustc_dev_contents(),
|
||||||
);
|
);
|
||||||
return;
|
return compiler.stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.ensure(Std::new(compiler, target));
|
builder.ensure(Std::new(compiler, target));
|
||||||
|
@ -857,7 +864,8 @@ impl Step for Rustc {
|
||||||
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::from_rustc(self, compiler));
|
builder.ensure(RustcLink::from_rustc(self, compiler));
|
||||||
return;
|
|
||||||
|
return compiler.stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
|
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
|
||||||
|
@ -880,7 +888,7 @@ impl Step for Rustc {
|
||||||
};
|
};
|
||||||
builder.info(&msg);
|
builder.info(&msg);
|
||||||
builder.ensure(RustcLink::from_rustc(self, compiler_to_use));
|
builder.ensure(RustcLink::from_rustc(self, compiler_to_use));
|
||||||
return;
|
return compiler_to_use.stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that build scripts and proc macros have a std / libproc_macro to link against.
|
// Ensure that build scripts and proc macros have a std / libproc_macro to link against.
|
||||||
|
@ -984,6 +992,8 @@ impl Step for Rustc {
|
||||||
self,
|
self,
|
||||||
builder.compiler(compiler.stage, builder.config.build),
|
builder.compiler(compiler.stage, builder.config.build),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
compiler.stage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,21 +1652,6 @@ impl Step for Assemble {
|
||||||
return target_compiler;
|
return target_compiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the compiler that we'll use to bootstrap ourselves.
|
|
||||||
//
|
|
||||||
// Note that this is where the recursive nature of the bootstrap
|
|
||||||
// happens, as this will request the previous stage's compiler on
|
|
||||||
// downwards to stage 0.
|
|
||||||
//
|
|
||||||
// Also note that we're building a compiler for the host platform. We
|
|
||||||
// only assume that we can run `build` artifacts, which means that to
|
|
||||||
// produce some other architecture compiler we need to start from
|
|
||||||
// `build` to get there.
|
|
||||||
//
|
|
||||||
// FIXME: It may be faster if we build just a stage 1 compiler and then
|
|
||||||
// use that to bootstrap this compiler forward.
|
|
||||||
let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
|
|
||||||
|
|
||||||
// If we're downloading a compiler from CI, we can use the same compiler for all stages other than 0.
|
// If we're downloading a compiler from CI, we can use the same compiler for all stages other than 0.
|
||||||
if builder.download_rustc() {
|
if builder.download_rustc() {
|
||||||
let sysroot =
|
let sysroot =
|
||||||
|
@ -1671,19 +1666,30 @@ impl Step for Assemble {
|
||||||
return target_compiler;
|
return target_compiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the compiler that we'll use to bootstrap ourselves.
|
||||||
|
//
|
||||||
|
// Note that this is where the recursive nature of the bootstrap
|
||||||
|
// happens, as this will request the previous stage's compiler on
|
||||||
|
// downwards to stage 0.
|
||||||
|
//
|
||||||
|
// Also note that we're building a compiler for the host platform. We
|
||||||
|
// only assume that we can run `build` artifacts, which means that to
|
||||||
|
// produce some other architecture compiler we need to start from
|
||||||
|
// `build` to get there.
|
||||||
|
//
|
||||||
|
// FIXME: It may be faster if we build just a stage 1 compiler and then
|
||||||
|
// use that to bootstrap this compiler forward.
|
||||||
|
let mut build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
|
||||||
|
|
||||||
// Build the libraries for this compiler to link to (i.e., the libraries
|
// Build the libraries for this compiler to link to (i.e., the libraries
|
||||||
// it uses at runtime). NOTE: Crates the target compiler compiles don't
|
// it uses at runtime). NOTE: Crates the target compiler compiles don't
|
||||||
// link to these. (FIXME: Is that correct? It seems to be correct most
|
// link to these. (FIXME: Is that correct? It seems to be correct most
|
||||||
// of the time but I think we do link to these for stage2/bin compilers
|
// of the time but I think we do link to these for stage2/bin compilers
|
||||||
// when not performing a full bootstrap).
|
// when not performing a full bootstrap).
|
||||||
builder.ensure(Rustc::new(build_compiler, target_compiler.host));
|
let actual_stage = builder.ensure(Rustc::new(build_compiler, target_compiler.host));
|
||||||
|
// Current build_compiler.stage might be uplifted instead of being built; so update it
|
||||||
// FIXME: For now patch over problems noted in #90244 by early returning here, even though
|
// to not fail while linking the artifacts.
|
||||||
// we've not properly assembled the target sysroot. A full fix is pending further investigation,
|
build_compiler.stage = actual_stage;
|
||||||
// for now full bootstrap usage is rare enough that this is OK.
|
|
||||||
if target_compiler.stage >= 3 && !builder.config.full_bootstrap {
|
|
||||||
return target_compiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
for &backend in builder.config.rust_codegen_backends.iter() {
|
for &backend in builder.config.rust_codegen_backends.iter() {
|
||||||
if backend == "llvm" {
|
if backend == "llvm" {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue