Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cf66122
Re-add missing `clippy` tests
Kobzol Aug 15, 2025
7cdee39
Forbid running dist steps on stage 0
Kobzol Aug 12, 2025
391bb13
Rename `default_doc` to `run_default_doc_steps` and remove unused arg…
Kobzol Aug 12, 2025
a1f67b6
Document the `rustc-docs` step
Kobzol Aug 12, 2025
1537ad6
Small refactor of `Mingw` step
Kobzol Aug 12, 2025
9bd8317
Refactor and document the `Rustc` dist step
Kobzol Aug 12, 2025
f8b3c56
Refactor and document the `DebuggerScripts` dist step
Kobzol Aug 12, 2025
502dc8d
Refactor `Std` dist step
Kobzol Aug 12, 2025
e7b7d39
Refactor `RustcDev` dist step
Kobzol Aug 12, 2025
172c6f5
Refactor `Analysis` dist step
Kobzol Aug 12, 2025
648d6ce
Remove `compiler_for` from `dist::Cargo`
Kobzol Aug 15, 2025
fc4bf13
Remove `compiler_for` from `dist::RustAnalyzer`
Kobzol Aug 15, 2025
5c03710
Add snapshot test for `x install`
Kobzol Aug 15, 2025
693e2ae
Remove `compiler_for` from `dist::Clippy`
Kobzol Aug 15, 2025
1f7f7f5
Remove `compiler_for` from `dist::Miri`
Kobzol Aug 15, 2025
dfc66f0
Remove `compiler_for` from `dist::CraneliftCodegenBackend`
Kobzol Aug 15, 2025
887831f
Remove `compiler_for` from `dist::Rustfmt`
Kobzol Aug 15, 2025
e68c93b
Remove `compiler_for` from `dist::Extended`
Kobzol Aug 15, 2025
699e5fe
Cleanup `dist::Bootstrap` and add a simple test for it
Kobzol Aug 15, 2025
e8af236
Cleanup the last few dist steps
Kobzol Aug 15, 2025
2074e13
Forbid running install steps on stage 0
Kobzol Aug 15, 2025
3ec2abc
Fix staging in `x install`
Kobzol Aug 15, 2025
0579f05
Add change tracker entry
Kobzol Aug 16, 2025
ba1bc64
Fix doc link
Kobzol Aug 16, 2025
3303770
Don't try to cross-document bootstrap tools
Kobzol Aug 20, 2025
0470945
Remove the `x dist rust-std` built optimization special-case
Kobzol Aug 20, 2025
21c30ea
Fix install test on Windows
Kobzol Aug 22, 2025
a62488b
Handle uplifting in libstd dist step
Kobzol Aug 23, 2025
600d9bf
Use correct mode when printing a build message for std documentation
Kobzol Aug 23, 2025
412734d
Allow running rust-installer (and other tools) multiple times with th…
Kobzol Aug 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,36 @@ impl Std {
}
deps
}

/// Returns true if the standard library will be uplifted from stage 1 for the given
/// `build_compiler` (which determines the stdlib stage) and `target`.
///
/// Uplifting is enabled if we're building a stage2+ libstd, full bootstrap is
/// disabled and we have a stage1 libstd already compiled for the given target.
pub fn should_be_uplifted_from_stage_1(
builder: &Builder<'_>,
stage: u32,
target: TargetSelection,
) -> bool {
stage > 1
&& !builder.config.full_bootstrap
// This estimates if a stage1 libstd exists for the given target. If we're not
// cross-compiling, it should definitely exist by the time we're building a stage2
// libstd.
// Or if we are cross-compiling, and we are building a cross-compiled rustc, then that
// rustc needs to link to a cross-compiled libstd, so again we should have a stage1
// libstd for the given target prepared.
// Even if we guess wrong in the cross-compiled case, the worst that should happen is
// that we build a fresh stage1 libstd below, and then we immediately uplift it, so we
// don't pay the libstd build cost twice.
&& (target == builder.host_target || builder.config.hosts.contains(&target))
}
}

