Skip to content

Commit f3e8856

Browse files
committed
bootstrap: take target by value in is_builder_target
1 parent a0c3874 commit f3e8856

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Step for Std {
154154

155155
// When using `download-rustc`, we already have artifacts for the host available. Don't
156156
// recompile them.
157-
if builder.download_rustc() && target == builder.build.build
157+
if builder.download_rustc() && builder.is_builder_target(target)
158158
// NOTE: the beta compiler may generate different artifacts than the downloaded compiler, so
159159
// its artifacts can't be reused.
160160
&& compiler.stage != 0
@@ -232,7 +232,7 @@ impl Step for Std {
232232
// The LLD wrappers and `rust-lld` are self-contained linking components that can be
233233
// necessary to link the stdlib on some targets. We'll also need to copy these binaries to
234234
// the `stage0-sysroot` to ensure the linker is found when bootstrapping on such a target.
235-
if compiler.stage == 0 && builder.is_builder_target(&compiler.host) {
235+
if compiler.stage == 0 && builder.is_builder_target(compiler.host) {
236236
trace!(
237237
"(build == host) copying linking components to `stage0-sysroot` for bootstrapping"
238238
);
@@ -1559,7 +1559,7 @@ impl Step for CodegenBackend {
15591559
#[cfg_attr(
15601560
feature = "tracing",
15611561
instrument(
1562-
level = "debug",
1562+
level = "debug",
15631563
name = "CodegenBackend::run",
15641564
skip_all,
15651565
fields(
@@ -2485,7 +2485,7 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path)
24852485
// FIXME: to make things simpler for now, limit this to the host and target where we know
24862486
// `strip -g` is both available and will fix the issue, i.e. on a x64 linux host that is not
24872487
// cross-compiling. Expand this to other appropriate targets in the future.
2488-
if target != "x86_64-unknown-linux-gnu" || !builder.is_builder_target(&target) || !path.exists()
2488+
if target != "x86_64-unknown-linux-gnu" || !builder.is_builder_target(target) || !path.exists()
24892489
{
24902490
return;
24912491
}

src/bootstrap/src/core/build_steps/dist.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl Step for DebuggerScripts {
584584
fn skip_host_target_lib(builder: &Builder<'_>, compiler: Compiler) -> bool {
585585
// The only true set of target libraries came from the build triple, so
586586
// let's reduce redundant work by only producing archives from that host.
587-
if !builder.is_builder_target(&compiler.host) {
587+
if !builder.is_builder_target(compiler.host) {
588588
builder.info("\tskipping, not a build host");
589589
true
590590
} else {
@@ -639,7 +639,7 @@ fn copy_target_libs(
639639
for (path, dependency_type) in builder.read_stamp_file(stamp) {
640640
if dependency_type == DependencyType::TargetSelfContained {
641641
builder.copy_link(&path, &self_contained_dst.join(path.file_name().unwrap()));
642-
} else if dependency_type == DependencyType::Target || builder.is_builder_target(&target) {
642+
} else if dependency_type == DependencyType::Target || builder.is_builder_target(target) {
643643
builder.copy_link(&path, &dst.join(path.file_name().unwrap()));
644644
}
645645
}
@@ -788,7 +788,7 @@ impl Step for Analysis {
788788
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
789789
let compiler = self.compiler;
790790
let target = self.target;
791-
if !builder.is_builder_target(&compiler.host) {
791+
if !builder.is_builder_target(compiler.host) {
792792
return None;
793793
}
794794

src/bootstrap/src/core/build_steps/llvm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl Step for Llvm {
518518
}
519519

520520
// https://llvm.org/docs/HowToCrossCompileLLVM.html
521-
if !builder.is_builder_target(&target) {
521+
if !builder.is_builder_target(target) {
522522
let LlvmResult { llvm_config, .. } =
523523
builder.ensure(Llvm { target: builder.config.build });
524524
if !builder.config.dry_run() {
@@ -670,7 +670,7 @@ fn configure_cmake(
670670
}
671671
cfg.target(&target.triple).host(&builder.config.build.triple);
672672

673-
if !builder.is_builder_target(&target) {
673+
if !builder.is_builder_target(target) {
674674
cfg.define("CMAKE_CROSSCOMPILING", "True");
675675

676676
if target.contains("netbsd") {
@@ -1133,7 +1133,7 @@ impl Step for Lld {
11331133
.define("LLVM_CMAKE_DIR", llvm_cmake_dir)
11341134
.define("LLVM_INCLUDE_TESTS", "OFF");
11351135

1136-
if !builder.is_builder_target(&target) {
1136+
if !builder.is_builder_target(target) {
11371137
// Use the host llvm-tblgen binary.
11381138
cfg.define(
11391139
"LLVM_TABLEGEN_EXE",

src/bootstrap/src/core/build_steps/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ impl Step for Crate {
27432743
cargo
27442744
} else {
27452745
// Also prepare a sysroot for the target.
2746-
if !builder.is_builder_target(&target) {
2746+
if !builder.is_builder_target(target) {
27472747
builder.ensure(compile::Std::new(compiler, target).force_recompile(true));
27482748
builder.ensure(RemoteCopyLibs { compiler, target });
27492749
}

src/bootstrap/src/core/builder/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ fn test_is_builder_target() {
10771077
let build = Build::new(config);
10781078
let builder = Builder::new(&build);
10791079

1080-
assert!(builder.is_builder_target(&target1));
1081-
assert!(!builder.is_builder_target(&target2));
1080+
assert!(builder.is_builder_target(target1));
1081+
assert!(!builder.is_builder_target(target2));
10821082
}
10831083
}

src/bootstrap/src/core/sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ than building it.
329329
if target.contains("musl") && !target.contains("unikraft") {
330330
// If this is a native target (host is also musl) and no musl-root is given,
331331
// fall back to the system toolchain in /usr before giving up
332-
if build.musl_root(*target).is_none() && build.is_builder_target(target) {
332+
if build.musl_root(*target).is_none() && build.is_builder_target(*target) {
333333
let target = build.config.target_config.entry(*target).or_default();
334334
target.musl_root = Some("/usr".into());
335335
}

src/bootstrap/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ impl Build {
748748
/// Note that if LLVM is configured externally then the directory returned
749749
/// will likely be empty.
750750
fn llvm_out(&self, target: TargetSelection) -> PathBuf {
751-
if self.config.llvm_from_ci && self.is_builder_target(&target) {
751+
if self.config.llvm_from_ci && self.is_builder_target(target) {
752752
self.config.ci_llvm_root()
753753
} else {
754754
self.out.join(target).join("llvm")
@@ -798,7 +798,7 @@ impl Build {
798798
fn is_system_llvm(&self, target: TargetSelection) -> bool {
799799
match self.config.target_config.get(&target) {
800800
Some(Target { llvm_config: Some(_), .. }) => {
801-
let ci_llvm = self.config.llvm_from_ci && self.is_builder_target(&target);
801+
let ci_llvm = self.config.llvm_from_ci && self.is_builder_target(target);
802802
!ci_llvm
803803
}
804804
// We're building from the in-tree src/llvm-project sources.
@@ -1286,7 +1286,7 @@ Executed at: {executed_at}"#,
12861286
// need to use CXX compiler as linker to resolve the exception functions
12871287
// that are only existed in CXX libraries
12881288
Some(self.cxx.borrow()[&target].path().into())
1289-
} else if !self.is_builder_target(&target)
1289+
} else if !self.is_builder_target(target)
12901290
&& helpers::use_host_linker(target)
12911291
&& !target.is_msvc()
12921292
{
@@ -1939,8 +1939,8 @@ to download LLVM rather than building it.
19391939
}
19401940

19411941
/// Checks if the given target is the same as the builder target.
1942-
fn is_builder_target(&self, target: &TargetSelection) -> bool {
1943-
&self.config.build == target
1942+
fn is_builder_target(&self, target: TargetSelection) -> bool {
1943+
self.config.build == target
19441944
}
19451945
}
19461946

0 commit comments

Comments
 (0)