Skip to content

Commit

Permalink
don't try to find target tools on certain commands
Browse files Browse the repository at this point in the history
For commands like check/clean there is no need to check for target tools.
Avoiding this check can also speed up the process.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Aug 9, 2024
1 parent 9a29081 commit 94fbe14
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/bootstrap/src/utils/cc_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,29 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
}

pub fn find(build: &Build) {
// For all targets we're going to need a C compiler for building some shims
// and such as well as for being a linker for Rust code.
let targets = build
.targets
.iter()
.chain(&build.hosts)
.cloned()
.chain(iter::once(build.build))
.collect::<HashSet<_>>();
let targets: HashSet<_> = match build.config.cmd {
// We don't need to check cross targets for these commands.
crate::Subcommand::Clean { .. }
| crate::Subcommand::Check { .. }
| crate::Subcommand::Suggest { .. }
| crate::Subcommand::Format { .. }
| crate::Subcommand::Setup { .. } => {
build.hosts.iter().cloned().chain(iter::once(build.build)).collect()
}

_ => {
// For all targets we're going to need a C compiler for building some shims
// and such as well as for being a linker for Rust code.
build
.targets
.iter()
.chain(&build.hosts)
.cloned()
.chain(iter::once(build.build))
.collect()
}
};

for target in targets.into_iter() {
find_target(build, target);
}
Expand Down

0 comments on commit 94fbe14

Please sign in to comment.