rustbuild: Deduplicate LLD checks slightly

This commit is contained in:
Vadim Petrochenkov
2020-09-07 00:39:58 +03:00
parent 5118a51b4d
commit b27fca71d4
3 changed files with 13 additions and 10 deletions

View File

@@ -863,15 +863,19 @@ impl Build {
&& !target.contains("msvc")
{
Some(self.cc(target))
} else if target.contains("msvc") && self.config.use_lld && self.build == target {
// `rust.use_lld` means using LLD directly only for MSVC, for other targets it only
// adds `-fuse-ld=lld` to already selected linker.
} else if self.config.use_lld && !self.is_fuse_ld_lld(target) && self.build == target {
Some(&self.initial_lld)
} else {
None
}
}
// LLD is used through `-fuse-ld=lld` rather than directly.
// Only MSVC targets use LLD directly at the moment.
fn is_fuse_ld_lld(&self, target: TargetSelection) -> bool {
self.config.use_lld && !target.contains("msvc")
}
/// Returns if this target should statically link the C runtime, if specified
fn crt_static(&self, target: TargetSelection) -> Option<bool> {
if target.contains("pc-windows-msvc") {