Rollup merge of #102836 - petrochenkov:jsonspec, r=eholk

rustc_target: Fix json target specs using LLD linker flavors in link args

Fixes https://github.com/rust-lang/rust/pull/101988#issuecomment-1272407248 (a regression introduced by https://github.com/rust-lang/rust/pull/101988).
This commit is contained in:
Yuki Okushi 2022-10-13 09:41:25 +09:00 committed by GitHub
commit f4c9580c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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());
}
}
}