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

Infer Lld::No linker hint when the linker stem is a generic compiler driver #114711

Merged
merged 2 commits into from
Aug 15, 2023
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
19 changes: 2 additions & 17 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2991,25 +2991,10 @@ fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
return;
}

let self_contained_linker = sess.opts.cg.link_self_contained.linker();

// FIXME: some targets default to using `lld`, but users can only override the linker on the CLI
// and cannot yet select the precise linker flavor to opt out of that. See for example issue
// #113597 for the `thumbv6m-none-eabi` target: a driver is used, and its default linker
// conflicts with the target's flavor, causing unexpected arguments being passed.
//
// Until the new `LinkerFlavor`-like CLI options are stabilized, we only adopt MCP510's behavior
// if its dedicated unstable CLI flags are used, to keep the current sub-optimal stable
// behavior.
let using_mcp510 =
self_contained_linker || sess.opts.cg.linker_flavor.is_some_and(|f| f.is_unstable());
if !using_mcp510 && !unstable_use_lld {
return;
}

// 1. Implement the "self-contained" part of this feature by adding rustc distribution
// directories to the tool's search path.
if self_contained_linker || unstable_use_lld {
let self_contained_linker = sess.opts.cg.link_self_contained.linker() || unstable_use_lld;
if self_contained_linker {
for path in sess.get_tools_search_paths(false) {
cmd.arg({
let mut arg = OsString::from("-B");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl LinkerFlavor {
|| stem == "clang++"
|| stem.ends_with("-clang++")
{
(Some(Cc::Yes), None)
(Some(Cc::Yes), Some(Lld::No))
} else if stem == "wasm-ld"
|| stem.ends_with("-wasm-ld")
|| stem == "ld.lld"
Expand Down
Loading