Skip to content

Commit 97a028f

Browse files
committed
Add tests around Linux distribution detection.
* Add a series of tests for checking distribution logic.
1 parent 7b2534f commit 97a028f

File tree

2 files changed

+788
-4
lines changed

2 files changed

+788
-4
lines changed

Sources/SWBGenericUnixPlatform/Plugin.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@ struct GenericUnixSDKRegistryExtension: SDKRegistryExtension {
126126
defaultProperties = [:]
127127
}
128128

129-
if operatingSystem == .freebsd || (operatingSystem == .linux && operatingSystem.distribution?.kind == .amazon && operatingSystem.distribution?.version == "2") || operatingSystem != context.hostOperatingSystem {
130-
// FreeBSD is always LLVM-based, use lld
131-
// Amazon Linux 2 has a gold linker bug see: https://sourceware.org/bugzilla/show_bug.cgi?id=23016, use lld
132-
// or if we're cross-compiling, use lld
129+
let shouldUseLLD = {
130+
switch operatingSystem {
131+
case .freebsd:
132+
return true // FreeBSD is always LLVM-based.
133+
case .linux where operatingSystem.distribution?.kind == .amazon && operatingSystem.distribution?.version == "2":
134+
return true // Amazon Linux 2 has a gold linker bug see: https://sourceware.org/bugzilla/show_bug.cgi?id=23016.
135+
default:
136+
return operatingSystem != context.hostOperatingSystem // Cross-compiling
137+
}
138+
}()
139+
140+
if shouldUseLLD {
133141
defaultProperties["ALTERNATE_LINKER"] = "lld"
134142
}
135143

0 commit comments

Comments
 (0)