1
Fork 0

make CLI linker features influence the linker flavor

While they're isomorphic, we can flip the lld component where
applicable, so that downstream doesn't have to check both the flavor and
the linker features.
This commit is contained in:
Rémy Rakic 2024-04-12 09:40:12 +00:00
parent 2398d8cf08
commit 11b6d40a98
2 changed files with 49 additions and 2 deletions

View file

@ -448,6 +448,28 @@ impl LinkerFlavor {
| LinkerFlavor::Ptx => false,
}
}
/// For flavors with an `Lld` component, ensure it's enabled. Otherwise, returns the given
/// flavor unmodified.
pub fn with_lld_enabled(self) -> LinkerFlavor {
match self {
LinkerFlavor::Gnu(cc, Lld::No) => LinkerFlavor::Gnu(cc, Lld::Yes),
LinkerFlavor::Darwin(cc, Lld::No) => LinkerFlavor::Darwin(cc, Lld::Yes),
LinkerFlavor::Msvc(Lld::No) => LinkerFlavor::Msvc(Lld::Yes),
_ => self,
}
}
/// For flavors with an `Lld` component, ensure it's disabled. Otherwise, returns the given
/// flavor unmodified.
pub fn with_lld_disabled(self) -> LinkerFlavor {
match self {
LinkerFlavor::Gnu(cc, Lld::Yes) => LinkerFlavor::Gnu(cc, Lld::No),
LinkerFlavor::Darwin(cc, Lld::Yes) => LinkerFlavor::Darwin(cc, Lld::No),
LinkerFlavor::Msvc(Lld::Yes) => LinkerFlavor::Msvc(Lld::No),
_ => self,
}
}
}
macro_rules! linker_flavor_cli_impls {