Skip to content

Commit 3193d52

Browse files
Remove host parameter from step configurations
rustc is a natively cross-compiling compiler, and generally none of our steps should care whether they are using a compiler built of triple A or B, just the --target directive being passed to the running compiler. e.g., when building for some target C, you don't generally want to build two stds: one with a host A compiler and the other with a host B compiler. Just one std is sufficient.
1 parent 25b2f48 commit 3193d52

File tree

6 files changed

+36
-48
lines changed

6 files changed

+36
-48
lines changed

src/bootstrap/builder.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,16 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
8787

8888
pub struct RunConfig<'a> {
8989
pub builder: &'a Builder<'a>,
90-
pub host: TargetSelection,
9190
pub target: TargetSelection,
9291
pub path: PathBuf,
9392
}
9493

94+
impl RunConfig<'_> {
95+
pub fn build_triple(&self) -> TargetSelection {
96+
self.builder.build.build
97+
}
98+
}
99+
95100
struct StepDescription {
96101
default: bool,
97102
only_hosts: bool,
@@ -165,7 +170,6 @@ impl StepDescription {
165170
pathset, self.name, builder.config.exclude
166171
);
167172
}
168-
let hosts = &builder.hosts;
169173

170174
// Determine the targets participating in this rule.
171175
let targets = if self.only_hosts {
@@ -178,16 +182,9 @@ impl StepDescription {
178182
&builder.targets
179183
};
180184

181-
for host in hosts {
182-
for target in targets {
183-
let run = RunConfig {
184-
builder,
185-
path: pathset.path(builder),
186-
host: *host,
187-
target: *target,
188-
};
189-
(self.make_run)(run);
190-
}
185+
for target in targets {
186+
let run = RunConfig { builder, path: pathset.path(builder), target: *target };
187+
(self.make_run)(run);
191188
}
192189
}
193190

src/bootstrap/builder/tests.rs

-10
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,9 @@ mod dist {
384384
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
385385
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
386386
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
387-
compile::Std { compiler: Compiler { host: b, stage: 2 }, target: a },
388387
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
389388
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
390-
compile::Std { compiler: Compiler { host: b, stage: 2 }, target: b },
391389
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
392-
compile::Std { compiler: Compiler { host: b, stage: 2 }, target: c },
393390
]
394391
);
395392
assert!(!builder.cache.all::<compile::Assemble>().is_empty());
@@ -399,10 +396,8 @@ mod dist {
399396
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
400397
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },
401398
compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: a },
402-
compile::Rustc { compiler: Compiler { host: b, stage: 2 }, target: a },
403399
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },
404400
compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: b },
405-
compile::Rustc { compiler: Compiler { host: b, stage: 2 }, target: b },
406401
]
407402
);
408403
}
@@ -425,12 +420,9 @@ mod dist {
425420
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
426421
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
427422
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
428-
compile::Std { compiler: Compiler { host: b, stage: 2 }, target: a },
429423
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
430424
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
431-
compile::Std { compiler: Compiler { host: b, stage: 2 }, target: b },
432425
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
433-
compile::Std { compiler: Compiler { host: b, stage: 2 }, target: c },
434426
]
435427
);
436428
assert_eq!(
@@ -439,15 +431,13 @@ mod dist {
439431
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
440432
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
441433
compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } },
442-
compile::Assemble { target_compiler: Compiler { host: b, stage: 2 } },
443434
]
444435
);
445436
assert_eq!(
446437
first(builder.cache.all::<compile::Rustc>()),
447438
&[
448439
compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
449440
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },
450-
compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },
451441
]
452442
);
453443
}

