Skip to content

Commit 72167b7

Browse files
committed
Rename compiler to test_compiler
1 parent 2bfff32 commit 72167b7

File tree

1 file changed

+54
-47
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+54
-47
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ impl Step for RustdocJSNotStd {
10791079

10801080
fn run(self, builder: &Builder<'_>) {
10811081
builder.ensure(Compiletest {
1082-
compiler: self.compiler,
1082+
test_compiler: self.compiler,
10831083
target: self.target,
10841084
mode: "rustdoc-js",
10851085
suite: "rustdoc-js",
@@ -1437,8 +1437,8 @@ macro_rules! test {
14371437
$( #[$attr] )*
14381438
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
14391439
pub struct $name {
1440-
pub compiler: Compiler,
1441-
pub target: TargetSelection,
1440+
test_compiler: Compiler,
1441+
target: TargetSelection,
14421442
}
14431443

14441444
impl Step for $name {
@@ -1456,14 +1456,14 @@ macro_rules! test {
14561456
}
14571457

14581458
fn make_run(run: RunConfig<'_>) {
1459-
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1459+
let test_compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
14601460

1461-
run.builder.ensure($name { compiler, target: run.target });
1461+
run.builder.ensure($name { test_compiler, target: run.target });
14621462
}
14631463

14641464
fn run(self, builder: &Builder<'_>) {
14651465
builder.ensure(Compiletest {
1466-
compiler: self.compiler,
1466+
test_compiler: self.test_compiler,
14671467
target: self.target,
14681468
mode: $mode,
14691469
suite: $suite,
@@ -1644,7 +1644,7 @@ impl Step for Coverage {
16441644
// Like other compiletest suite test steps, delegate to an internal
16451645
// compiletest task to actually run the tests.
16461646
builder.ensure(Compiletest {
1647-
compiler,
1647+
test_compiler: compiler,
16481648
target,
16491649
mode,
16501650
suite: Self::SUITE,
@@ -1685,7 +1685,7 @@ impl Step for MirOpt {
16851685
fn run(self, builder: &Builder<'_>) {
16861686
let run = |target| {
16871687
builder.ensure(Compiletest {
1688-
compiler: self.compiler,
1688+
test_compiler: self.compiler,
16891689
target,
16901690
mode: "mir-opt",
16911691
suite: "mir-opt",
@@ -1720,9 +1720,15 @@ impl Step for MirOpt {
17201720
}
17211721
}
17221722

1723+
/// Executes the `compiletest` tool to run a suite of tests.
1724+
///
1725+
/// Compiles all tests with `test_compiler` for `target` with the specified
1726+
/// compiletest `mode` and `suite` arguments. For example `mode` can be
1727+
/// "run-pass" or `suite` can be something like `debuginfo`.
17231728
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
17241729
struct Compiletest {
1725-
compiler: Compiler,
1730+
/// The compiler that we're testing.
1731+
test_compiler: Compiler,
17261732
target: TargetSelection,
17271733
mode: &'static str,
17281734
suite: &'static str,
@@ -1737,11 +1743,6 @@ impl Step for Compiletest {
17371743
run.never()
17381744
}
17391745

1740-
/// Executes the `compiletest` tool to run a suite of tests.
1741-
///
1742-
/// Compiles all tests with `compiler` for `target` with the specified
1743-
/// compiletest `mode` and `suite` arguments. For example `mode` can be
1744-
/// "run-pass" or `suite` can be something like `debuginfo`.
17451746
fn run(self, builder: &Builder<'_>) {
17461747
if builder.doc_tests == DocTests::Only {
17471748
return;
@@ -1756,7 +1757,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17561757
crate::exit!(1);
17571758
}
17581759

1759-
let mut compiler = self.compiler;
1760+
let mut test_compiler = self.test_compiler;
17601761
let target = self.target;
17611762
let mode = self.mode;
17621763
let suite = self.suite;
@@ -1776,30 +1777,30 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17761777
// NOTE: Only stage 1 is special cased because we need the rustc_private artifacts to match the
17771778
// running compiler in stage 2 when plugins run.
17781779
let query_compiler;
1779-
let (stage, stage_id) = if suite == "ui-fulldeps" && compiler.stage == 1 {
1780+
let (stage, stage_id) = if suite == "ui-fulldeps" && test_compiler.stage == 1 {
17801781
// Even when using the stage 0 compiler, we also need to provide the stage 1 compiler
17811782
// so that compiletest can query it for target information.
1782-
query_compiler = Some(compiler);
1783+
query_compiler = Some(test_compiler);
17831784
// At stage 0 (stage - 1) we are using the stage0 compiler. Using `self.target` can lead
17841785
// finding an incorrect compiler path on cross-targets, as the stage 0 is always equal to
17851786
// `build.build` in the configuration.
17861787
let build = builder.build.host_target;
1787-
compiler = builder.compiler(compiler.stage - 1, build);
1788-
let test_stage = compiler.stage + 1;
1788+
test_compiler = builder.compiler(test_compiler.stage - 1, build);
1789+
let test_stage = test_compiler.stage + 1;
17891790
(test_stage, format!("stage{test_stage}-{build}"))
17901791
} else {
17911792
query_compiler = None;
1792-
let stage = compiler.stage;
1793+
let stage = test_compiler.stage;
17931794
(stage, format!("stage{stage}-{target}"))
17941795
};
17951796

17961797
if suite.ends_with("fulldeps") {
1797-
builder.ensure(compile::Rustc::new(compiler, target));
1798+
builder.ensure(compile::Rustc::new(test_compiler, target));
17981799
}
17991800

18001801
if suite == "debuginfo" {
18011802
builder.ensure(dist::DebuggerScripts {
1802-
sysroot: builder.sysroot(compiler).to_path_buf(),
1803+
sysroot: builder.sysroot(test_compiler).to_path_buf(),
18031804
target,
18041805
});
18051806
}
@@ -1809,30 +1810,32 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18091810

18101811
// ensure that `libproc_macro` is available on the host.
18111812
if suite == "mir-opt" {
1812-
builder.ensure(compile::Std::new(compiler, compiler.host).is_for_mir_opt_tests(true));
1813+
builder.ensure(
1814+
compile::Std::new(test_compiler, test_compiler.host).is_for_mir_opt_tests(true),
1815+
);
18131816
} else {
1814-
builder.std(compiler, compiler.host);
1817+
builder.std(test_compiler, test_compiler.host);
18151818
}
18161819

18171820
let mut cmd = builder.tool_cmd(Tool::Compiletest);
18181821

18191822
if suite == "mir-opt" {
1820-
builder.ensure(compile::Std::new(compiler, target).is_for_mir_opt_tests(true));
1823+
builder.ensure(compile::Std::new(test_compiler, target).is_for_mir_opt_tests(true));
18211824
} else {
1822-
builder.std(compiler, target);
1825+
builder.std(test_compiler, target);
18231826
}
18241827

1825-
builder.ensure(RemoteCopyLibs { build_compiler: compiler, target });
1828+
builder.ensure(RemoteCopyLibs { build_compiler: test_compiler, target });
18261829

18271830
// compiletest currently has... a lot of arguments, so let's just pass all
18281831
// of them!
18291832

18301833
cmd.arg("--stage").arg(stage.to_string());
18311834
cmd.arg("--stage-id").arg(stage_id);
18321835

1833-
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1834-
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(compiler, target));
1835-
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
1836+
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(test_compiler));
1837+
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(test_compiler, target));
1838+
cmd.arg("--rustc-path").arg(builder.rustc(test_compiler));
18361839
if let Some(query_compiler) = query_compiler {
18371840
cmd.arg("--query-rustc-path").arg(builder.rustc(query_compiler));
18381841
}
@@ -1849,14 +1852,16 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18491852
// If we're using `--stage 0`, we should provide the bootstrap cargo.
18501853
builder.initial_cargo.clone()
18511854
} else {
1852-
builder.ensure(tool::Cargo::from_build_compiler(compiler, compiler.host)).tool_path
1855+
builder
1856+
.ensure(tool::Cargo::from_build_compiler(test_compiler, test_compiler.host))
1857+
.tool_path
18531858
};
18541859

18551860
cmd.arg("--cargo-path").arg(cargo_path);
18561861

18571862
// We need to pass the compiler that was used to compile run-make-support,
18581863
// because we have to use the same compiler to compile rmake.rs recipes.
1859-
let stage0_rustc_path = builder.compiler(0, compiler.host);
1864+
let stage0_rustc_path = builder.compiler(0, test_compiler.host);
18601865
cmd.arg("--stage0-rustc-path").arg(builder.rustc(stage0_rustc_path));
18611866
}
18621867

@@ -1868,7 +1873,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18681873
|| mode == "rustdoc-json"
18691874
|| suite == "coverage-run-rustdoc"
18701875
{
1871-
cmd.arg("--rustdoc-path").arg(builder.rustdoc_for_compiler(compiler));
1876+
cmd.arg("--rustdoc-path").arg(builder.rustdoc_for_compiler(test_compiler));
18721877
}
18731878

18741879
if mode == "rustdoc-json" {
@@ -1893,26 +1898,26 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18931898
// directory immediately under the root build directory, and the test-suite-specific build
18941899
// directory.
18951900
cmd.arg("--build-root").arg(&builder.out);
1896-
cmd.arg("--build-test-suite-root").arg(testdir(builder, compiler.host).join(suite));
1901+
cmd.arg("--build-test-suite-root").arg(testdir(builder, test_compiler.host).join(suite));
18971902

18981903
// When top stage is 0, that means that we're testing an externally provided compiler.
18991904
// In that case we need to use its specific sysroot for tests to pass.
19001905
let sysroot = if builder.top_stage == 0 {
19011906
builder.initial_sysroot.clone()
19021907
} else {
1903-
builder.sysroot(compiler)
1908+
builder.sysroot(test_compiler)
19041909
};
19051910

19061911
cmd.arg("--sysroot-base").arg(sysroot);
19071912

19081913
cmd.arg("--suite").arg(suite);
19091914
cmd.arg("--mode").arg(mode);
19101915
cmd.arg("--target").arg(target.rustc_target_arg());
1911-
cmd.arg("--host").arg(&*compiler.host.triple);
1916+
cmd.arg("--host").arg(&*test_compiler.host.triple);
19121917
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.host_target));
19131918

19141919
if let Some(codegen_backend) = builder.config.cmd.test_codegen_backend() {
1915-
if !builder.config.enabled_codegen_backends(compiler.host).contains(codegen_backend) {
1920+
if !builder.config.enabled_codegen_backends(test_compiler.host).contains(codegen_backend) {
19161921
eprintln!(
19171922
"\
19181923
ERROR: No configured backend named `{name}`
@@ -1931,7 +1936,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
19311936
// Tells compiletest which codegen backend to use.
19321937
// It is used to e.g. ignore tests that don't support that codegen backend.
19331938
cmd.arg("--default-codegen-backend")
1934-
.arg(builder.config.default_codegen_backend(compiler.host).name());
1939+
.arg(builder.config.default_codegen_backend(test_compiler.host).name());
19351940
}
19361941

19371942
if builder.build.config.llvm_enzyme {
@@ -2011,7 +2016,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
20112016
if let Some(linker) = builder.linker(target) {
20122017
cmd.arg("--target-linker").arg(linker);
20132018
}
2014-
if let Some(linker) = builder.linker(compiler.host) {
2019+
if let Some(linker) = builder.linker(test_compiler.host) {
20152020
cmd.arg("--host-linker").arg(linker);
20162021
}
20172022
}
@@ -2022,16 +2027,18 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
20222027
}
20232028

20242029
let mut hostflags = flags.clone();
2025-
hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
2030+
hostflags.extend(linker_flags(builder, test_compiler.host, LldThreads::No));
20262031

20272032
let mut targetflags = flags;
20282033

20292034
// Provide `rust_test_helpers` for both host and target.
20302035
if suite == "ui" || suite == "incremental" {
2031-
builder.ensure(TestHelpers { target: compiler.host });
2036+
builder.ensure(TestHelpers { target: test_compiler.host });
20322037
builder.ensure(TestHelpers { target });
2033-
hostflags
2034-
.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
2038+
hostflags.push(format!(
2039+
"-Lnative={}",
2040+
builder.test_helpers_out(test_compiler.host).display()
2041+
));
20352042
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
20362043
}
20372044

@@ -2116,7 +2123,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
21162123

21172124
let mut llvm_components_passed = false;
21182125
let mut copts_passed = false;
2119-
if builder.config.llvm_enabled(compiler.host) {
2126+
if builder.config.llvm_enabled(test_compiler.host) {
21202127
let llvm::LlvmResult { host_llvm_config, .. } =
21212128
builder.ensure(llvm::Llvm { target: builder.config.host_target });
21222129
if !builder.config.dry_run() {
@@ -2327,7 +2334,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
23272334
format!("compiletest suite={suite} mode={mode}"),
23282335
// FIXME: compiletest sometimes behaves as ToolStd, we could expose that difference here
23292336
Mode::ToolBootstrap,
2330-
compiler,
2337+
test_compiler,
23312338
target,
23322339
);
23332340
try_run_tests(builder, &mut cmd, false);
@@ -2350,7 +2357,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
23502357

23512358
builder.info(&format!(
23522359
"Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
2353-
suite, mode, compare_mode, &compiler.host, target
2360+
suite, mode, compare_mode, &test_compiler.host, target
23542361
));
23552362
let _time = helpers::timeit(builder);
23562363
try_run_tests(builder, &mut cmd, false);
@@ -2360,7 +2367,7 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
23602367
fn metadata(&self) -> Option<StepMetadata> {
23612368
Some(
23622369
StepMetadata::test(&format!("compiletest-{}", self.suite), self.target)
2363-
.stage(self.compiler.stage),
2370+
.stage(self.test_compiler.stage),
23642371
)
23652372
}
23662373
}

0 commit comments

Comments
 (0)