Skip to content

Commit

Permalink
propagate --target only if target is not host
Browse files Browse the repository at this point in the history
Passing `--target` alters `RUSTFLAGS` in the build scripts. Since there is no reason
to pass them when building for the host triple, exclude them if the target is the host triple.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Apr 7, 2024
1 parent 3f10032 commit 0bdcd2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,10 +1343,9 @@ impl<'a> Builder<'a> {
Color::Auto => {} // nothing to do
}

if cmd != "install" {
if target != compiler.host {
assert!(cmd != "install", "`x install` can only be called for the host triple.");
cargo.arg("--target").arg(target.rustc_target_arg());
} else {
assert_eq!(target, compiler.host);
}

if self.config.rust_optimize.is_release() {
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,13 @@ impl Build {
/// running a particular compiler, whether or not we're building the
/// standard library, and targeting the specified architecture.
fn cargo_out(&self, compiler: Compiler, mode: Mode, target: TargetSelection) -> PathBuf {
self.stage_out(compiler, mode).join(&*target.triple).join(self.cargo_dir())
let stage_out = self.stage_out(compiler, mode);

if self.config.build == target {
stage_out.join(self.cargo_dir())
} else {
stage_out.join(&*target.triple).join(self.cargo_dir())
}
}

/// Root output directory of LLVM for `target`
Expand Down

0 comments on commit 0bdcd2c

Please sign in to comment.