Skip to content

Commit 0d9afb6

Browse files
committed
Auto merge of #77133 - tmandry:bootstrap-host, r=Mark-Simulacrum
bootstrap: Always build for host, even when target is given This changes the behavior from *not* building for host whenever an explicit target is specified. I find this much less confusing. You can still disable host steps by passing an explicit empty list for host. Fixes #76990. r? `@Mark-Simulacrum`
2 parents 0d97f7a + bf7aeaa commit 0d9afb6

File tree

17 files changed

+52
-86
lines changed

17 files changed

+52
-86
lines changed

src/bootstrap/CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [Non-breaking changes since the last major version]
88

9+
None.
10+
11+
## [Version 2] - 2020-09-25
12+
13+
- `host` now defaults to the value of `build` in all cases
14+
+ Previously `host` defaulted to an empty list when `target` was overridden, and to `build` otherwise
15+
16+
### Non-breaking changes
17+
918
- Add `x.py setup` [#76631](https://github.com/rust-lang/rust/pull/76631)
1019
- Add a changelog for x.py [#76626](https://github.com/rust-lang/rust/pull/76626)
1120
- Optionally, download LLVM from CI on Linux and NixOS
@@ -21,7 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2130
[#77120](https://github.com/rust-lang/rust/pull/77120).
2231

2332

24-
## [Version 0] - 2020-09-11
33+
## [Version 1] - 2020-09-11
2534

2635
This is the first changelog entry, and it does not attempt to be an exhaustive list of features in x.py.
2736
Instead, this documents the changes to bootstrap in the past 2 months.

src/bootstrap/bin/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn main() {
4040
}
4141

4242
fn check_version(config: &Config) -> Option<String> {
43-
const VERSION: usize = 1;
43+
const VERSION: usize = 2;
4444

4545
let mut msg = String::new();
4646

src/bootstrap/builder.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,7 @@ impl StepDescription {
172172
}
173173

174174
// Determine the targets participating in this rule.
175-
let targets = if self.only_hosts {
176-
if builder.config.skip_only_host_steps {
177-
return; // don't run anything
178-
} else {
179-
&builder.hosts
180-
}
181-
} else {
182-
&builder.targets
183-
};
175+
let targets = if self.only_hosts { &builder.hosts } else { &builder.targets };
184176

185177
for target in targets {
186178
let run = RunConfig { builder, path: pathset.path(builder), target: *target };

src/bootstrap/builder/tests.rs

+24-52
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
66
let mut config = Config::parse(&[cmd.to_owned()]);
77
// don't save toolstates
88
config.save_toolstates = None;
9-
config.skip_only_host_steps = false;
109
config.dry_run = true;
1110
config.ninja_in_file = false;
1211
// try to avoid spurious failures in dist where we create/delete each others file
@@ -20,16 +19,8 @@ fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
2019
t!(fs::create_dir_all(&dir));
2120
config.out = dir;
2221
config.build = TargetSelection::from_user("A");
23-
config.hosts = vec![config.build]
24-
.into_iter()
25-
.chain(host.iter().map(|s| TargetSelection::from_user(s)))
26-
.collect::<Vec<_>>();
27-
config.targets = config
28-
.hosts
29-
.clone()
30-
.into_iter()
31-
.chain(target.iter().map(|s| TargetSelection::from_user(s)))
32-
.collect::<Vec<_>>();
22+
config.hosts = host.iter().map(|s| TargetSelection::from_user(s)).collect();
23+
config.targets = target.iter().map(|s| TargetSelection::from_user(s)).collect();
3324
config
3425
}
3526

@@ -45,7 +36,7 @@ mod defaults {
4536

4637
#[test]
4738
fn build_default() {
48-
let build = Build::new(configure("build", &[], &[]));
39+
let build = Build::new(configure("build", &["A"], &["A"]));
4940
let mut builder = Builder::new(&build);
5041
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
5142

@@ -73,7 +64,7 @@ mod defaults {
7364

7465
#[test]
7566
fn build_stage_0() {
76-
let config = Config { stage: 0, ..configure("build", &[], &[]) };
67+
let config = Config { stage: 0, ..configure("build", &["A"], &["A"]) };
7768
let build = Build::new(config);
7869
let mut builder = Builder::new(&build);
7970
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
@@ -95,7 +86,7 @@ mod defaults {
9586

9687
#[test]
9788
fn build_cross_compile() {
98-
let config = Config { stage: 1, ..configure("build", &["B"], &["B"]) };
89+
let config = Config { stage: 1, ..configure("build", &["A", "B"], &["A", "B"]) };
9990
let build = Build::new(config);
10091
let mut builder = Builder::new(&build);
10192
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
@@ -143,7 +134,7 @@ mod defaults {
143134

144135
#[test]
145136
fn doc_default() {
146-
let mut config = configure("doc", &[], &[]);
137+
let mut config = configure("doc", &["A"], &["A"]);
147138
config.compiler_docs = true;
148139
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false };
149140
let build = Build::new(config);
@@ -182,7 +173,7 @@ mod dist {
182173

183174
#[test]
184175
fn dist_baseline() {
185-
let build = Build::new(configure(&[], &[]));
176+
let build = Build::new(configure(&["A"], &["A"]));
186177
let mut builder = Builder::new(&build);
187178
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
188179

@@ -208,7 +199,7 @@ mod dist {
208199

209200
#[test]
210201
fn dist_with_targets() {
211-
let build = Build::new(configure(&[], &["B"]));
202+
let build = Build::new(configure(&["A"], &["A", "B"]));
212203
let mut builder = Builder::new(&build);
213204
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
214205

@@ -239,7 +230,7 @@ mod dist {
239230

240231
#[test]
241232
fn dist_with_hosts() {
242-
let build = Build::new(configure(&["B"], &[]));
233+
let build = Build::new(configure(&["A", "B"], &["A", "B"]));
243234
let mut builder = Builder::new(&build);
244235
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
245236

@@ -285,7 +276,7 @@ mod dist {
285276
fn dist_only_cross_host() {
286277
let a = TargetSelection::from_user("A");
287278
let b = TargetSelection::from_user("B");
288-
let mut build = Build::new(configure(&["B"], &[]));
279+
let mut build = Build::new(configure(&["A", "B"], &["A", "B"]));
289280
build.config.docs = false;
290281
build.config.extended = true;
291282
build.hosts = vec![b];
@@ -307,7 +298,7 @@ mod dist {
307298

308299
#[test]
309300
fn dist_with_targets_and_hosts() {
310-
let build = Build::new(configure(&["B"], &["C"]));
301+
let build = Build::new(configure(&["A", "B"], &["A", "B", "C"]));
311302
let mut builder = Builder::new(&build);
312303
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
313304

@@ -342,40 +333,26 @@ mod dist {
342333
}
343334

344335
#[test]
345-
fn dist_with_target_flag() {
346-
let mut config = configure(&["B"], &["C"]);
347-
config.skip_only_host_steps = true; // as-if --target=C was passed
336+
fn dist_with_empty_host() {
337+
let config = configure(&[], &["C"]);
348338
let build = Build::new(config);
349339
let mut builder = Builder::new(&build);
350340
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
351341

352342
let a = TargetSelection::from_user("A");
353-
let b = TargetSelection::from_user("B");
354343
let c = TargetSelection::from_user("C");
355344

356-
assert_eq!(
357-
first(builder.cache.all::<dist::Docs>()),
358-
&[dist::Docs { host: a }, dist::Docs { host: b }, dist::Docs { host: c },]
359-
);
360-
assert_eq!(
361-
first(builder.cache.all::<dist::Mingw>()),
362-
&[dist::Mingw { host: a }, dist::Mingw { host: b }, dist::Mingw { host: c },]
363-
);
364-
assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[]);
345+
assert_eq!(first(builder.cache.all::<dist::Docs>()), &[dist::Docs { host: c },]);
346+
assert_eq!(first(builder.cache.all::<dist::Mingw>()), &[dist::Mingw { host: c },]);
365347
assert_eq!(
366348
first(builder.cache.all::<dist::Std>()),
367-
&[
368-
dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
369-
dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
370-
dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
371-
]
349+
&[dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c },]
372350
);
373-
assert_eq!(first(builder.cache.all::<dist::Src>()), &[]);
374351
}
375352

376353
#[test]
377354
fn dist_with_same_targets_and_hosts() {
378-
let build = Build::new(configure(&["B"], &["B"]));
355+
let build = Build::new(configure(&["A", "B"], &["A", "B"]));
379356
let mut builder = Builder::new(&build);
380357
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
381358

@@ -428,7 +405,7 @@ mod dist {
428405

429406
#[test]
430407
fn build_all() {
431-
let build = Build::new(configure(&["B"], &["C"]));
408+
let build = Build::new(configure(&["A", "B"], &["A", "B", "C"]));
432409
let mut builder = Builder::new(&build);
433410
builder.run_step_descriptions(
434411
&Builder::get_step_descriptions(Kind::Build),
@@ -464,25 +441,20 @@ mod dist {
464441
}
465442

466443
#[test]
467-
fn build_with_target_flag() {
468-
let mut config = configure(&["B"], &["C"]);
469-
config.skip_only_host_steps = true;
444+
fn build_with_empty_host() {
445+
let config = configure(&[], &["C"]);
470446
let build = Build::new(config);
471447
let mut builder = Builder::new(&build);
472448
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
473449

474450
let a = TargetSelection::from_user("A");
475-
let b = TargetSelection::from_user("B");
476451
let c = TargetSelection::from_user("C");
477452

478453
assert_eq!(
479454
first(builder.cache.all::<compile::Std>()),
480455
&[
481456
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
482457
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
483-
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
484-
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
485-
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
486458
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
487459
]
488460
);
@@ -505,7 +477,7 @@ mod dist {
505477

506478
#[test]
507479
fn test_with_no_doc_stage0() {
508-
let mut config = configure(&[], &[]);
480+
let mut config = configure(&["A"], &["A"]);
509481
config.stage = 0;
510482
config.cmd = Subcommand::Test {
511483
paths: vec!["library/std".into()],
@@ -545,7 +517,7 @@ mod dist {
545517

546518
#[test]
547519
fn test_exclude() {
548-
let mut config = configure(&[], &[]);
520+
let mut config = configure(&["A"], &["A"]);
549521
config.exclude = vec!["src/tools/tidy".into()];
550522
config.cmd = Subcommand::Test {
551523
paths: Vec::new(),
@@ -572,7 +544,7 @@ mod dist {
572544

573545
#[test]
574546
fn doc_ci() {
575-
let mut config = configure(&[], &[]);
547+
let mut config = configure(&["A"], &["A"]);
576548
config.compiler_docs = true;
577549
config.cmd = Subcommand::Doc { paths: Vec::new(), open: false };
578550
let build = Build::new(config);
@@ -601,7 +573,7 @@ mod dist {
601573
#[test]
602574
fn test_docs() {
603575
// Behavior of `x.py test` doing various documentation tests.
604-
let mut config = configure(&[], &[]);
576+
let mut config = configure(&["A"], &["A"]);
605577
config.cmd = Subcommand::Test {
606578
paths: vec![],
607579
test_args: vec![],

src/bootstrap/config.rs

-7
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ pub struct Config {
6666
pub test_compare_mode: bool,
6767
pub llvm_libunwind: bool,
6868

69-
pub skip_only_host_steps: bool,
70-
7169
pub on_fail: Option<String>,
7270
pub stage: u32,
7371
pub keep_stage: Vec<u32>,
@@ -586,11 +584,6 @@ impl Config {
586584

587585
let build = toml.build.unwrap_or_default();
588586

589-
// If --target was specified but --host wasn't specified, don't run any host-only tests.
590-
let has_hosts = build.host.is_some() || flags.host.is_some();
591-
let has_targets = build.target.is_some() || flags.target.is_some();
592-
config.skip_only_host_steps = !has_hosts && has_targets;
593-
594587
config.hosts = if let Some(arg_host) = flags.host {
595588
arg_host
596589
} else if let Some(file_host) = build.host {

src/bootstrap/flags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl Subcommand {
679679
}
680680

681681
fn split(s: &[String]) -> Vec<String> {
682-
s.iter().flat_map(|s| s.split(',')).map(|s| s.to_string()).collect()
682+
s.iter().flat_map(|s| s.split(',')).filter(|s| !s.is_empty()).map(|s| s.to_string()).collect()
683683
}
684684

685685
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {

src/ci/docker/host-x86_64/arm-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ENV TARGETS=arm-linux-androideabi
3131

3232
ENV RUST_CONFIGURE_ARGS --arm-linux-androideabi-ndk=/android/ndk/arm-14
3333

34-
ENV SCRIPT python3 ../x.py --stage 2 test --target $TARGETS
34+
ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target $TARGETS
3535

3636
COPY scripts/sccache.sh /scripts/
3737
RUN sh /scripts/sccache.sh

src/ci/docker/host-x86_64/armhf-gnu/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ COPY scripts/sccache.sh /scripts/
7979
RUN sh /scripts/sccache.sh
8080

8181
ENV RUST_CONFIGURE_ARGS --qemu-armhf-rootfs=/tmp/rootfs
82-
ENV SCRIPT python3 ../x.py --stage 2 test --target arm-unknown-linux-gnueabihf
82+
ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target arm-unknown-linux-gnueabihf
8383

8484
ENV NO_CHANGE_USER=1

src/ci/docker/host-x86_64/disabled/asmjs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ENV EMCC_CFLAGS=-O1
3434
# Emscripten installation is user-specific
3535
ENV NO_CHANGE_USER=1
3636

37-
ENV SCRIPT python3 ../x.py --stage 2 test --target $TARGETS
37+
ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target $TARGETS
3838

3939
# This is almost identical to the wasm32-unknown-emscripten target, so
4040
# running with assertions again is not useful

src/ci/docker/host-x86_64/disabled/dist-x86_64-redox/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ ENV \
1919
CXX_x86_64_unknown_redox=x86_64-unknown-redox-g++
2020

2121
ENV RUST_CONFIGURE_ARGS --enable-extended
22-
ENV SCRIPT python3 ../x.py dist --target x86_64-unknown-redox
22+
ENV SCRIPT python3 ../x.py dist --host='' --target x86_64-unknown-redox

src/ci/docker/host-x86_64/dist-android/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ENV RUST_CONFIGURE_ARGS \
3232
--x86_64-linux-android-ndk=/android/ndk/x86_64-21 \
3333
--disable-docs
3434

35-
ENV SCRIPT python3 ../x.py dist --target $TARGETS
35+
ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS
3636

3737
COPY scripts/sccache.sh /scripts/
3838
RUN sh /scripts/sccache.sh

src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ ENV CFLAGS_i586_unknown_linux_musl=-Wa,-mrelax-relocations=no
4747
ENV TARGETS=i586-unknown-linux-gnu,i686-unknown-linux-musl
4848

4949
ENV SCRIPT \
50-
python3 ../x.py --stage 2 test --target $TARGETS && \
51-
python3 ../x.py dist --target $TARGETS,i586-unknown-linux-musl
50+
python3 ../x.py --stage 2 test --host='' --target $TARGETS && \
51+
python3 ../x.py dist --host='' --target $TARGETS,i586-unknown-linux-musl

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ ENV RUST_CONFIGURE_ARGS \
187187
--disable-docs
188188

189189
ENV SCRIPT \
190-
python3 ../x.py --stage 2 test --target $RUN_MAKE_TARGETS src/test/run-make && \
191-
python3 ../x.py dist --target $TARGETS
190+
python3 ../x.py --stage 2 test --host='' --target $RUN_MAKE_TARGETS src/test/run-make && \
191+
python3 ../x.py dist --host='' --target $TARGETS
192192

193193
# sccache
194194
COPY scripts/sccache.sh /scripts/

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
110110
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
111111
--musl-root-armv7=/musl-armv7
112112

113-
ENV SCRIPT python3 ../x.py dist --target $TARGETS
113+
ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS

src/ci/docker/host-x86_64/test-various/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ENV RUST_CONFIGURE_ARGS \
4141
ENV NO_DEBUG_ASSERTIONS=1
4242

4343
ENV WASM_TARGETS=wasm32-unknown-unknown
44-
ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --target $WASM_TARGETS \
44+
ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_TARGETS \
4545
src/test/run-make \
4646
src/test/ui \
4747
src/test/compile-fail \
@@ -50,13 +50,13 @@ ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --target $WASM_TARGETS \
5050
library/core
5151

5252
ENV NVPTX_TARGETS=nvptx64-nvidia-cuda
53-
ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --target $NVPTX_TARGETS \
53+
ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \
5454
src/test/run-make \
5555
src/test/assembly
5656

5757
ENV MUSL_TARGETS=x86_64-unknown-linux-musl \
5858
CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc \
5959
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++
60-
ENV MUSL_SCRIPT python3 /checkout/x.py --stage 2 test --target $MUSL_TARGETS
60+
ENV MUSL_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $MUSL_TARGETS
6161

6262
ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT

0 commit comments

Comments
 (0)