diff --git a/schemes/release-6.0/manifest.json b/schemes/release-6.0/manifest.json index 30a002a2..aa4b0e6a 100644 --- a/schemes/release-6.0/manifest.json +++ b/schemes/release-6.0/manifest.json @@ -1,6 +1,6 @@ { "update-checkout-scheme": "release/6.0", - "base-tag": "swift-6.0-DEVELOPMENT-SNAPSHOT-2024-08-22-a", + "base-tag": "swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a", "build-compiler": false, "icu4c": ["https://github.com/swiftwasm/icu4c-wasi/releases/download/0.8.0/icu4c-wasi.tar.xz"], "libxml2": ["https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz"], diff --git a/schemes/release-6.0/swift-corelibs-foundation/0001-build-Repair-the-build-on-WASI-platform.patch b/schemes/release-6.0/swift-corelibs-foundation/0001-build-Repair-the-build-on-WASI-platform.patch deleted file mode 100644 index 6f48c2eb..00000000 --- a/schemes/release-6.0/swift-corelibs-foundation/0001-build-Repair-the-build-on-WASI-platform.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 4db45e0b9c75e3a6ac31cf45a06018592af381f5 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 30 Mar 2024 10:28:40 +0000 -Subject: [PATCH] build: Repair the build on WASI platform - -Cherry picked from https://github.com/apple/swift-corelibs-foundation/pull/4934 - -(cherry picked from commit 51ee6906be0556eb63cd35a16ad4167f69f16a63) ---- - Package.swift | 20 ++++++++++++++++++-- - Sources/CoreFoundation/CFBundle.c | 8 +++++++- - Sources/CoreFoundation/CFString.c | 2 +- - 3 files changed, 26 insertions(+), 4 deletions(-) - -diff --git a/Package.swift b/Package.swift -index 6d660388..4949fe4e 100644 ---- a/Package.swift -+++ b/Package.swift -@@ -3,6 +3,16 @@ - - import PackageDescription - -+let platformsWithThreads: [Platform] = [ -+ .iOS, -+ .macOS, -+ .tvOS, -+ .watchOS, -+ .macCatalyst, -+ .driverKit, -+ .android, -+ .linux, -+] - var dispatchIncludeFlags: [CSetting] - if let environmentPath = Context.environment["DISPATCH_INCLUDE_PATH"] { - dispatchIncludeFlags = [.unsafeFlags([ -@@ -31,8 +41,11 @@ let coreFoundationBuildSettings: [CSetting] = [ - .define("DEPLOYMENT_ENABLE_LIBDISPATCH"), - .define("DEPLOYMENT_RUNTIME_SWIFT"), - .define("HAVE_STRUCT_TIMESPEC"), -- .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS"), -+ .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS", .when(platforms: platformsWithThreads)), - .define("_GNU_SOURCE", .when(platforms: [.linux, .android])), -+ .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])), -+ .define("HAVE_STRLCPY", .when(platforms: [.wasi])), -+ .define("HAVE_STRLCAT", .when(platforms: [.wasi])), - .unsafeFlags([ - "-Wno-shorten-64-to-32", - "-Wno-deprecated-declarations", -@@ -61,8 +74,11 @@ let interfaceBuildSettings: [CSetting] = [ - .define("CF_BUILDING_CF"), - .define("DEPLOYMENT_ENABLE_LIBDISPATCH"), - .define("HAVE_STRUCT_TIMESPEC"), -- .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS"), -+ .define("SWIFT_CORELIBS_FOUNDATION_HAS_THREADS", .when(platforms: platformsWithThreads)), - .define("_GNU_SOURCE", .when(platforms: [.linux, .android])), -+ .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])), -+ .define("HAVE_STRLCPY", .when(platforms: [.wasi])), -+ .define("HAVE_STRLCAT", .when(platforms: [.wasi])), - .unsafeFlags([ - "-Wno-shorten-64-to-32", - "-Wno-deprecated-declarations", -diff --git a/Sources/CoreFoundation/CFBundle.c b/Sources/CoreFoundation/CFBundle.c -index 8026a262..05afe988 100644 ---- a/Sources/CoreFoundation/CFBundle.c -+++ b/Sources/CoreFoundation/CFBundle.c -@@ -596,7 +596,13 @@ static CFBundleRef _CFBundleGetBundleWithIdentifier(CFStringRef bundleID, void * - - CFBundleRef CFBundleGetBundleWithIdentifier(CFStringRef bundleID) { - // Use the frame that called this as a hint -- return _CFBundleGetBundleWithIdentifier(bundleID, __builtin_return_address(0)); -+ void *hint; -+#if TARGET_OS_WASI -+ hint = NULL; -+#else -+ hint = __builtin_frame_address(0); -+#endif -+ return _CFBundleGetBundleWithIdentifier(bundleID, hint); - } - - CFBundleRef _CFBundleGetBundleWithIdentifierWithHint(CFStringRef bundleID, void *pointer) { -diff --git a/Sources/CoreFoundation/CFString.c b/Sources/CoreFoundation/CFString.c -index 1de46dac..94a6c86d 100644 ---- a/Sources/CoreFoundation/CFString.c -+++ b/Sources/CoreFoundation/CFString.c -@@ -28,7 +28,7 @@ - #include "CFRuntime_Internal.h" - #include - #include <_foundation_unicode/uchar.h> --#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD -+#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_WASI - #include "CFConstantKeys.h" - #include "CFStringLocalizedFormattingInternal.h" - #endif --- -2.43.2 - diff --git a/schemes/release-6.0/swift-corelibs-foundation/0002-Reflect-Package.swift-WASI-changes-in-CMakeLists.txt.patch b/schemes/release-6.0/swift-corelibs-foundation/0002-Reflect-Package.swift-WASI-changes-in-CMakeLists.txt.patch deleted file mode 100644 index 03d9392b..00000000 --- a/schemes/release-6.0/swift-corelibs-foundation/0002-Reflect-Package.swift-WASI-changes-in-CMakeLists.txt.patch +++ /dev/null @@ -1,66 +0,0 @@ -From f8c20b56988da0f649c1645dd4e0ea18af739b95 Mon Sep 17 00:00:00 2001 -From: Max Desiatov -Date: Mon, 5 Aug 2024 20:28:46 +0100 -Subject: [PATCH] Reflect `Package.swift` WASI changes in `CMakeLists.txt` - ---- - CMakeLists.txt | 26 ++++++++++++++++++++++++-- - 1 file changed, 24 insertions(+), 2 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 7f290d16..1fbdee6a 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -146,7 +146,6 @@ list(APPEND _Foundation_common_build_flags - "-DCF_BUILDING_CF" - "-DDEPLOYMENT_ENABLE_LIBDISPATCH" - "-DHAVE_STRUCT_TIMESPEC" -- "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" - "-Wno-shorten-64-to-32" - "-Wno-deprecated-declarations" - "-Wno-unreachable-code" -@@ -158,6 +157,18 @@ list(APPEND _Foundation_common_build_flags - "-Wno-switch" - "-fblocks") - -+if(CMAKE_SYSTEM_NAME STREQUAL "WASI") -+ list(APPEND _Foundation_common_build_flags -+ "-D_WASI_EMULATED_SIGNAL" -+ "-DHAVE_STRLCPY" -+ "-DHAVE_STRLCAT" -+ ) -+else() -+ list(APPEND _Foundation_common_build_flags -+ "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" -+ ) -+endif() -+ - if(NOT "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") - list(APPEND _Foundation_common_build_flags - "-fconstant-cfstrings" -@@ -185,10 +196,21 @@ set(_Foundation_swift_build_flags) - list(APPEND _Foundation_swift_build_flags - "-swift-version 6" - "-DDEPLOYMENT_RUNTIME_SWIFT" -- "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" - "-Xfrontend" - "-require-explicit-sendable") - -+if(CMAKE_SYSTEM_NAME STREQUAL "WASI") -+ list(APPEND _Foundation_swift_build_flags -+ "-D_WASI_EMULATED_SIGNAL" -+ "-DHAVE_STRLCPY" -+ "-DHAVE_STRLCAT" -+ ) -+else() -+ list(APPEND _Foundation_swift_build_flags -+ "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" -+ ) -+endif() -+ - if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") - list(APPEND _Foundation_common_build_flags - "-D_GNU_SOURCE") --- -2.43.2 - diff --git a/schemes/release-6.0/swift-corelibs-foundation/0003-Add-.windows-to-platformsWithThreads-in-Package.swif.patch b/schemes/release-6.0/swift-corelibs-foundation/0003-Add-.windows-to-platformsWithThreads-in-Package.swif.patch deleted file mode 100644 index 6f6b87e7..00000000 --- a/schemes/release-6.0/swift-corelibs-foundation/0003-Add-.windows-to-platformsWithThreads-in-Package.swif.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0c954d9de286e15204240722d717e1928e165cbb Mon Sep 17 00:00:00 2001 -From: Max Desiatov -Date: Mon, 5 Aug 2024 20:16:22 +0100 -Subject: [PATCH] Add `.windows` to `platformsWithThreads` in `Package.swift` - -(cherry picked from commit bc0dd484adbabdb978e68cf6905e3b44ca5117bd) ---- - Package.swift | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Package.swift b/Package.swift -index 4949fe4e..aca50e80 100644 ---- a/Package.swift -+++ b/Package.swift -@@ -12,6 +12,7 @@ let platformsWithThreads: [Platform] = [ - .driverKit, - .android, - .linux, -+ .windows, - ] - var dispatchIncludeFlags: [CSetting] - if let environmentPath = Context.environment["DISPATCH_INCLUDE_PATH"] { --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0001-Use-platform-shims-for-clock-ids-to-support-wasi-lib.patch b/schemes/release-6.0/swift-foundation/0001-Use-platform-shims-for-clock-ids-to-support-wasi-lib.patch index dea99c47..692b7f4d 100644 --- a/schemes/release-6.0/swift-foundation/0001-Use-platform-shims-for-clock-ids-to-support-wasi-lib.patch +++ b/schemes/release-6.0/swift-foundation/0001-Use-platform-shims-for-clock-ids-to-support-wasi-lib.patch @@ -86,7 +86,7 @@ index 911fc9e..9c7e959 100644 --- a/Sources/_FoundationCShims/include/platform_shims.h +++ b/Sources/_FoundationCShims/include/platform_shims.h @@ -68,4 +68,17 @@ typedef enum { - INTERNAL const char * _Nonnull _platform_shims_kOSThermalNotificationPressureLevelName(); + INTERNAL const char * _Nonnull _platform_shims_kOSThermalNotificationPressureLevelName(void); #endif +#if TARGET_OS_WASI diff --git a/schemes/release-6.0/swift-foundation/0002-Add-explicit-include-of-wasi-libc-environ.h-786.patch b/schemes/release-6.0/swift-foundation/0002-Add-explicit-include-of-wasi-libc-environ.h-786.patch deleted file mode 100644 index b6c57c58..00000000 --- a/schemes/release-6.0/swift-foundation/0002-Add-explicit-include-of-wasi-libc-environ.h-786.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 32526a30ecfb17d64f60dcf4658e2c5f8b745628 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 00:50:27 +0900 -Subject: [PATCH] Add explicit include of `wasi/libc-environ.h` (#786) - -This is necessary to get the `__wasilibc_get_environ` function -declaration. - -(cherry picked from commit 243066f12d0b6f1ab8ad9fefd8526b2383641892) ---- - Sources/_FoundationCShims/platform_shims.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/Sources/_FoundationCShims/platform_shims.c b/Sources/_FoundationCShims/platform_shims.c -index 5a400a4..6f79224 100644 ---- a/Sources/_FoundationCShims/platform_shims.c -+++ b/Sources/_FoundationCShims/platform_shims.c -@@ -21,6 +21,10 @@ - extern char **environ; - #endif - -+#if __wasi__ -+#include // for __wasilibc_get_environ -+#endif -+ - #if __has_include() - #import - void _platform_shims_lock_environ() { --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0003-Add-explicit-void-type-parameter-to-C-functions-with.patch b/schemes/release-6.0/swift-foundation/0003-Add-explicit-void-type-parameter-to-C-functions-with.patch deleted file mode 100644 index 8e185d42..00000000 --- a/schemes/release-6.0/swift-foundation/0003-Add-explicit-void-type-parameter-to-C-functions-with.patch +++ /dev/null @@ -1,109 +0,0 @@ -From a415338a471ec82fcd6fab4e4905b927f5165cc3 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:02:11 +0900 -Subject: [PATCH] Add explicit void type parameter to C functions without - parameters (#775) - -C functions with `()` as parameter list can take any number of -parameters. But WebAssembly requires static signature information for -every function call, so we need to explicitly specify `(void)` to -indicate that the function takes no parameters. ---- - .../_FoundationCShims/include/platform_shims.h | 12 ++++++------ - Sources/_FoundationCShims/platform_shims.c | 16 ++++++++-------- - 2 files changed, 14 insertions(+), 14 deletions(-) - -diff --git a/Sources/_FoundationCShims/include/platform_shims.h b/Sources/_FoundationCShims/include/platform_shims.h -index 9c7e959..f45f5fd 100644 ---- a/Sources/_FoundationCShims/include/platform_shims.h -+++ b/Sources/_FoundationCShims/include/platform_shims.h -@@ -31,19 +31,19 @@ - #include - #endif - --INTERNAL char * _Nullable * _Nullable _platform_shims_get_environ(); -+INTERNAL char * _Nullable * _Nullable _platform_shims_get_environ(void); - --INTERNAL void _platform_shims_lock_environ(); --INTERNAL void _platform_shims_unlock_environ(); -+INTERNAL void _platform_shims_lock_environ(void); -+INTERNAL void _platform_shims_unlock_environ(void); - - #if __has_include() - #include --INTERNAL vm_size_t _platform_shims_vm_size(); -+INTERNAL vm_size_t _platform_shims_vm_size(void); - #endif - - #if __has_include() - #include --INTERNAL mach_port_t _platform_mach_task_self(); -+INTERNAL mach_port_t _platform_mach_task_self(void); - #endif - - #if __has_include() -@@ -65,7 +65,7 @@ typedef enum { - } _platform_shims_OSThermalPressureLevel; - - --INTERNAL const char * _Nonnull _platform_shims_kOSThermalNotificationPressureLevelName(); -+INTERNAL const char * _Nonnull _platform_shims_kOSThermalNotificationPressureLevelName(void); - #endif - - #if TARGET_OS_WASI -diff --git a/Sources/_FoundationCShims/platform_shims.c b/Sources/_FoundationCShims/platform_shims.c -index 6f79224..556bc94 100644 ---- a/Sources/_FoundationCShims/platform_shims.c -+++ b/Sources/_FoundationCShims/platform_shims.c -@@ -27,19 +27,19 @@ extern char **environ; - - #if __has_include() - #import --void _platform_shims_lock_environ() { -+void _platform_shims_lock_environ(void) { - environ_lock_np(); - } - --void _platform_shims_unlock_environ() { -+void _platform_shims_unlock_environ(void) { - environ_unlock_np(); - } - #else --void _platform_shims_lock_environ() { /* noop */ } --void _platform_shims_unlock_environ() { /* noop */ } -+void _platform_shims_lock_environ(void) { /* noop */ } -+void _platform_shims_unlock_environ(void) { /* noop */ } - #endif - --char ** _platform_shims_get_environ() { -+char ** _platform_shims_get_environ(void) { - #if __has_include() - return *_NSGetEnviron(); - #elif defined(_WIN32) -@@ -52,20 +52,20 @@ char ** _platform_shims_get_environ() { - } - - #if __has_include() --const char * _platform_shims_kOSThermalNotificationPressureLevelName() { -+const char * _platform_shims_kOSThermalNotificationPressureLevelName(void) { - return kOSThermalNotificationPressureLevelName; - } - #endif - - #if __has_include() --vm_size_t _platform_shims_vm_size() { -+vm_size_t _platform_shims_vm_size(void) { - // This shim exists because vm_page_size is not marked const, and therefore looks like global mutable state to Swift. - return vm_page_size; - } - #endif - - #if __has_include() --mach_port_t _platform_mach_task_self() { -+mach_port_t _platform_mach_task_self(void) { - // This shim exists because mach_task_self_ is not marked const, and therefore looks like global mutable state to Swift. - return mach_task_self(); - } --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0004-wasm-Fall-back-to-a-default-chunk-size-when-st_blksi.patch b/schemes/release-6.0/swift-foundation/0004-wasm-Fall-back-to-a-default-chunk-size-when-st_blksi.patch index f1819565..e9a0e5e0 100644 --- a/schemes/release-6.0/swift-foundation/0004-wasm-Fall-back-to-a-default-chunk-size-when-st_blksi.patch +++ b/schemes/release-6.0/swift-foundation/0004-wasm-Fall-back-to-a-default-chunk-size-when-st_blksi.patch @@ -31,7 +31,7 @@ index 03adcc6..71ef113 100644 + } var current: off_t = 0 - while current < total { + #if os(WASI) -- 2.43.2 diff --git a/schemes/release-6.0/swift-foundation/0006-Enable-wasi-libc-emulation-features-777.patch b/schemes/release-6.0/swift-foundation/0006-Enable-wasi-libc-emulation-features-777.patch deleted file mode 100644 index 652c5929..00000000 --- a/schemes/release-6.0/swift-foundation/0006-Enable-wasi-libc-emulation-features-777.patch +++ /dev/null @@ -1,166 +0,0 @@ -From f2e4534e75a972a96b802dc682e870f142b72fe9 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Tue, 6 Aug 2024 02:20:54 +0900 -Subject: [PATCH] Enable wasi-libc emulation features (#777) - -* Enable wasi-libc emulation features - -Those features require explicit macro definitions to be enabled, so add -them to the package definition. Only affects WASI builds. - -* Prefer `TARGET_OS_WASI` over `__wasi__` - -And explain why we need definition checks for `signal.h` and `sys/mman.h` ---- - CMakeLists.txt | 8 +++++ - Package.swift | 35 ++++++++++++++----- - Sources/FoundationEssentials/CMakeLists.txt | 1 + - .../CMakeLists.txt | 1 + - Sources/_FoundationCShims/include/_CStdlib.h | 16 ++++++++- - 5 files changed, 51 insertions(+), 10 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a8dc410..3243e53 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -116,6 +116,14 @@ foreach(version ${_SwiftFoundation_versions}) - endforeach() - endforeach() - -+# wasi-libc emulation feature flags -+set(_SwiftFoundation_wasi_libc_flags) -+if(CMAKE_SYSTEM_NAME STREQUAL "WASI") -+ list(APPEND _SwiftFoundation_wasi_libc_flags -+ "SHELL:$<$:-Xcc -D_WASI_EMULATED_SIGNAL>" -+ "SHELL:$<$:-Xcc -D_WASI_EMULATED_MMAN>") -+endif() -+ - include(GNUInstallDirs) - include(SwiftFoundationSwiftSupport) - -diff --git a/Package.swift b/Package.swift -index daaf638..67bce50 100644 ---- a/Package.swift -+++ b/Package.swift -@@ -70,6 +70,11 @@ var dependencies: [Package.Dependency] { - } - } - -+let wasiLibcCSettings: [CSetting] = [ -+ .define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])), -+ .define("_WASI_EMULATED_MMAN", .when(platforms: [.wasi])), -+] -+ - let package = Package( - name: "FoundationPreview", - platforms: [.macOS("13.3"), .iOS("16.4"), .tvOS("16.4"), .watchOS("9.4")], -@@ -91,15 +96,23 @@ let package = Package( - path: "Sources/Foundation"), - - // _FoundationCShims (Internal) -- .target(name: "_FoundationCShims", -- cSettings: [.define("_CRT_SECURE_NO_WARNINGS", -- .when(platforms: [.windows]))]), -+ .target( -+ name: "_FoundationCShims", -+ cSettings: [ -+ .define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])) -+ ] + wasiLibcCSettings -+ ), - - // TestSupport (Internal) -- .target(name: "TestSupport", dependencies: [ -- "FoundationEssentials", -- "FoundationInternationalization", -- ], swiftSettings: availabilityMacros + concurrencyChecking), -+ .target( -+ name: "TestSupport", -+ dependencies: [ -+ "FoundationEssentials", -+ "FoundationInternationalization", -+ ], -+ cSettings: wasiLibcCSettings, -+ swiftSettings: availabilityMacros + concurrencyChecking -+ ), - - // FoundationEssentials - .target( -@@ -130,11 +143,14 @@ let package = Package( - ], - cSettings: [ - .define("_GNU_SOURCE", .when(platforms: [.linux])) -- ], -+ ] + wasiLibcCSettings, - swiftSettings: [ - .enableExperimentalFeature("VariadicGenerics"), - .enableExperimentalFeature("AccessLevelOnImport") -- ] + availabilityMacros + concurrencyChecking -+ ] + availabilityMacros + concurrencyChecking, -+ linkerSettings: [ -+ .linkedLibrary("wasi-emulated-getpid", .when(platforms: [.wasi])), -+ ] - ), - .testTarget( - name: "FoundationEssentialsTests", -@@ -166,6 +182,7 @@ let package = Package( - "CMakeLists.txt", - "Predicate/CMakeLists.txt" - ], -+ cSettings: wasiLibcCSettings, - swiftSettings: [ - .enableExperimentalFeature("AccessLevelOnImport") - ] + availabilityMacros + concurrencyChecking -diff --git a/Sources/FoundationEssentials/CMakeLists.txt b/Sources/FoundationEssentials/CMakeLists.txt -index 617ef2f..98c419a 100644 ---- a/Sources/FoundationEssentials/CMakeLists.txt -+++ b/Sources/FoundationEssentials/CMakeLists.txt -@@ -66,6 +66,7 @@ target_compile_options(FoundationEssentials PRIVATE - "SHELL:$<$:-Xfrontend -enable-experimental-feature -Xfrontend StrictConcurrency>" - "SHELL:$<$:-Xfrontend -enable-upcoming-feature -Xfrontend InferSendableFromCaptures>") - target_compile_options(FoundationEssentials PRIVATE ${_SwiftFoundation_availability_macros}) -+target_compile_options(FoundationEssentials PRIVATE ${_SwiftFoundation_wasi_libc_flags}) - target_compile_options(FoundationEssentials PRIVATE -package-name "SwiftFoundation") - - target_link_libraries(FoundationEssentials PUBLIC -diff --git a/Sources/FoundationInternationalization/CMakeLists.txt b/Sources/FoundationInternationalization/CMakeLists.txt -index 5a89ceb..857db9c 100644 ---- a/Sources/FoundationInternationalization/CMakeLists.txt -+++ b/Sources/FoundationInternationalization/CMakeLists.txt -@@ -33,6 +33,7 @@ target_compile_options(FoundationInternationalization PRIVATE - "SHELL:$<$:-Xfrontend -enable-experimental-feature -Xfrontend StrictConcurrency>" - "SHELL:$<$:-Xfrontend -enable-upcoming-feature -Xfrontend InferSendableFromCaptures>") - target_compile_options(FoundationInternationalization PRIVATE ${_SwiftFoundation_availability_macros}) -+target_compile_options(FoundationInternationalization PRIVATE ${_SwiftFoundation_wasi_libc_flags}) - target_compile_options(FoundationInternationalization PRIVATE -package-name "SwiftFoundation") - - target_link_libraries(FoundationInternationalization PUBLIC -diff --git a/Sources/_FoundationCShims/include/_CStdlib.h b/Sources/_FoundationCShims/include/_CStdlib.h -index 8967eb7..0337393 100644 ---- a/Sources/_FoundationCShims/include/_CStdlib.h -+++ b/Sources/_FoundationCShims/include/_CStdlib.h -@@ -60,7 +60,21 @@ - #endif - - #if __has_include() --#include -+/// Guard against including `signal.h` on WASI. The `signal.h` header file -+/// itself is available in wasi-libc, but it's just a stub that doesn't actually -+/// do anything. And also including it requires a special macro definition -+/// (`_WASI_EMULATED_SIGNAL`) and it causes compilation errors without the macro. -+# if !TARGET_OS_WASI || defined(_WASI_EMULATED_SIGNAL) -+# include -+# endif -+#endif -+ -+#if __has_include() -+/// Similar to `signal.h`, guard against including `sys/mman.h` on WASI unless -+/// `_WASI_EMULATED_MMAN` is enabled. -+# if !TARGET_OS_WASI || defined(_WASI_EMULATED_MMAN) -+# include -+# endif - #endif - - #if __has_include() --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0008-Guard-out-user-group-related-code-on-WASI-783.patch b/schemes/release-6.0/swift-foundation/0008-Guard-out-user-group-related-code-on-WASI-783.patch deleted file mode 100644 index 7a959909..00000000 --- a/schemes/release-6.0/swift-foundation/0008-Guard-out-user-group-related-code-on-WASI-783.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 1f5e0a8cc6e45e6be7a6d983877dbd602e5c0ff8 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:23:13 +0900 -Subject: [PATCH] Guard out user/group related code on WASI (#783) - -* Guard out user/group related code on WASI - -This change guards out the user/group related code on WASI, as WASI does -not have the concept of users or groups. - -* Throw explicit unsupported error if trying to set user or group on WASI - -Instead of implicitly ignoring user-given values, we should throw -exception to make it clear that those values cannot be set on WASI. ---- - Sources/FoundationEssentials/Data/Data+Writing.swift | 2 ++ - .../FoundationEssentials/FileManager/FileManager+Files.swift | 5 +++++ - .../FileManager/FileManager+Utilities.swift | 2 +- - .../FoundationEssentials/FileManager/FileOperations.swift | 2 ++ - Sources/FoundationEssentials/Platform.swift | 4 ++-- - Sources/FoundationEssentials/String/String+Path.swift | 2 ++ - 6 files changed, 14 insertions(+), 3 deletions(-) - -diff --git a/Sources/FoundationEssentials/Data/Data+Writing.swift b/Sources/FoundationEssentials/Data/Data+Writing.swift -index 1e75b43..78a9a98 100644 ---- a/Sources/FoundationEssentials/Data/Data+Writing.swift -+++ b/Sources/FoundationEssentials/Data/Data+Writing.swift -@@ -516,6 +516,7 @@ private func writeToFileAux(path inPath: PathOrURL, buffer: UnsafeRawBufferPoint - - cleanupTemporaryDirectory(at: temporaryDirectoryPath) - -+#if !os(WASI) // WASI does not support fchmod for now - if let mode { - // Try to change the mode if the path has not changed. Do our best, but don't report an error. - #if FOUNDATION_FRAMEWORK -@@ -539,6 +540,7 @@ private func writeToFileAux(path inPath: PathOrURL, buffer: UnsafeRawBufferPoint - fchmod(fd, mode) - #endif - } -+#endif // os(WASI) - } - } - } -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -index b8cd50a..943ac9e 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -@@ -928,6 +928,10 @@ extension _FileManagerImpl { - let groupID = _readFileAttributePrimitive(attributes[.groupOwnerAccountID], as: UInt.self) - - if user != nil || userID != nil || group != nil || groupID != nil { -+ #if os(WASI) -+ // WASI does not have the concept of users or groups -+ throw CocoaError.errorWithFilePath(.featureUnsupported, path) -+ #else - // Bias toward userID & groupID - try to prevent round trips to getpwnam if possible. - var leaveUnchanged: UInt32 { UInt32(bitPattern: -1) } - let rawUserID = userID.flatMap(uid_t.init) ?? user.flatMap(Self._userAccountNameToNumber) ?? leaveUnchanged -@@ -935,6 +939,7 @@ extension _FileManagerImpl { - if chown(fileSystemRepresentation, rawUserID, rawGroupID) != 0 { - throw CocoaError.errorWithFilePath(path, errno: errno, reading: false) - } -+ #endif - } - - try Self._setCatInfoAttributes(attributes, path: path) -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift b/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -index 9bac967..4f42f19 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -@@ -274,7 +274,7 @@ extension _FileManagerImpl { - } - #endif - --#if !os(Windows) -+#if !os(Windows) && !os(WASI) - static func _userAccountNameToNumber(_ name: String) -> uid_t? { - name.withCString { ptr in - getpwnam(ptr)?.pointee.pw_uid -diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift -index 528a7c9..8734fc0 100644 ---- a/Sources/FoundationEssentials/FileManager/FileOperations.swift -+++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift -@@ -874,12 +874,14 @@ enum _FileOperations { - } - defer { close(dstfd) } - -+ #if !os(WASI) // WASI doesn't have fchmod for now - // Set the file permissions using fchmod() instead of when open()ing to avoid umask() issues - let permissions = fileInfo.st_mode & ~S_IFMT - guard fchmod(dstfd, permissions) == 0 else { - try delegate.throwIfNecessary(errno, String(cString: srcPtr), String(cString: dstPtr)) - return - } -+ #endif - - if fileInfo.st_size == 0 { - // no copying required -diff --git a/Sources/FoundationEssentials/Platform.swift b/Sources/FoundationEssentials/Platform.swift -index 9c3f2d7..4549a45 100644 ---- a/Sources/FoundationEssentials/Platform.swift -+++ b/Sources/FoundationEssentials/Platform.swift -@@ -114,7 +114,7 @@ private let _cachedUGIDs: (uid_t, gid_t) = { - }() - #endif - --#if !os(Windows) -+#if !os(Windows) && !os(WASI) - extension Platform { - private static var ROOT_USER: UInt32 { 0 } - static func getUGIDs(allowEffectiveRootUID: Bool = true) -> (uid: UInt32, gid: UInt32) { -@@ -175,7 +175,7 @@ extension Platform { - // FIXME: bionic implements this as `return 0;` and does not expose the - // function via headers. We should be able to shim this and use the call - // if it is available. --#if !os(Android) -+#if !os(Android) && !os(WASI) - guard issetugid() == 0 else { return nil } - #endif - if let value = getenv(name) { -diff --git a/Sources/FoundationEssentials/String/String+Path.swift b/Sources/FoundationEssentials/String/String+Path.swift -index 477d5d3..aaf62d1 100644 ---- a/Sources/FoundationEssentials/String/String+Path.swift -+++ b/Sources/FoundationEssentials/String/String+Path.swift -@@ -452,6 +452,7 @@ extension String { - return envVar.standardizingPath - } - -+ #if !os(WASI) // WASI does not have user concept - // Next, attempt to find the home directory via getpwnam/getpwuid - var pass: UnsafeMutablePointer? - if let user { -@@ -465,6 +466,7 @@ extension String { - if let dir = pass?.pointee.pw_dir { - return String(cString: dir).standardizingPath - } -+ #endif - - // Fallback to HOME for the current user if possible - if user == nil, let home = getenv("HOME") { --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0009-Add-WASI-platform-conditions-for-libc-imports-and-wo.patch b/schemes/release-6.0/swift-foundation/0009-Add-WASI-platform-conditions-for-libc-imports-and-wo.patch deleted file mode 100644 index 7877e137..00000000 --- a/schemes/release-6.0/swift-foundation/0009-Add-WASI-platform-conditions-for-libc-imports-and-wo.patch +++ /dev/null @@ -1,354 +0,0 @@ -From 8e83fc7f48dc5410b7b3fabaf5b0deb121488cea Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Sat, 3 Aug 2024 01:55:56 +0900 -Subject: [PATCH] Add WASI platform conditions for libc imports and word size - (#776) - -* Add `import WASILibc` statements to libc import chains - -* Declare wasm32 arch as 32-bit environment - -* Switch to _pointerBitWidth for architecture checks - -This change switches the architecture checks in Data.swift to use the -_pointerBitWidth instead of the arch() checks for consistency with newer -platforms. ---- - .../FoundationEssentials/Calendar/Calendar.swift | 2 ++ - .../Calendar/Calendar_Gregorian.swift | 2 ++ - .../FoundationEssentials/Data/Data+Reading.swift | 2 ++ - .../FoundationEssentials/Data/Data+Writing.swift | 2 ++ - Sources/FoundationEssentials/Data/Data.swift | 14 ++++++++------ - Sources/FoundationEssentials/Date.swift | 2 ++ - .../Decimal/Decimal+Math.swift | 2 ++ - .../Error/CocoaError+FilePath.swift | 2 ++ - .../Error/ErrorCodes+POSIX.swift | 2 ++ - .../FileManager/FileManager+Basics.swift | 2 ++ - .../FileManager/FileManager+Directories.swift | 2 ++ - .../FileManager/FileManager+Files.swift | 3 +++ - .../FileManager/FileManager+SymbolicLinks.swift | 2 ++ - .../FileManager/FileManager+Utilities.swift | 2 ++ - .../FileManager/FileOperations.swift | 2 ++ - ...BinaryInteger+NumericStringRepresentation.swift | 2 ++ - .../ProcessInfo/ProcessInfo.swift | 2 ++ - .../PropertyList/OpenStepPlist.swift | 2 ++ - .../FoundationEssentials/String/String+Path.swift | 2 ++ - .../Calendar/Calendar_ICU.swift | 2 ++ - .../Formatting/Duration+Formatting.swift | 2 ++ - 21 files changed, 49 insertions(+), 6 deletions(-) - -diff --git a/Sources/FoundationEssentials/Calendar/Calendar.swift b/Sources/FoundationEssentials/Calendar/Calendar.swift -index 9de55b3..257b742 100644 ---- a/Sources/FoundationEssentials/Calendar/Calendar.swift -+++ b/Sources/FoundationEssentials/Calendar/Calendar.swift -@@ -20,6 +20,8 @@ import Glibc - import Musl - #elseif canImport(CRT) - import CRT -+#elseif os(WASI) -+import WASILibc - #endif - - #if FOUNDATION_FRAMEWORK -diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift -index 797a8e8..8c25c77 100644 ---- a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift -+++ b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift -@@ -20,6 +20,8 @@ import Glibc - import Musl - #elseif canImport(CRT) - import CRT -+#elseif os(WASI) -+import WASILibc - #endif - - -diff --git a/Sources/FoundationEssentials/Data/Data+Reading.swift b/Sources/FoundationEssentials/Data/Data+Reading.swift -index 2540b14..48b9521 100644 ---- a/Sources/FoundationEssentials/Data/Data+Reading.swift -+++ b/Sources/FoundationEssentials/Data/Data+Reading.swift -@@ -27,6 +27,8 @@ import Musl - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - func _fgetxattr(_ fd: Int32, _ name: UnsafePointer!, _ value: UnsafeMutableRawPointer!, _ size: Int, _ position: UInt32, _ options: Int32) -> Int { -diff --git a/Sources/FoundationEssentials/Data/Data+Writing.swift b/Sources/FoundationEssentials/Data/Data+Writing.swift -index 78a9a98..1acd412 100644 ---- a/Sources/FoundationEssentials/Data/Data+Writing.swift -+++ b/Sources/FoundationEssentials/Data/Data+Writing.swift -@@ -29,6 +29,8 @@ import Musl - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if !NO_FILESYSTEM -diff --git a/Sources/FoundationEssentials/Data/Data.swift b/Sources/FoundationEssentials/Data/Data.swift -index 8bded85..ad3ac42 100644 ---- a/Sources/FoundationEssentials/Data/Data.swift -+++ b/Sources/FoundationEssentials/Data/Data.swift -@@ -76,6 +76,8 @@ import Glibc - import Musl - #elseif canImport(ucrt) - import ucrt -+#elseif canImport(WASILibc) -+import WASILibc - #endif - - #if os(Windows) -@@ -580,11 +582,11 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect - @usableFromInline - @frozen - internal struct InlineData : Sendable { --#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) -+#if _pointerBitWidth(_64) - @usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, - UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) //len //enum - @usableFromInline var bytes: Buffer --#elseif arch(i386) || arch(arm) || arch(arm64_32) -+#elseif _pointerBitWidth(_32) - @usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, - UInt8, UInt8) //len //enum - @usableFromInline var bytes: Buffer -@@ -615,9 +617,9 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect - @inlinable // This is @inlinable as a trivial initializer. - init(count: Int = 0) { - assert(count <= MemoryLayout.size) --#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) -+#if _pointerBitWidth(_64) - bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0)) --#elseif arch(i386) || arch(arm) || arch(arm64_32) -+#elseif _pointerBitWidth(_32) - bytes = (UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0), UInt8(0)) - #else - #error ("Unsupported architecture: initialization for Buffer is required for this architecture") -@@ -802,9 +804,9 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect - } - } - --#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le) -+#if _pointerBitWidth(_64) - @usableFromInline internal typealias HalfInt = Int32 --#elseif arch(i386) || arch(arm) || arch(arm64_32) -+#elseif _pointerBitWidth(_32) - @usableFromInline internal typealias HalfInt = Int16 - #else - #error ("Unsupported architecture: a definition of half of the pointer sized Int needs to be defined for this architecture") -diff --git a/Sources/FoundationEssentials/Date.swift b/Sources/FoundationEssentials/Date.swift -index b65066f..37548e4 100644 ---- a/Sources/FoundationEssentials/Date.swift -+++ b/Sources/FoundationEssentials/Date.swift -@@ -20,6 +20,8 @@ import Glibc - import Musl - #elseif canImport(WinSDK) - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if !FOUNDATION_FRAMEWORK -diff --git a/Sources/FoundationEssentials/Decimal/Decimal+Math.swift b/Sources/FoundationEssentials/Decimal/Decimal+Math.swift -index 7b35f11..eb344b2 100644 ---- a/Sources/FoundationEssentials/Decimal/Decimal+Math.swift -+++ b/Sources/FoundationEssentials/Decimal/Decimal+Math.swift -@@ -20,6 +20,8 @@ import Glibc - import Musl - #elseif canImport(CRT) - import CRT -+#elseif os(WASI) -+import WASILibc - #endif - - private let powerOfTen: [Decimal.VariableLengthInteger] = [ -diff --git a/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift b/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift -index d9b2497..586c781 100644 ---- a/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift -+++ b/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift -@@ -24,6 +24,8 @@ import Musl - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - extension CocoaError.Code { -diff --git a/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift b/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -index 048cd29..c940a30 100644 ---- a/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -+++ b/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -@@ -21,6 +21,8 @@ - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if FOUNDATION_FRAMEWORK -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Basics.swift b/Sources/FoundationEssentials/FileManager/FileManager+Basics.swift -index 991c5e8..9896b35 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Basics.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Basics.swift -@@ -21,6 +21,8 @@ import Musl - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if os(Windows) -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift b/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift -index ed1b445..b987ee8 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift -@@ -28,6 +28,8 @@ import Musl - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - internal import _FoundationCShims -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -index 943ac9e..1999b6a 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -@@ -29,6 +29,9 @@ internal import _FoundationCShims - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+internal import _FoundationCShims -+import WASILibc - #endif - - extension Date { -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+SymbolicLinks.swift b/Sources/FoundationEssentials/FileManager/FileManager+SymbolicLinks.swift -index a1355e7..12d32e5 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+SymbolicLinks.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+SymbolicLinks.swift -@@ -23,6 +23,8 @@ import Musl - import CRT - import WinSDK - internal import _FoundationCShims -+#elseif os(WASI) -+import WASILibc - #endif - - extension _FileManagerImpl { -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift b/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -index 4f42f19..4d487b5 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -@@ -34,6 +34,8 @@ internal import _FoundationCShims - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if os(Windows) -diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift -index 8734fc0..6ba5bb7 100644 ---- a/Sources/FoundationEssentials/FileManager/FileOperations.swift -+++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift -@@ -21,6 +21,8 @@ import Musl - #elseif os(Windows) - import CRT - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if FOUNDATION_FRAMEWORK -diff --git a/Sources/FoundationEssentials/Formatting/BinaryInteger+NumericStringRepresentation.swift b/Sources/FoundationEssentials/Formatting/BinaryInteger+NumericStringRepresentation.swift -index 43e9fcd..663509d 100644 ---- a/Sources/FoundationEssentials/Formatting/BinaryInteger+NumericStringRepresentation.swift -+++ b/Sources/FoundationEssentials/Formatting/BinaryInteger+NumericStringRepresentation.swift -@@ -20,6 +20,8 @@ import Glibc - import Musl - #elseif os(Windows) - import CRT -+#elseif os(WASI) -+import WASILibc - #endif - - // MARK: - BinaryInteger + Numeric string representation -diff --git a/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift b/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift -index 30591b5..93eabb9 100644 ---- a/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift -+++ b/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift -@@ -23,6 +23,8 @@ import Glibc - import Musl - #elseif os(Windows) - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - #if !NO_PROCESS -diff --git a/Sources/FoundationEssentials/PropertyList/OpenStepPlist.swift b/Sources/FoundationEssentials/PropertyList/OpenStepPlist.swift -index c042820..61b6d80 100644 ---- a/Sources/FoundationEssentials/PropertyList/OpenStepPlist.swift -+++ b/Sources/FoundationEssentials/PropertyList/OpenStepPlist.swift -@@ -18,6 +18,8 @@ import Bionic - import Glibc - #elseif canImport(Musl) - import Musl -+#elseif os(WASI) -+import WASILibc - #endif - - #if canImport(CRT) -diff --git a/Sources/FoundationEssentials/String/String+Path.swift b/Sources/FoundationEssentials/String/String+Path.swift -index aaf62d1..7047b9b 100644 ---- a/Sources/FoundationEssentials/String/String+Path.swift -+++ b/Sources/FoundationEssentials/String/String+Path.swift -@@ -20,6 +20,8 @@ import Glibc - import Musl - #elseif os(Windows) - import WinSDK -+#elseif os(WASI) -+import WASILibc - #endif - - internal import _FoundationCShims -diff --git a/Sources/FoundationInternationalization/Calendar/Calendar_ICU.swift b/Sources/FoundationInternationalization/Calendar/Calendar_ICU.swift -index 0d3c371..01895b8 100644 ---- a/Sources/FoundationInternationalization/Calendar/Calendar_ICU.swift -+++ b/Sources/FoundationInternationalization/Calendar/Calendar_ICU.swift -@@ -24,6 +24,8 @@ import Musl - import CRT - #elseif canImport(Darwin) - import Darwin -+#elseif os(WASI) -+import WASILibc - #endif - - internal import _FoundationICU -diff --git a/Sources/FoundationInternationalization/Formatting/Duration+Formatting.swift b/Sources/FoundationInternationalization/Formatting/Duration+Formatting.swift -index a94f571..dfe2fad 100644 ---- a/Sources/FoundationInternationalization/Formatting/Duration+Formatting.swift -+++ b/Sources/FoundationInternationalization/Formatting/Duration+Formatting.swift -@@ -24,6 +24,8 @@ import Glibc - import Musl - #elseif os(Windows) - import CRT -+#elseif os(WASI) -+import WASILibc - #endif - - @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0010-Fix-operatingSystemVersion-on-WASI-782.patch b/schemes/release-6.0/swift-foundation/0010-Fix-operatingSystemVersion-on-WASI-782.patch deleted file mode 100644 index e3b56f2b..00000000 --- a/schemes/release-6.0/swift-foundation/0010-Fix-operatingSystemVersion-on-WASI-782.patch +++ /dev/null @@ -1,27 +0,0 @@ -From b68fa674093de0bc6225a299045dbd2ac4dcf340 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:15:23 +0900 -Subject: [PATCH] Fix `operatingSystemVersion` on WASI (#782) - -The `operatingSystemVersion` property type is a tuple but the it was -returning an `OperatingSystemVersion` instance on unknown platforms. ---- - Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift b/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift -index 93eabb9..74d60a4 100644 ---- a/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift -+++ b/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift -@@ -393,7 +393,7 @@ extension _ProcessInfo { - patch: Int(osVersionInfo.dwBuildNumber) - ) - #else -- return OperatingSystemVersion(majorVersion: -1, minorVersion: 0, patchVersion: 0) -+ return (major: -1, minor: 0, patch: 0) - #endif - } - --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0011-Implement-_copyRegularFile-for-WASI-without-sendfile.patch b/schemes/release-6.0/swift-foundation/0011-Implement-_copyRegularFile-for-WASI-without-sendfile.patch deleted file mode 100644 index 130ff6da..00000000 --- a/schemes/release-6.0/swift-foundation/0011-Implement-_copyRegularFile-for-WASI-without-sendfile.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 66bb63386eb0d3a1b9aba1759f9e0d965884eb4d Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 02:50:04 +0900 -Subject: [PATCH] Implement `_copyRegularFile` for WASI without `sendfile` - (#787) - -WASI doesn't have `sendfile`, so we need to implement the copy in user -space with `read` and `write`. It's not as efficient as `sendfile`, but -it's the best we can do. ---- - .../FileManager/FileOperations.swift | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift -index 6ba5bb7..41f0b65 100644 ---- a/Sources/FoundationEssentials/FileManager/FileOperations.swift -+++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift -@@ -903,12 +903,31 @@ enum _FileOperations { - } - var current: off_t = 0 - -+ #if os(WASI) -+ // WASI doesn't have sendfile, so we need to do it in user space with read/write -+ try withUnsafeTemporaryAllocation(of: UInt8.self, capacity: chunkSize) { buffer in -+ while current < total { -+ let readSize = Swift.min(total - Int(current), chunkSize) -+ let bytesRead = read(srcfd, buffer.baseAddress, readSize) -+ guard bytesRead >= 0 else { -+ try delegate.throwIfNecessary(errno, String(cString: srcPtr), String(cString: dstPtr)) -+ return -+ } -+ guard write(dstfd, buffer.baseAddress, bytesRead) == bytesRead else { -+ try delegate.throwIfNecessary(errno, String(cString: srcPtr), String(cString: dstPtr)) -+ return -+ } -+ current += off_t(bytesRead) -+ } -+ } -+ #else - while current < total { - guard sendfile(dstfd, srcfd, ¤t, Swift.min(total - Int(current), chunkSize)) != -1 else { - try delegate.throwIfNecessary(errno, String(cString: srcPtr), String(cString: dstPtr)) - return - } - } -+ #endif - } - #endif - --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0012-Guard-out-extended-or-fs-attributes-related-code-on-.patch b/schemes/release-6.0/swift-foundation/0012-Guard-out-extended-or-fs-attributes-related-code-on-.patch deleted file mode 100644 index 30988024..00000000 --- a/schemes/release-6.0/swift-foundation/0012-Guard-out-extended-or-fs-attributes-related-code-on-.patch +++ /dev/null @@ -1,79 +0,0 @@ -From d177f42ef0423eb2daacb0e2b32434214f766a78 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:20:05 +0900 -Subject: [PATCH] Guard out extended or fs attributes related code on WASI - (#784) - -This commit guards out the extended attributes and file system -attributes related code on WASI as WASI does not support these -features. Just return nothing or ignore the set request. ---- - .../FileManager/FileManager+Files.swift | 13 +++++++++++-- - .../FileManager/FileManager+Utilities.swift | 2 +- - 2 files changed, 12 insertions(+), 3 deletions(-) - -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -index 1999b6a..b1e6f34 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -@@ -497,7 +497,7 @@ extension _FileManagerImpl { - #endif - } - --#if !os(Windows) -+#if !os(Windows) && !os(WASI) - private func _extendedAttribute(_ key: UnsafePointer, at path: UnsafePointer, followSymlinks: Bool) throws -> Data? { - #if canImport(Darwin) - var size = getxattr(path, key, nil, 0, 0, followSymlinks ? 0 : XATTR_NOFOLLOW) -@@ -651,10 +651,11 @@ extension _FileManagerImpl { - - var attributes = statAtPath.fileAttributes - try? Self._catInfo(for: URL(filePath: path, directoryHint: .isDirectory), statInfo: statAtPath, into: &attributes) -- -+ #if !os(WASI) // WASI does not support extended attributes - if let extendedAttrs = try? _extendedAttributes(at: fsRep, followSymlinks: false) { - attributes[._extendedAttributes] = extendedAttrs - } -+ #endif - - #if !targetEnvironment(simulator) && FOUNDATION_FRAMEWORK - if statAtPath.isRegular || statAtPath.isDirectory { -@@ -716,6 +717,9 @@ extension _FileManagerImpl { - ] - } - } -+#elseif os(WASI) -+ // WASI does not support file system attributes -+ return [:] - #else - try fileManager.withFileSystemRepresentation(for: path) { rep in - guard let rep else { -@@ -948,7 +952,12 @@ extension _FileManagerImpl { - try Self._setCatInfoAttributes(attributes, path: path) - - if let extendedAttrs = attributes[.init("NSFileExtendedAttributes")] as? [String : Data] { -+ #if os(WASI) -+ // WASI does not support extended attributes -+ throw CocoaError.errorWithFilePath(.featureUnsupported, path) -+ #else - try Self._setAttributes(extendedAttrs, at: fileSystemRepresentation, followSymLinks: false) -+ #endif - } - - if let date = attributes[.modificationDate] as? Date { -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift b/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -index 4d487b5..036f50c 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Utilities.swift -@@ -178,7 +178,7 @@ extension _FileManagerImpl { - #endif - } - --#if !os(Windows) -+#if !os(Windows) && !os(WASI) - static func _setAttribute(_ key: UnsafePointer, value: Data, at path: UnsafePointer, followSymLinks: Bool) throws { - try value.withUnsafeBytes { buffer in - #if canImport(Darwin) --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0013-Skip-sticky-bit-check-in-isDeletableFile-on-WASI-785.patch b/schemes/release-6.0/swift-foundation/0013-Skip-sticky-bit-check-in-isDeletableFile-on-WASI-785.patch deleted file mode 100644 index 81fed4f2..00000000 --- a/schemes/release-6.0/swift-foundation/0013-Skip-sticky-bit-check-in-isDeletableFile-on-WASI-785.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 6e6fdb07fd6facfcf49e239a0cd118967026a764 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:30:17 +0900 -Subject: [PATCH] Skip sticky-bit check in `isDeletableFile` on WASI (#785) - -WASI does not surface the sticky bit and getuid, so we cannot check -whether the file is actually deletable before attempting to delete it. ---- - .../FoundationEssentials/FileManager/FileManager+Files.swift | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -index b1e6f34..9cd9752 100644 ---- a/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -+++ b/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -@@ -474,7 +474,7 @@ extension _FileManagerImpl { - parent = fileManager.currentDirectoryPath - } - --#if os(Windows) -+#if os(Windows) || os(WASI) - return fileManager.isWritableFile(atPath: parent) && fileManager.isWritableFile(atPath: path) - #else - guard fileManager.isWritableFile(atPath: parent), --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0014-Port-LockedState-and-_ThreadLocal-to-WASI-without-an.patch b/schemes/release-6.0/swift-foundation/0014-Port-LockedState-and-_ThreadLocal-to-WASI-without-an.patch deleted file mode 100644 index 99130cf8..00000000 --- a/schemes/release-6.0/swift-foundation/0014-Port-LockedState-and-_ThreadLocal-to-WASI-without-an.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 65d09d9b7a536833e3e57f7545dcfe7be5d02b24 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 05:57:20 +0900 -Subject: [PATCH] Port `LockedState` and `_ThreadLocal` to WASI without any - locking (#780) - ---- - Sources/FoundationEssentials/LockedState.swift | 9 +++++++++ - Sources/FoundationEssentials/_ThreadLocal.swift | 8 ++++++++ - 2 files changed, 17 insertions(+) - -diff --git a/Sources/FoundationEssentials/LockedState.swift b/Sources/FoundationEssentials/LockedState.swift -index 6eb9ad8..4e6aefa 100644 ---- a/Sources/FoundationEssentials/LockedState.swift -+++ b/Sources/FoundationEssentials/LockedState.swift -@@ -35,6 +35,9 @@ package struct LockedState { - typealias Primitive = pthread_mutex_t - #elseif canImport(WinSDK) - typealias Primitive = SRWLOCK -+#elseif os(WASI) -+ // WASI is single-threaded, so we don't need a lock. -+ typealias Primitive = Void - #endif - - typealias PlatformLock = UnsafeMutablePointer -@@ -47,6 +50,8 @@ package struct LockedState { - pthread_mutex_init(platformLock, nil) - #elseif canImport(WinSDK) - InitializeSRWLock(platformLock) -+#elseif os(WASI) -+ // no-op - #endif - } - -@@ -64,6 +69,8 @@ package struct LockedState { - pthread_mutex_lock(platformLock) - #elseif canImport(WinSDK) - AcquireSRWLockExclusive(platformLock) -+#elseif os(WASI) -+ // no-op - #endif - } - -@@ -74,6 +81,8 @@ package struct LockedState { - pthread_mutex_unlock(platformLock) - #elseif canImport(WinSDK) - ReleaseSRWLockExclusive(platformLock) -+#elseif os(WASI) -+ // no-op - #endif - } - } -diff --git a/Sources/FoundationEssentials/_ThreadLocal.swift b/Sources/FoundationEssentials/_ThreadLocal.swift -index aea9c41..ffe010c 100644 ---- a/Sources/FoundationEssentials/_ThreadLocal.swift -+++ b/Sources/FoundationEssentials/_ThreadLocal.swift -@@ -32,6 +32,8 @@ struct _ThreadLocal { - fileprivate typealias PlatformKey = tss_t - #elseif canImport(WinSDK) - fileprivate typealias PlatformKey = DWORD -+#elseif os(WASI) -+ fileprivate typealias PlatformKey = UnsafeMutablePointer - #endif - - struct Key { -@@ -48,6 +50,8 @@ struct _ThreadLocal { - self.key = key - #elseif canImport(WinSDK) - key = FlsAlloc(nil) -+#elseif os(WASI) -+ key = UnsafeMutablePointer.allocate(capacity: 1) - #endif - } - } -@@ -60,6 +64,8 @@ struct _ThreadLocal { - tss_get(key) - #elseif canImport(WinSDK) - FlsGetValue(key) -+#elseif os(WASI) -+ key.pointee - #endif - } - -@@ -70,6 +76,8 @@ struct _ThreadLocal { - tss_set(key, newValue) - #elseif canImport(WinSDK) - FlsSetValue(key, newValue) -+#elseif os(WASI) -+ key.pointee = newValue - #endif - } - } --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0015-Throw-.featureUnsupported-when-attempting-to-create-.patch b/schemes/release-6.0/swift-foundation/0015-Throw-.featureUnsupported-when-attempting-to-create-.patch deleted file mode 100644 index a0ac0f09..00000000 --- a/schemes/release-6.0/swift-foundation/0015-Throw-.featureUnsupported-when-attempting-to-create-.patch +++ /dev/null @@ -1,39 +0,0 @@ -From f8a181d7ffd5de758c0c57f00aa69016f3fecf0e Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:12:39 +0900 -Subject: [PATCH] Throw `.featureUnsupported` when attempting to create temp - files on WASI (#779) - -WASI does not have temp directory concept, and does not provide mktemp -family of functions, so attempting to create a temporary file should be -considered a feature unsupported. ---- - Sources/FoundationEssentials/Data/Data+Writing.swift | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/Sources/FoundationEssentials/Data/Data+Writing.swift b/Sources/FoundationEssentials/Data/Data+Writing.swift -index 1acd412..0256e51 100644 ---- a/Sources/FoundationEssentials/Data/Data+Writing.swift -+++ b/Sources/FoundationEssentials/Data/Data+Writing.swift -@@ -131,6 +131,10 @@ private func cleanupTemporaryDirectory(at inPath: String?) { - - /// Caller is responsible for calling `close` on the `Int32` file descriptor. - private func createTemporaryFile(at destinationPath: String, inPath: PathOrURL, prefix: String, options: Data.WritingOptions) throws -> (Int32, String) { -+#if os(WASI) -+ // WASI does not have temp directories -+ throw CocoaError(.featureUnsupported) -+#else - var directoryPath = destinationPath - if !directoryPath.isEmpty && directoryPath.last! != "/" { - directoryPath.append("/") -@@ -185,6 +189,7 @@ private func createTemporaryFile(at destinationPath: String, inPath: PathOrURL, - } - } - } while true -+#endif // os(WASI) - } - - /// Returns `(file descriptor, temporary file path, temporary directory path)` --- -2.43.2 - diff --git a/schemes/release-6.0/swift-foundation/0016-Exclude-EREMOTE-definition-for-WASI-platform-778.patch b/schemes/release-6.0/swift-foundation/0016-Exclude-EREMOTE-definition-for-WASI-platform-778.patch deleted file mode 100644 index 621c6a8a..00000000 --- a/schemes/release-6.0/swift-foundation/0016-Exclude-EREMOTE-definition-for-WASI-platform-778.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 5d333819a3ffb36996b4332750d5bd25c1ecea00 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Fri, 2 Aug 2024 01:06:57 +0900 -Subject: [PATCH] Exclude EREMOTE definition for WASI platform (#778) - -WASI does not define the EREMOTE error code. ---- - Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift b/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -index c940a30..e1bfffa 100644 ---- a/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -+++ b/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -@@ -469,11 +469,13 @@ extension POSIXError { - return .ESTALE - } - -+ #if !os(WASI) - /// Too many levels of remote in path. - public static var EREMOTE: POSIXErrorCode { - return .EREMOTE - } - #endif -+ #endif - - #if canImport(Darwin) - /// RPC struct is bad. --- -2.43.2 -