From 28fdcade79a0ed86f8453e3089a114d38a73e791 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 9 Oct 2022 12:46:23 +0400 Subject: [PATCH] rustc_target: Fix json target specs using LLD linker flavors in link args --- compiler/rustc_target/src/spec/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 9396d769dc702..8909cf33af911 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1739,11 +1739,15 @@ impl TargetOptions { self.lld_flavor_json, self.linker_is_gnu_json, ); - match linker_flavor { - LinkerFlavor::Gnu(_, Lld::Yes) - | LinkerFlavor::Darwin(_, Lld::Yes) - | LinkerFlavor::Msvc(Lld::Yes) => {} - _ => add_link_args_iter(args, linker_flavor, args_json.iter().cloned()), + // Normalize to no lld to avoid asserts. + let linker_flavor = match linker_flavor { + LinkerFlavor::Gnu(cc, _) => LinkerFlavor::Gnu(cc, Lld::No), + LinkerFlavor::Darwin(cc, _) => LinkerFlavor::Darwin(cc, Lld::No), + LinkerFlavor::Msvc(_) => LinkerFlavor::Msvc(Lld::No), + _ => linker_flavor, + }; + if !args.contains_key(&linker_flavor) { + add_link_args_iter(args, linker_flavor, args_json.iter().cloned()); } } }