impl Step for Std {
type Output = ();
/// Build stamp of std, if it was indeed built or uplifted.
type Output = Option<BuildStamp>;

const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand Down Expand Up @@ -136,15 +162,15 @@ impl Step for Std {
/// This will build the standard library for a particular stage of the build
/// using the `compiler` targeting the `target` architecture. The artifacts
/// created will also be linked into the sysroot directory.
fn run(self, builder: &Builder<'_>) {
fn run(self, builder: &Builder<'_>) -> Self::Output {
let target = self.target;

// We already have std ready to be used for stage 0.
if self.build_compiler.stage == 0 {
let compiler = self.build_compiler;
builder.ensure(StdLink::from_std(self, compiler));

return;
return None;
}

let build_compiler = if builder.download_rustc() && self.force_recompile {
Expand All @@ -169,7 +195,7 @@ impl Step for Std {
&sysroot,
builder.config.ci_rust_std_contents(),
);
return;
return None;
}

if builder.config.keep_stage.contains(&build_compiler.stage)
Expand All @@ -185,32 +211,17 @@ impl Step for Std {
self.copy_extra_objects(builder, &build_compiler, target);

builder.ensure(StdLink::from_std(self, build_compiler));
return;
return Some(build_stamp::libstd_stamp(builder, build_compiler, target));
}

let mut target_deps = builder.ensure(StartupObjects { compiler: build_compiler, target });

// Stage of the stdlib that we're building
let stage = build_compiler.stage;

// If we're building a stage2+ libstd, full bootstrap is
// disabled and we have a stage1 libstd already compiled for the given target,
// then simply uplift a previously built stage1 library.
if build_compiler.stage > 1
&& !builder.config.full_bootstrap
// This estimates if a stage1 libstd exists for the given target. If we're not
// cross-compiling, it should definitely exist by the time we're building a stage2
// libstd.
// Or if we are cross-compiling, and we are building a cross-compiled rustc, then that
// rustc needs to link to a cross-compiled libstd, so again we should have a stage1
// libstd for the given target prepared.
// Even if we guess wrong in the cross-compiled case, the worst that should happen is
// that we build a fresh stage1 libstd below, and then we immediately uplift it, so we
// don't pay the libstd build cost twice.
&& (target == builder.host_target || builder.config.hosts.contains(&target))
{
if Self::should_be_uplifted_from_stage_1(builder, build_compiler.stage, target) {
let build_compiler_for_std_to_uplift = builder.compiler(1, builder.host_target);
builder.std(build_compiler_for_std_to_uplift, target);
let stage_1_stamp = builder.std(build_compiler_for_std_to_uplift, target);

let msg = if build_compiler_for_std_to_uplift.host == target {
format!(
Expand All @@ -231,7 +242,7 @@ impl Step for Std {
self.copy_extra_objects(builder, &build_compiler, target);

builder.ensure(StdLink::from_std(self, build_compiler_for_std_to_uplift));
return;
return stage_1_stamp;
}

target_deps.extend(self.copy_extra_objects(builder, &build_compiler, target));
Expand Down Expand Up @@ -284,11 +295,13 @@ impl Step for Std {
build_compiler,
target,
);

let stamp = build_stamp::libstd_stamp(builder, build_compiler, target);
run_cargo(
builder,
cargo,
vec![],
&build_stamp::libstd_stamp(builder, build_compiler, target),
&stamp,
target_deps,
self.is_for_mir_opt_tests, // is_check
false,
Expand All @@ -298,6 +311,7 @@ impl Step for Std {
self,
builder.compiler(build_compiler.stage, builder.config.host_target),
));
Some(stamp)
}

fn metadata(&self) -> Option<StepMetadata> {
Expand Down
Loading
Loading