Skip to content

Commit 2b61a5e

Browse files
committed
make MCP510 behavior explicitly opt-in
because sometimes users can't opt out
1 parent 993deaa commit 2b61a5e

File tree

1 file changed

+17
-2
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+17
-2
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -2970,10 +2970,25 @@ fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
29702970
return;
29712971
}
29722972

2973+
let self_contained_linker = sess.opts.cg.link_self_contained.linker();
2974+
2975+
// FIXME: some targets default to using `lld`, but users can only override the linker on the CLI
2976+
// and cannot yet select the precise linker flavor to opt out of that. See for example issue
2977+
// #113597 for the `thumbv6m-none-eabi` target: a driver is used, and its default linker
2978+
// conflicts with the target's flavor, causing unexpected arguments being passed.
2979+
//
2980+
// Until the new `LinkerFlavor`-like CLI options are stabilized, we only adopt MCP510's behavior
2981+
// if its dedicated unstable CLI flags are used, to keep the current sub-optimal stable
2982+
// behavior.
2983+
let using_mcp510 =
2984+
self_contained_linker || sess.opts.cg.linker_flavor.is_some_and(|f| f.is_unstable());
2985+
if !using_mcp510 && !unstable_use_lld {
2986+
return;
2987+
}
2988+
29732989
// 1. Implement the "self-contained" part of this feature by adding rustc distribution
29742990
// directories to the tool's search path.
2975-
let self_contained_linker = sess.opts.cg.link_self_contained.linker() || unstable_use_lld;
2976-
if self_contained_linker {
2991+
if self_contained_linker || unstable_use_lld {
29772992
for path in sess.get_tools_search_paths(false) {
29782993
cmd.arg({
29792994
let mut arg = OsString::from("-B");

0 commit comments

Comments
 (0)