src/bootstrap/compile.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Step for Std {
4545

4646
fn make_run(run: RunConfig<'_>) {
4747
run.builder.ensure(Std {
48-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
48+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
4949
target: run.target,
5050
});
5151
}
@@ -385,7 +385,7 @@ impl Step for StartupObjects {
385385

386386
fn make_run(run: RunConfig<'_>) {
387387
run.builder.ensure(StartupObjects {
388-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
388+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
389389
target: run.target,
390390
});
391391
}
@@ -454,7 +454,7 @@ impl Step for Rustc {
454454

455455
fn make_run(run: RunConfig<'_>) {
456456
run.builder.ensure(Rustc {
457-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
457+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
458458
target: run.target,
459459
});
460460
}

src/bootstrap/dist.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,9 @@ impl Step for DebuggerScripts {
605605

606606
fn make_run(run: RunConfig<'_>) {
607607
run.builder.ensure(DebuggerScripts {
608-
sysroot: run.builder.sysroot(run.builder.compiler(run.builder.top_stage, run.host)),
608+
sysroot: run
609+
.builder
610+
.sysroot(run.builder.compiler(run.builder.top_stage, run.build_triple())),
609611
host: run.target,
610612
});
611613
}

src/bootstrap/test.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl Step for RustdocTheme {
584584
}
585585

586586
fn make_run(run: RunConfig<'_>) {
587-
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
587+
let compiler = run.builder.compiler(run.builder.top_stage, run.target);
588588

589589
run.builder.ensure(RustdocTheme { compiler });
590590
}
@@ -651,7 +651,6 @@ impl Step for RustdocJSStd {
651651

652652
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
653653
pub struct RustdocJSNotStd {
654-
pub host: TargetSelection,
655654
pub target: TargetSelection,
656655
pub compiler: Compiler,
657656
}
@@ -666,8 +665,8 @@ impl Step for RustdocJSNotStd {
666665
}
667666

668667
fn make_run(run: RunConfig<'_>) {
669-
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
670-
run.builder.ensure(RustdocJSNotStd { host: run.host, target: run.target, compiler });
668+
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
669+
run.builder.ensure(RustdocJSNotStd { target: run.target, compiler });
671670
}
672671

673672
fn run(self, builder: &Builder<'_>) {
@@ -688,7 +687,6 @@ impl Step for RustdocJSNotStd {
688687

689688
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
690689
pub struct RustdocUi {
691-
pub host: TargetSelection,
692690
pub target: TargetSelection,
693691
pub compiler: Compiler,
694692
}
@@ -703,8 +701,8 @@ impl Step for RustdocUi {
703701
}
704702

705703
fn make_run(run: RunConfig<'_>) {
706-
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
707-
run.builder.ensure(RustdocUi { host: run.host, target: run.target, compiler });
704+
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
705+
run.builder.ensure(RustdocUi { target: run.target, compiler });
708706
}
709707

710708
fn run(self, builder: &Builder<'_>) {
@@ -873,7 +871,7 @@ macro_rules! test_definitions {
873871
}
874872

875873
fn make_run(run: RunConfig<'_>) {
876-
let compiler = run.builder.compiler(run.builder.top_stage, run.host);
874+
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
877875

878876
run.builder.ensure($name { compiler, target: run.target });
879877
}
@@ -1422,7 +1420,7 @@ macro_rules! test_book {
14221420

14231421
fn make_run(run: RunConfig<'_>) {
14241422
run.builder.ensure($name {
1425-
compiler: run.builder.compiler(run.builder.top_stage, run.host),
1423+
compiler: run.builder.compiler(run.builder.top_stage, run.target),
14261424
});
14271425
}
14281426

@@ -1469,7 +1467,7 @@ impl Step for ErrorIndex {
14691467
// error_index_generator depends on librustdoc. Use the compiler that
14701468
// is normally used to build rustdoc for other tests (like compiletest
14711469
// tests in src/test/rustdoc) so that it shares the same artifacts.
1472-
let compiler = run.builder.compiler_for(run.builder.top_stage, run.host, run.host);
1470+
let compiler = run.builder.compiler_for(run.builder.top_stage, run.target, run.target);
14731471
run.builder.ensure(ErrorIndex { compiler });
14741472
}
14751473

@@ -1573,7 +1571,7 @@ impl Step for CrateLibrustc {
15731571

15741572
fn make_run(run: RunConfig<'_>) {
15751573
let builder = run.builder;
1576-
let compiler = builder.compiler(builder.top_stage, run.host);
1574+
let compiler = builder.compiler(builder.top_stage, run.build_triple());
15771575

15781576
for krate in builder.in_tree_crates("rustc-main") {
15791577
if krate.path.ends_with(&run.path) {
@@ -1620,7 +1618,7 @@ impl Step for CrateNotDefault {
16201618

16211619
fn make_run(run: RunConfig<'_>) {
16221620
let builder = run.builder;
1623-
let compiler = builder.compiler(builder.top_stage, run.host);
1621+
let compiler = builder.compiler(builder.top_stage, run.build_triple());
16241622

16251623
let test_kind = builder.kind.into();
16261624

@@ -1668,7 +1666,7 @@ impl Step for Crate {
16681666

16691667
fn make_run(run: RunConfig<'_>) {
16701668
let builder = run.builder;
1671-
let compiler = builder.compiler(builder.top_stage, run.host);
1669+
let compiler = builder.compiler(builder.top_stage, run.build_triple());
16721670

16731671
let make = |mode: Mode, krate: &CargoCrate| {
16741672
let test_kind = builder.kind.into();
@@ -1808,7 +1806,7 @@ impl Step for CrateRustdoc {
18081806

18091807
let test_kind = builder.kind.into();
18101808

1811-
builder.ensure(CrateRustdoc { host: run.host, test_kind });
1809+
builder.ensure(CrateRustdoc { host: run.target, test_kind });
18121810
}
18131811

18141812
fn run(self, builder: &Builder<'_>) {
@@ -2054,7 +2052,6 @@ impl Step for Bootstrap {
20542052
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
20552053
pub struct TierCheck {
20562054
pub compiler: Compiler,
2057-
target: TargetSelection,
20582055
}
20592056

20602057
impl Step for TierCheck {
@@ -2067,18 +2064,19 @@ impl Step for TierCheck {
20672064
}
20682065

20692066
fn make_run(run: RunConfig<'_>) {
2070-
let compiler = run.builder.compiler_for(run.builder.top_stage, run.host, run.host);
2071-
run.builder.ensure(TierCheck { compiler, target: run.host });
2067+
let compiler =
2068+
run.builder.compiler_for(run.builder.top_stage, run.builder.build.build, run.target);
2069+
run.builder.ensure(TierCheck { compiler });
20722070
}
20732071

20742072
/// Tests the Platform Support page in the rustc book.
20752073
fn run(self, builder: &Builder<'_>) {
2076-
builder.ensure(compile::Std { compiler: self.compiler, target: self.target });
2074+
builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host });
20772075
let mut cargo = tool::prepare_tool_cargo(
20782076
builder,
20792077
self.compiler,
2080-
Mode::ToolRustc,
2081-
self.target,
2078+
Mode::ToolStd,
2079+
self.compiler.host,
20822080
"run",
20832081
"src/tools/tier-check",
20842082
SourceType::InTree,

src/bootstrap/tool.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,9 @@ impl Step for Rustdoc {
469469
}
470470

471471
fn make_run(run: RunConfig<'_>) {
472-
run.builder
473-
.ensure(Rustdoc { compiler: run.builder.compiler(run.builder.top_stage, run.host) });
472+
run.builder.ensure(Rustdoc {
473+
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
474+
});
474475
}
475476

476477
fn run(self, builder: &Builder<'_>) -> PathBuf {

0 commit comments

Comments
 (0)