Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bypass linker configuration and cross target check for specific commands #128871

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2446,7 +2446,15 @@ impl Cargo {
cmd_kind: Kind,
) -> Cargo {
let mut cargo = builder.cargo(compiler, mode, source_type, target, cmd_kind);
cargo.configure_linker(builder);

match cmd_kind {
Kobzol marked this conversation as resolved.
Show resolved Hide resolved
// No need to configure the target linker for these command types.
Kind::Clean | Kind::Check | Kind::Suggest | Kind::Format | Kind::Setup => {}
_ => {
cargo.configure_linker(builder);
}
}

cargo
}

Expand Down
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
Loading