Skip to content

Commit e715c7f

Browse files
committed
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.
1 parent d62d3f7 commit e715c7f

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/bootstrap/builder/tests.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -342,31 +342,29 @@ mod dist {
342342
}
343343

344344
#[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
345+
fn dist_with_empty_host() {
346+
let mut config = configure(&[], &["C"]);
347+
config.skip_only_host_steps = true;
348348
let build = Build::new(config);
349349
let mut builder = Builder::new(&build);
350350
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
351351

352352
let a = TargetSelection::from_user("A");
353-
let b = TargetSelection::from_user("B");
354353
let c = TargetSelection::from_user("C");
355354

356355
assert_eq!(
357356
first(builder.cache.all::<dist::Docs>()),
358-
&[dist::Docs { host: a }, dist::Docs { host: b }, dist::Docs { host: c },]
357+
&[dist::Docs { host: a }, dist::Docs { host: c },]
359358
);
360359
assert_eq!(
361360
first(builder.cache.all::<dist::Mingw>()),
362-
&[dist::Mingw { host: a }, dist::Mingw { host: b }, dist::Mingw { host: c },]
361+
&[dist::Mingw { host: a }, dist::Mingw { host: c },]
363362
);
364363
assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[]);
365364
assert_eq!(
366365
first(builder.cache.all::<dist::Std>()),
367366
&[
368367
dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
369-
dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
370368
dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
371369
]
372370
);
@@ -464,15 +462,14 @@ mod dist {
464462
}
465463

466464
#[test]
467-
fn build_with_target_flag() {
468-
let mut config = configure(&["B"], &["C"]);
465+
fn build_with_empty_host() {
466+
let mut config = configure(&[], &["C"]);
469467
config.skip_only_host_steps = true;
470468
let build = Build::new(config);
471469
let mut builder = Builder::new(&build);
472470
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
473471

474472
let a = TargetSelection::from_user("A");
475-
let b = TargetSelection::from_user("B");
476473
let c = TargetSelection::from_user("C");
477474

478475
assert_eq!(
@@ -481,8 +478,6 @@ mod dist {
481478
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
482479
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
483480
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 },
486481
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
487482
]
488483
);

src/bootstrap/config.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -586,18 +586,15 @@ impl Config {
586586

587587
let build = toml.build.unwrap_or_default();
588588

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-
594589
config.hosts = if let Some(arg_host) = flags.host {
595590
arg_host
596591
} else if let Some(file_host) = build.host {
597592
file_host.iter().map(|h| TargetSelection::from_user(h)).collect()
598593
} else {
599594
vec![config.build]
600595
};
596+
// If host was explicitly given an empty list, don't run any host-only steps.
597+
config.skip_only_host_steps = config.hosts.is_empty();
601598
config.targets = if let Some(arg_target) = flags.target {
602599
arg_target
603600
} else if let Some(file_target) = build.target {

0 commit comments

Comments
 (0)