Skip to content

Commit fecb681

Browse files
committed
improve staging api
Signed-off-by: onur-ozkan <[email protected]>
1 parent 4857f03 commit fecb681

File tree

14 files changed

+340
-221
lines changed

14 files changed

+340
-221
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Step for Std {
5757
builder.require_submodule("library/stdarch", None);
5858

5959
let target = self.target;
60-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
60+
let compiler = builder.compiler(builder.top_stage, builder.config.build, false);
6161

6262
let mut cargo = builder::Cargo::new(
6363
builder,
@@ -192,7 +192,7 @@ impl Step for Rustc {
192192
/// the `compiler` targeting the `target` architecture. The artifacts
193193
/// created will also be linked into the sysroot directory.
194194
fn run(self, builder: &Builder<'_>) {
195-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
195+
let compiler = builder.compiler(builder.top_stage, builder.config.build, false);
196196
let target = self.target;
197197

198198
if compiler.stage != 0 {
@@ -274,7 +274,7 @@ impl Step for CodegenBackend {
274274
return;
275275
}
276276

277-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
277+
let compiler = builder.compiler(builder.top_stage, builder.config.build, false);
278278
let target = self.target;
279279
let backend = self.backend;
280280

@@ -329,7 +329,7 @@ impl Step for RustAnalyzer {
329329
}
330330

331331
fn run(self, builder: &Builder<'_>) {
332-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
332+
let compiler = builder.compiler(builder.top_stage, builder.config.build, true);
333333
let target = self.target;
334334

335335
builder.ensure(Rustc::new(target, builder));
@@ -411,7 +411,7 @@ fn run_tool_check_step(
411411
path: &str,
412412
) {
413413
let display_name = path.rsplit('/').next().unwrap();
414-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
414+
let compiler = builder.compiler(builder.top_stage, builder.config.build, true);
415415

416416
builder.ensure(Rustc::new(target, builder));
417417

src/bootstrap/src/core/build_steps/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ macro_rules! clean_crate_tree {
6060

6161
fn make_run(run: RunConfig<'_>) {
6262
let builder = run.builder;
63-
let compiler = builder.compiler(builder.top_stage, run.target);
63+
let compiler = builder.compiler(builder.top_stage, run.target, false);
6464
builder.ensure(Self { crates: run.cargo_crates_in_set(), compiler });
6565
}
6666

src/bootstrap/src/core/build_steps/clippy.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl Step for Std {
144144
builder.require_submodule("library/stdarch", None);
145145

146146
let target = self.target;
147-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
147+
let compiler = builder.compiler(builder.top_stage, builder.config.build, false);
148148

149149
let mut cargo = builder::Cargo::new(
150150
builder,
@@ -204,7 +204,7 @@ impl Step for Rustc {
204204
/// This will lint the compiler for a particular stage of the build using
205205
/// the `compiler` targeting the `target` architecture.
206206
fn run(self, builder: &Builder<'_>) {
207-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
207+
let compiler = builder.compiler(builder.top_stage, builder.config.build, false);
208208
let target = self.target;
209209

210210
if compiler.stage != 0 {
@@ -254,7 +254,7 @@ impl Step for Rustc {
254254

255255
macro_rules! lint_any {
256256
($(
257-
$name:ident, $path:expr, $readable_name:expr
257+
$name:ident, $path:expr, $readable_name:expr, $mode:expr
258258
$(,lint_by_default = $lint_by_default:expr)*
259259
;
260260
)+) => {
@@ -283,15 +283,15 @@ macro_rules! lint_any {
283283
}
284284

285285
fn run(self, builder: &Builder<'_>) -> Self::Output {
286-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
286+
let compiler = builder.compiler(builder.top_stage, builder.config.build, $mode == Mode::ToolRustc);
287287
let target = self.target;
288288

289289
builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check)));
290290

291291
let cargo = prepare_tool_cargo(
292292
builder,
293293
compiler,
294-
Mode::ToolRustc,
294+
$mode,
295295
target,
296296
Kind::Clippy,
297297
$path,
@@ -301,15 +301,15 @@ macro_rules! lint_any {
301301

302302
let _guard = builder.msg_tool(
303303
Kind::Clippy,
304-
Mode::ToolRustc,
304+
$mode,
305305
$readable_name,
306306
compiler.stage,
307307
&compiler.host,
308308
&target,
309309
);
310310

311311
let stringified_name = stringify!($name).to_lowercase();
312-
let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
312+
let stamp = BuildStamp::new(&builder.cargo_out(compiler, $mode, target))
313313
.with_prefix(&format!("{}-check", stringified_name));
314314

315315
run_cargo(
@@ -328,31 +328,31 @@ macro_rules! lint_any {
328328
}
329329

330330
lint_any!(
331-
Bootstrap, "src/bootstrap", "bootstrap";
332-
BuildHelper, "src/build_helper", "build_helper";
333-
BuildManifest, "src/tools/build-manifest", "build-manifest";
334-
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri";
335-
Clippy, "src/tools/clippy", "clippy";
336-
CollectLicenseMetadata, "src/tools/collect-license-metadata", "collect-license-metadata";
337-
CodegenGcc, "compiler/rustc_codegen_gcc", "rustc-codegen-gcc";
338-
Compiletest, "src/tools/compiletest", "compiletest";
339-
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
340-
Jsondocck, "src/tools/jsondocck", "jsondocck";
341-
Jsondoclint, "src/tools/jsondoclint", "jsondoclint";
342-
LintDocs, "src/tools/lint-docs", "lint-docs";
343-
LlvmBitcodeLinker, "src/tools/llvm-bitcode-linker", "llvm-bitcode-linker";
344-
Miri, "src/tools/miri", "miri";
345-
MiroptTestTools, "src/tools/miropt-test-tools", "miropt-test-tools";
346-
OptDist, "src/tools/opt-dist", "opt-dist";
347-
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
348-
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
349-
Rls, "src/tools/rls", "rls";
350-
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
351-
Rustdoc, "src/librustdoc", "clippy";
352-
Rustfmt, "src/tools/rustfmt", "rustfmt";
353-
RustInstaller, "src/tools/rust-installer", "rust-installer";
354-
Tidy, "src/tools/tidy", "tidy";
355-
TestFloatParse, "src/etc/test-float-parse", "test-float-parse";
331+
Bootstrap, "src/bootstrap", "bootstrap", Mode::ToolBootstrap;
332+
BuildHelper, "src/build_helper", "build_helper", Mode::ToolBootstrap;
333+
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
334+
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", Mode::ToolRustc;
335+
Clippy, "src/tools/clippy", "clippy", Mode::ToolRustc;
336+
CollectLicenseMetadata, "src/tools/collect-license-metadata", "collect-license-metadata", Mode::ToolBootstrap;
337+
CodegenGcc, "compiler/rustc_codegen_gcc", "rustc-codegen-gcc", Mode::ToolRustc;
338+
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap;
339+
CoverageDump, "src/tools/coverage-dump", "coverage-dump", Mode::ToolBootstrap;
340+
Jsondocck, "src/tools/jsondocck", "jsondocck", Mode::ToolBootstrap;
341+
Jsondoclint, "src/tools/jsondoclint", "jsondoclint", Mode::ToolBootstrap;
342+
LintDocs, "src/tools/lint-docs", "lint-docs", Mode::ToolBootstrap;
343+
LlvmBitcodeLinker, "src/tools/llvm-bitcode-linker", "llvm-bitcode-linker", Mode::ToolRustc;
344+
Miri, "src/tools/miri", "miri", Mode::ToolRustc;
345+
MiroptTestTools, "src/tools/miropt-test-tools", "miropt-test-tools", Mode::ToolRustc;
346+
OptDist, "src/tools/opt-dist", "opt-dist", Mode::ToolBootstrap;
347+
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
348+
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server", Mode::ToolBootstrap;
349+
Rls, "src/tools/rls", "rls", Mode::ToolBootstrap;
350+
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer", Mode::ToolRustc;
351+
Rustdoc, "src/librustdoc", "clippy", Mode::ToolRustc;
352+
Rustfmt, "src/tools/rustfmt", "rustfmt", Mode::ToolRustc;
353+
RustInstaller, "src/tools/rust-installer", "rust-installer", Mode::ToolBootstrap;
354+
Tidy, "src/tools/tidy", "tidy", Mode::ToolBootstrap;
355+
TestFloatParse, "src/etc/test-float-parse", "test-float-parse", Mode::ToolStd;
356356
);
357357

358358
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Step for Std {
121121
trace!(force_recompile);
122122

123123
run.builder.ensure(Std {
124-
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
124+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple(), false),
125125
target: run.target,
126126
crates,
127127
force_recompile,
@@ -189,7 +189,7 @@ impl Step for Std {
189189

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

192-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
192+
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target, false);
193193
trace!(?compiler_to_use);
194194

195195
if compiler_to_use != compiler {
@@ -310,7 +310,7 @@ impl Step for Std {
310310

311311
builder.ensure(StdLink::from_std(
312312
self,
313-
builder.compiler(compiler.stage, builder.config.build),
313+
builder.compiler(compiler.stage, builder.config.build, false),
314314
));
315315
}
316316
}
@@ -870,7 +870,7 @@ impl Step for StartupObjects {
870870

871871
fn make_run(run: RunConfig<'_>) {
872872
run.builder.ensure(StartupObjects {
873-
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
873+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple(), false),
874874
target: run.target,
875875
});
876876
}
@@ -1003,7 +1003,7 @@ impl Step for Rustc {
10031003
fn make_run(run: RunConfig<'_>) {
10041004
let crates = run.cargo_crates_in_set();
10051005
run.builder.ensure(Rustc {
1006-
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
1006+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple(), false),
10071007
target: run.target,
10081008
crates,
10091009
});
@@ -1053,9 +1053,9 @@ impl Step for Rustc {
10531053
return compiler.stage;
10541054
}
10551055

1056-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
1056+
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target, false);
10571057
if compiler_to_use != compiler {
1058-
let _ = builder.compiler(compiler_to_use.stage, target);
1058+
let _ = builder.compiler(compiler_to_use.stage, target, false);
10591059

10601060
let msg = if compiler_to_use.host == target {
10611061
format!(
@@ -1079,7 +1079,7 @@ impl Step for Rustc {
10791079

10801080
// Ensure that build scripts and proc macros have a std / libproc_macro to link against.
10811081
builder.ensure(Std::new(
1082-
builder.compiler(self.compiler.stage, builder.config.build),
1082+
builder.compiler(self.compiler.stage, builder.config.build, false),
10831083
builder.config.build,
10841084
));
10851085

@@ -1145,7 +1145,7 @@ impl Step for Rustc {
11451145

11461146
builder.ensure(RustcLink::from_rustc(
11471147
self,
1148-
builder.compiler(compiler.stage, builder.config.build),
1148+
builder.compiler(compiler.stage, builder.config.build, false),
11491149
));
11501150

11511151
compiler.stage
@@ -1561,7 +1561,7 @@ impl Step for CodegenBackend {
15611561

15621562
run.builder.ensure(CodegenBackend {
15631563
target: run.target,
1564-
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
1564+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple(), false),
15651565
backend: backend.clone(),
15661566
});
15671567
}
@@ -1585,7 +1585,7 @@ impl Step for CodegenBackend {
15851585
let target = self.target;
15861586
let backend = self.backend;
15871587

1588-
let _ = builder.compiler(compiler.stage, target);
1588+
let _ = builder.compiler(compiler.stage, target, false);
15891589

15901590
if builder.config.keep_stage.contains(&compiler.stage) {
15911591
trace!("`keep-stage` requested");
@@ -1598,7 +1598,7 @@ impl Step for CodegenBackend {
15981598
return;
15991599
}
16001600

1601-
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
1601+
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target, false);
16021602
if compiler_to_use != compiler {
16031603
builder.ensure(CodegenBackend { compiler: compiler_to_use, target, backend });
16041604
return;
@@ -1907,7 +1907,7 @@ impl Step for Assemble {
19071907

19081908
fn make_run(run: RunConfig<'_>) {
19091909
run.builder.ensure(Assemble {
1910-
target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target),
1910+
target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target, false),
19111911
});
19121912
}
19131913

@@ -2036,7 +2036,8 @@ impl Step for Assemble {
20362036
target_compiler.stage - 1,
20372037
builder.config.build,
20382038
);
2039-
let mut build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
2039+
let mut build_compiler =
2040+
builder.compiler(target_compiler.stage - 1, builder.config.build, false);
20402041

20412042
// Build enzyme
20422043
if builder.config.llvm_enzyme {
@@ -2197,7 +2198,11 @@ impl Step for Assemble {
21972198
);
21982199
}
21992200

2200-
maybe_install_llvm_bitcode_linker(target_compiler);
2201+
{
2202+
let mut compiler_for_rustc_tool = build_compiler;
2203+
compiler_for_rustc_tool.downgraded_from = Some(target_compiler.stage);
2204+
maybe_install_llvm_bitcode_linker(compiler_for_rustc_tool);
2205+
}
22012206

22022207
// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
22032208
// so that it can be found when the newly built `rustc` is run.

0 commit comments

Comments
 (0)