Skip to content

Commit aecc1b1

Browse files
authored
[main] Get Swift-Foundation building against MUSL for Swift Static SDK (#848)
* Get FoundationEssentials building Adding the missing musl imports to get FoundationEssentials building for the Swift static SDKs again. Also providing an option to disable building the macros. The macros aren't necessary for building the library and will not be run as part of the static SDK. No need to bloat the SDK or build times further. For Swift 6, the macros should be provided by the toolchain since the toolchain and SDK are current revlocked due to swiftmodules. * Get FoundationInternationalization building Adding the missing Musl imports to get FoundationInternationalization building for the static SDK.
1 parent ad6ca71 commit aecc1b1

27 files changed

+67
-10
lines changed

Sources/FoundationEssentials/Calendar/Calendar.swift

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

Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift

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

Sources/FoundationEssentials/Data/Data+Reading.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import Darwin
2222
import Android
2323
#elseif canImport(Glibc)
2424
import Glibc
25+
#elseif canImport(Musl)
26+
import Musl
2527
#elseif os(Windows)
2628
import CRT
2729
import WinSDK
@@ -32,7 +34,7 @@ import WASILibc
3234
func _fgetxattr(_ fd: Int32, _ name: UnsafePointer<CChar>!, _ value: UnsafeMutableRawPointer!, _ size: Int, _ position: UInt32, _ options: Int32) -> Int {
3335
#if canImport(Darwin)
3436
return fgetxattr(fd, name, value, size, position, options)
35-
#elseif canImport(Glibc)
37+
#elseif canImport(Glibc) || canImport(Musl)
3638
return fgetxattr(fd, name, value, size)
3739
#else
3840
return -1

Sources/FoundationEssentials/Data/Data+Writing.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import Android
2424
import unistd
2525
#elseif canImport(Glibc)
2626
import Glibc
27+
#elseif canImport(Musl)
28+
import Musl
2729
#elseif os(Windows)
2830
import CRT
2931
import WinSDK
@@ -632,7 +634,7 @@ private func writeExtendedAttributes(fd: Int32, attributes: [String : Data]) {
632634
// Returns non-zero on error, but we ignore them
633635
#if canImport(Darwin)
634636
_ = fsetxattr(fd, key, valueBuf.baseAddress!, valueBuf.count, 0, 0)
635-
#elseif canImport(Glibc)
637+
#elseif canImport(Glibc) || canImport(Musl)
636638
_ = fsetxattr(fd, key, valueBuf.baseAddress!, valueBuf.count, 0)
637639
#endif
638640
}

Sources/FoundationEssentials/Date.swift

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

Sources/FoundationEssentials/Decimal/Decimal+Math.swift

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

Sources/FoundationEssentials/Error/CocoaError+FilePath.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import Darwin
1919
import Bionic
2020
#elseif canImport(Glibc)
2121
import Glibc
22+
#elseif canImport(Musl)
23+
import Musl
2224
#elseif os(Windows)
2325
import CRT
2426
import WinSDK

Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift

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

Sources/FoundationEssentials/FileManager/FileManager+Basics.swift

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

Sources/FoundationEssentials/FileManager/FileManager+Directories.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import Android
2323
import unistd
2424
#elseif canImport(Glibc)
2525
import Glibc
26+
#elseif canImport(Musl)
27+
import Musl
2628
#elseif os(Windows)
2729
import CRT
2830
import WinSDK

0 commit comments

Comments
 (0)