Skip to content

Commit 21a2b78

Browse files
authored
stdlib/benchmark: add canImport(Musl) where needed (#67120)
This allows compiling stdlib and benchmarks when targeting musl instead of Glibc.
1 parent 39a837c commit 21a2b78

File tree

18 files changed

+47
-8
lines changed

18 files changed

+47
-8
lines changed

benchmark/single-source/CString.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import TestsUtils
14-
#if os(Linux)
14+
#if canImport(Glibc)
1515
import Glibc
16+
#elseif canImport(Musl)
17+
import Musl
1618
#elseif os(Windows)
1719
import MSVCRT
1820
#else

benchmark/single-source/Radix2CooleyTukey.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
//
33
// Originally written by @owensd. Used with his permission.
44

5-
#if os(Linux)
5+
#if canImport(Glibc)
66
import Glibc
7+
#elseif canImport(Musl)
8+
import Musl
79
#elseif os(Windows)
810
import MSVCRT
911
#else

benchmark/single-source/StringEdits.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import TestsUtils
14-
#if os(Linux)
14+
#if canImport(Glibc)
1515
import Glibc
16+
#elseif canImport(Musl)
17+
import Musl
1618
#elseif os(Windows)
1719
import MSVCRT
1820
#else

benchmark/single-source/StringMatch.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import TestsUtils
14-
#if os(Linux)
14+
#if canImport(Glibc)
1515
import Glibc
16+
#elseif canImport(Musl)
17+
import Musl
1618
#elseif os(Windows)
1719
import MSVCRT
1820
#else

benchmark/single-source/Walsh.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import TestsUtils
14-
#if os(Linux)
14+
#if canImport(Glibc)
1515
import Glibc
16+
#elseif canImport(Musl)
17+
import Musl
1618
#elseif os(Windows)
1719
import MSVCRT
1820
#else

benchmark/utils/ArgParse.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if os(Linux)
13+
#if canImport(Glibc)
1414
import Glibc
15+
#elseif canImport(Musl)
16+
import Musl
1517
#elseif os(Windows)
1618
import MSVCRT
1719
#else

benchmark/utils/DriverUtils.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if os(Linux)
13+
#if canImport(Glibc)
1414
import Glibc
15+
#elseif canImport(Musl)
16+
import Musl
1517
#elseif os(Windows)
1618
import MSVCRT
1719
#else

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import SwiftPrivateThreadExtras
4343
import Darwin
4444
#elseif canImport(Glibc)
4545
import Glibc
46+
#elseif canImport(Musl)
47+
import Musl
4648
#elseif os(WASI)
4749
import WASILibc
4850
#elseif os(Windows)

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import SwiftPrivateLibcExtras
1616
import Darwin
1717
#elseif canImport(Glibc)
1818
import Glibc
19+
#elseif canImport(Musl)
20+
import Musl
1921
#elseif os(WASI)
2022
import WASILibc
2123
#elseif os(Windows)

stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import Foundation
2222
import Darwin
2323
#elseif canImport(Glibc)
2424
import Glibc
25+
#elseif canImport(Musl)
26+
import Musl
2527
#elseif os(Windows)
2628
import CRT
2729
import WinSDK

stdlib/private/SwiftPrivate/IO.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ let (platform_read, platform_write, platform_close) = (read, write, close)
1919
#elseif canImport(Glibc)
2020
import Glibc
2121
let (platform_read, platform_write, platform_close) = (read, write, close)
22+
#elseif canImport(Musl)
23+
import Musl
24+
let (platform_read, platform_write, platform_close) = (read, write, close)
2225
#elseif os(Windows)
2326
import CRT
2427
import WinSDK

stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import SwiftPrivate
1515
import Darwin
1616
#elseif canImport(Glibc)
1717
import Glibc
18+
#elseif canImport(Musl)
19+
import Musl
1820
#elseif os(WASI)
1921
import WASILibc
2022
#elseif os(Windows)

stdlib/private/SwiftPrivateLibcExtras/SwiftPrivateLibcExtras.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import SwiftPrivate
1515
import Darwin
1616
#elseif canImport(Glibc)
1717
import Glibc
18+
#elseif canImport(Musl)
19+
import Musl
1820
#elseif os(WASI)
1921
import WASILibc
2022
#elseif os(Windows)

stdlib/private/SwiftPrivateThreadExtras/SwiftPrivateThreadExtras.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import Darwin
2020
#elseif canImport(Glibc)
2121
import Glibc
22+
#elseif canImport(Musl)
23+
import Musl
2224
#elseif os(WASI)
2325
import WASILibc
2426
#elseif os(Windows)
@@ -69,7 +71,7 @@ public typealias ThreadHandle = HANDLE
6971
#else
7072
public typealias ThreadHandle = pthread_t
7173

72-
#if os(Linux) || os(Android)
74+
#if (os(Linux) && !canImport(Musl)) || os(Android)
7375
internal func _make_pthread_t() -> pthread_t {
7476
return pthread_t()
7577
}

stdlib/private/SwiftPrivateThreadExtras/ThreadBarriers.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import Darwin
1515
#elseif canImport(Glibc)
1616
import Glibc
17+
#elseif canImport(Musl)
18+
import Musl
1719
#elseif os(WASI)
1820
import WASILibc
1921
#elseif os(Windows)

stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ internal func getImageCount() -> UInt32 {
127127
let rtldDefault = UnsafeMutableRawPointer(bitPattern: Int(-2))
128128
#elseif !os(Windows)
129129
import SwiftShims
130+
#if canImport(Glibc)
130131
import Glibc
132+
#elseif canImport(Musl)
133+
import Musl
134+
#endif
131135

132136
let rtldDefault: UnsafeMutableRawPointer? = nil
133137

stdlib/public/Differentiation/TgmathDerivatives.swift.gyb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import Swift
1616

1717
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
1818
import Darwin.C.tgmath
19+
#elseif canImport(Musl)
20+
import Musl
1921
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
2022
import Glibc
2123
#elseif os(WASI)

stdlib/public/Distributed/LocalTestingDistributedActorSystem.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import Swift
1616
import Darwin
1717
#elseif canImport(Glibc)
1818
import Glibc
19+
#elseif canImport(Musl)
20+
import Musl
1921
#elseif os(Windows)
2022
import WinSDK
2123
#endif

0 commit comments

Comments
 (0)