Skip to content

Commit

Permalink
bootstrap: Always build for host, even when target is given
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tmandry committed Sep 28, 2020
1 parent d62d3f7 commit e715c7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
19 changes: 7 additions & 12 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,31 +342,29 @@ mod dist {
}

#[test]
fn dist_with_target_flag() {
let mut config = configure(&["B"], &["C"]);
config.skip_only_host_steps = true; // as-if --target=C was passed
fn dist_with_empty_host() {
let mut config = configure(&[], &["C"]);
config.skip_only_host_steps = true;
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);

let a = TargetSelection::from_user("A");
let b = TargetSelection::from_user("B");
let c = TargetSelection::from_user("C");

assert_eq!(
first(builder.cache.all::<dist::Docs>()),
&[dist::Docs { host: a }, dist::Docs { host: b }, dist::Docs { host: c },]
&[dist::Docs { host: a }, dist::Docs { host: c },]
);
assert_eq!(
first(builder.cache.all::<dist::Mingw>()),
&[dist::Mingw { host: a }, dist::Mingw { host: b }, dist::Mingw { host: c },]
&[dist::Mingw { host: a }, dist::Mingw { host: c },]
);
assert_eq!(first(builder.cache.all::<dist::Rustc>()), &[]);
assert_eq!(
first(builder.cache.all::<dist::Std>()),
&[
dist::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
dist::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
dist::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
]
);
Expand Down Expand Up @@ -464,15 +462,14 @@ mod dist {
}

#[test]
fn build_with_target_flag() {
let mut config = configure(&["B"], &["C"]);
fn build_with_empty_host() {
let mut config = configure(&[], &["C"]);
config.skip_only_host_steps = true;
let build = Build::new(config);
let mut builder = Builder::new(&build);
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);

let a = TargetSelection::from_user("A");
let b = TargetSelection::from_user("B");
let c = TargetSelection::from_user("C");

assert_eq!(
Expand All @@ -481,8 +478,6 @@ mod dist {
compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
]
);
Expand Down
7 changes: 2 additions & 5 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,18 +586,15 @@ impl Config {

let build = toml.build.unwrap_or_default();

// If --target was specified but --host wasn't specified, don't run any host-only tests.
let has_hosts = build.host.is_some() || flags.host.is_some();
let has_targets = build.target.is_some() || flags.target.is_some();
config.skip_only_host_steps = !has_hosts && has_targets;

config.hosts = if let Some(arg_host) = flags.host {
arg_host
} else if let Some(file_host) = build.host {
file_host.iter().map(|h| TargetSelection::from_user(h)).collect()
} else {
vec![config.build]
};
// If host was explicitly given an empty list, don't run any host-only steps.
config.skip_only_host_steps = config.hosts.is_empty();
config.targets = if let Some(arg_target) = flags.target {
arg_target
} else if let Some(file_target) = build.target {
Expand Down

0 comments on commit e715c7f

Please sign in to comment.