mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
infer linker flavor by linker name if it's sufficiently specific
This commit is contained in:
parent
eeb9035117
commit
c23bf48e4f
@ -303,15 +303,16 @@ impl LinkerFlavor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer_linker_hints(linker_stem: &str) -> (Option<Cc>, Option<Lld>) {
|
fn infer_linker_hints(linker_stem: &str) -> Result<Self, (Option<Cc>, Option<Lld>)> {
|
||||||
// Remove any version postfix.
|
// Remove any version postfix.
|
||||||
let stem = linker_stem
|
let stem = linker_stem
|
||||||
.rsplit_once('-')
|
.rsplit_once('-')
|
||||||
.and_then(|(lhs, rhs)| rhs.chars().all(char::is_numeric).then_some(lhs))
|
.and_then(|(lhs, rhs)| rhs.chars().all(char::is_numeric).then_some(lhs))
|
||||||
.unwrap_or(linker_stem);
|
.unwrap_or(linker_stem);
|
||||||
|
|
||||||
// GCC/Clang can have an optional target prefix.
|
if stem == "llvm-bitcode-linker" {
|
||||||
if stem == "emcc"
|
Ok(Self::Llbc)
|
||||||
|
} else if stem == "emcc" // GCC/Clang can have an optional target prefix.
|
||||||
|| stem == "gcc"
|
|| stem == "gcc"
|
||||||
|| stem.ends_with("-gcc")
|
|| stem.ends_with("-gcc")
|
||||||
|| stem == "g++"
|
|| stem == "g++"
|
||||||
@ -321,7 +322,7 @@ impl LinkerFlavor {
|
|||||||
|| stem == "clang++"
|
|| stem == "clang++"
|
||||||
|| stem.ends_with("-clang++")
|
|| stem.ends_with("-clang++")
|
||||||
{
|
{
|
||||||
(Some(Cc::Yes), Some(Lld::No))
|
Err((Some(Cc::Yes), Some(Lld::No)))
|
||||||
} else if stem == "wasm-ld"
|
} else if stem == "wasm-ld"
|
||||||
|| stem.ends_with("-wasm-ld")
|
|| stem.ends_with("-wasm-ld")
|
||||||
|| stem == "ld.lld"
|
|| stem == "ld.lld"
|
||||||
@ -329,11 +330,11 @@ impl LinkerFlavor {
|
|||||||
|| stem == "rust-lld"
|
|| stem == "rust-lld"
|
||||||
|| stem == "lld-link"
|
|| stem == "lld-link"
|
||||||
{
|
{
|
||||||
(Some(Cc::No), Some(Lld::Yes))
|
Err((Some(Cc::No), Some(Lld::Yes)))
|
||||||
} else if stem == "ld" || stem.ends_with("-ld") || stem == "link" {
|
} else if stem == "ld" || stem.ends_with("-ld") || stem == "link" {
|
||||||
(Some(Cc::No), Some(Lld::No))
|
Err((Some(Cc::No), Some(Lld::No)))
|
||||||
} else {
|
} else {
|
||||||
(None, None)
|
Err((None, None))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +358,10 @@ impl LinkerFlavor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_linker_hints(self, linker_stem: &str) -> LinkerFlavor {
|
pub fn with_linker_hints(self, linker_stem: &str) -> LinkerFlavor {
|
||||||
self.with_hints(LinkerFlavor::infer_linker_hints(linker_stem))
|
match LinkerFlavor::infer_linker_hints(linker_stem) {
|
||||||
|
Ok(linker_flavor) => linker_flavor,
|
||||||
|
Err(hints) => self.with_hints(hints),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_compatibility(self, cli: LinkerFlavorCli) -> Option<String> {
|
pub fn check_compatibility(self, cli: LinkerFlavorCli) -> Option<String> {
|
||||||
|
Loading…
Reference in New Issue
Block a user