From 9d3616f78d5e1e9dd0f95f261970946e8ef821c1 Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Wed, 28 Dec 2016 03:39:35 +0800 Subject: [PATCH 1/3] rustbuild: get an empty slice the straight-forward way --- src/bootstrap/step.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index c5898c1119a67..ceece7988adf5 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -843,7 +843,7 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? let arr = if rule.host { if self.build.flags.target.len() > 0 && self.build.flags.host.len() == 0 { - &hosts[..0] + &[] } else { hosts } From 3991046d52a0cdcc88174f5d421d4c7761f49244 Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Wed, 28 Dec 2016 01:54:09 +0800 Subject: [PATCH 2/3] rustbuild: clarify comment on target array calculation The comment touched, as originally written, only concerned itself with the `test` steps. However, since #38468 the `arr` variable actually has gained an indirect relationship with the `dist` steps too. The comment failed to convey the extra meaning, contributing to the misunderstanding which eventually lead to #38637. Fix that by moving the comment into the right place near the relevant condition, and properly documenting `arr`'s purpose. --- src/bootstrap/step.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index ceece7988adf5..2c0bd1b6e23ec 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -838,9 +838,10 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? } else { &self.build.config.target }; - // If --target was specified but --host wasn't specified, don't run - // any host-only tests + // Determine the actual targets participating in this rule. let arr = if rule.host { + // If --target was specified but --host wasn't specified, + // don't run any host-only tests if self.build.flags.target.len() > 0 && self.build.flags.host.len() == 0 { &[] From cf894535069f67a1192ae7999ae2a82ba31b4877 Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Wed, 28 Dec 2016 01:49:25 +0800 Subject: [PATCH 3/3] rustbuild: fix host-only rules ignoring targets in dist steps `arr` is the actual list of targets participating in steps construction, but due to #38468 the hosts array now consists of only the build triple for the `dist` steps, hence all non-build-triple targets are lost for the host-only rules. Fix this by using the original non-shadowed hosts array in `arr` calculation. This should unbreak the nightly packaging process. Fixes #38637. --- src/bootstrap/step.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 2c0bd1b6e23ec..52caa3f0958a3 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -839,14 +839,20 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd? &self.build.config.target }; // Determine the actual targets participating in this rule. + // NOTE: We should keep the full projection from build triple to + // the hosts for the dist steps, now that the hosts array above is + // truncated to avoid duplication of work in that case. Therefore + // the original non-shadowed hosts array is used below. let arr = if rule.host { // If --target was specified but --host wasn't specified, - // don't run any host-only tests - if self.build.flags.target.len() > 0 && - self.build.flags.host.len() == 0 { + // don't run any host-only tests. Also, respect any `--host` + // overrides as done for `hosts`. + if self.build.flags.host.len() > 0 { + &self.build.flags.host[..] + } else if self.build.flags.target.len() > 0 { &[] } else { - hosts + &self.build.config.host[..] } } else { targets