From 895fe3bd7a905e6bfdb375dcd996a7eee15dce8c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 10 May 2025 12:29:09 +0000 Subject: [PATCH 1/3] Update base tag for main to swift-DEVELOPMENT-SNAPSHOT-2025-05-08-a --- schemes/main/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemes/main/manifest.json b/schemes/main/manifest.json index 3f5998f..b33776c 100644 --- a/schemes/main/manifest.json +++ b/schemes/main/manifest.json @@ -1,5 +1,5 @@ { - "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2025-04-12-a", + "base-tag": "swift-DEVELOPMENT-SNAPSHOT-2025-05-08-a", "icu4c": [], "libxml2": [ "https://github.com/swiftwasm/libxml2-wasm/releases/download/2.0.0/libxml2-wasm32-unknown-wasi.tar.gz", From f40e2f09d1a2fe81fd08c6ebab3030f3bd04124e Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 11 May 2025 12:32:31 +0000 Subject: [PATCH 2/3] Remove upstreamed patches --- ...-write-option-usages-behind-platform.patch | 64 ------------------- ...equiring-TZDIR-and-TZDEFAULT-on-WASI.patch | 27 -------- 2 files changed, 91 deletions(-) delete mode 100644 schemes/main/swift-corelibs-foundation/0001-wasm-Gate-atomic-write-option-usages-behind-platform.patch delete mode 100644 schemes/main/swift-foundation/0001-wasm-Stop-requiring-TZDIR-and-TZDEFAULT-on-WASI.patch diff --git a/schemes/main/swift-corelibs-foundation/0001-wasm-Gate-atomic-write-option-usages-behind-platform.patch b/schemes/main/swift-corelibs-foundation/0001-wasm-Gate-atomic-write-option-usages-behind-platform.patch deleted file mode 100644 index 9596883..0000000 --- a/schemes/main/swift-corelibs-foundation/0001-wasm-Gate-atomic-write-option-usages-behind-platform.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 6e3a9e2ced5688bfe9e209633735bf6bdc85d64c Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Mon, 31 Mar 2025 11:07:42 +0000 -Subject: [PATCH] [wasm] Gate atomic write option usages behind platform check - -`Data.WritingOptions.atomic` is now unavailable on WASI: https://github.com/swiftlang/swift-foundation/pull/992 ---- - Sources/Foundation/NSData.swift | 11 +++++++++-- - Sources/Foundation/NSString.swift | 7 ++++++- - 2 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/Sources/Foundation/NSData.swift b/Sources/Foundation/NSData.swift -index 1a076bef..e1499ae2 100644 ---- a/Sources/Foundation/NSData.swift -+++ b/Sources/Foundation/NSData.swift -@@ -433,10 +433,12 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding { - #if os(WASI) - // WASI does not have permission concept - let permissions: Int? = nil -+ var atomicWrite: Bool { false } - #else - let permissions = try? fm.attributesOfItem(atPath: path)[.posixPermissions] as? Int -+ let atomicWrite = writeOptionsMask.contains(.atomic) - #endif -- if writeOptionsMask.contains(.atomic) { -+ if atomicWrite { - let (newFD, auxFilePath) = try _NSCreateTemporaryFile(path) - let fh = FileHandle(fileDescriptor: newFD, closeOnDealloc: true) - do { -@@ -489,7 +491,12 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding { - /// NOTE: the 'atomically' flag is ignored if the url is not of a type the supports atomic writes - open func write(toFile path: String, atomically useAuxiliaryFile: Bool) -> Bool { - do { -- try write(toFile: path, options: useAuxiliaryFile ? .atomic : []) -+ #if os(WASI) -+ let options: WritingOptions = [] -+ #else -+ let options: WritingOptions = useAuxiliaryFile ? .atomic : [] -+ #endif -+ try write(toFile: path, options: options) - } catch { - return false - } -diff --git a/Sources/Foundation/NSString.swift b/Sources/Foundation/NSString.swift -index ccd0ae08..fd1de6f3 100644 ---- a/Sources/Foundation/NSString.swift -+++ b/Sources/Foundation/NSString.swift -@@ -1269,7 +1269,12 @@ extension NSString { - internal func _writeTo(_ url: URL, _ useAuxiliaryFile: Bool, _ enc: UInt) throws { - var data = Data() - try _getExternalRepresentation(&data, url, enc) -- try data.write(to: url, options: useAuxiliaryFile ? .atomic : []) -+ #if os(WASI) -+ let options: Data.WritingOptions = [] -+ #else -+ let options: Data.WritingOptions = useAuxiliaryFile ? .atomic : [] -+ #endif -+ try data.write(to: url, options: options) - } - - public func write(to url: URL, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws { --- -2.48.1 - diff --git a/schemes/main/swift-foundation/0001-wasm-Stop-requiring-TZDIR-and-TZDEFAULT-on-WASI.patch b/schemes/main/swift-foundation/0001-wasm-Stop-requiring-TZDIR-and-TZDEFAULT-on-WASI.patch deleted file mode 100644 index 1cb76e7..0000000 --- a/schemes/main/swift-foundation/0001-wasm-Stop-requiring-TZDIR-and-TZDEFAULT-on-WASI.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 3828fe6d24735d59d53f073d9021b954d28e5750 Mon Sep 17 00:00:00 2001 -From: Yuta Saito -Date: Mon, 14 Apr 2025 18:20:25 +0000 -Subject: [PATCH] [wasm] Stop requiring `TZDIR` and `TZDEFAULT` on WASI - -Those constants are not used on WASI in Swift side, so there's no -need to require them in the C headers. ---- - Sources/_FoundationCShims/include/_CStdlib.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Sources/_FoundationCShims/include/_CStdlib.h b/Sources/_FoundationCShims/include/_CStdlib.h -index 405febc..408a924 100644 ---- a/Sources/_FoundationCShims/include/_CStdlib.h -+++ b/Sources/_FoundationCShims/include/_CStdlib.h -@@ -156,7 +156,7 @@ - #ifndef TZDEFAULT - #define TZDEFAULT "/etc/localtime" - #endif /* !defined TZDEFAULT */ --#elif TARGET_OS_WINDOWS -+#elif TARGET_OS_WINDOWS || TARGET_OS_WASI - /* not required */ - #else - #error "possibly define TZDIR and TZDEFAULT for this platform" --- -2.48.1 - From 6098c53d529da5ccc1acc00a7930287008ea5956 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Mon, 12 May 2025 01:39:50 +0000 Subject: [PATCH 3/3] Pass `CMAKE_CXX_FLAGS` to foundation build The recent wasi-libc introduced some explicit checks for `pthread.h` inclusion and a part of C++ sources in ICU include it. So we need to pass `-pthread` to CXX flags as well. https://github.com/WebAssembly/wasi-libc/blob/eadb436d5c09f7983c3a687086e5af6b6e9f5510/libc-top-half/musl/include/pthread.h#L92 --- schemes/main/build/build-foundation.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/schemes/main/build/build-foundation.sh b/schemes/main/build/build-foundation.sh index 290215b..1b367f4 100755 --- a/schemes/main/build/build-foundation.sh +++ b/schemes/main/build/build-foundation.sh @@ -43,6 +43,7 @@ cmake -G Ninja \ -D CMAKE_CXX_COMPILER_FORCED=ON \ -D CMAKE_Swift_FLAGS="-sdk $WASI_SYSROOT_PATH -resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static $swift_extra_flags" \ -D CMAKE_C_FLAGS="-resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static/clang -B $LLVM_BIN_DIR $c_extra_flags" \ + -D CMAKE_CXX_FLAGS="-resource-dir $DESTINATION_TOOLCHAIN/usr/lib/swift_static/clang -B $LLVM_BIN_DIR $c_extra_flags" \ -D _SwiftCollections_SourceDIR="$SOURCE_PATH/swift-collections" \ -D _SwiftFoundation_SourceDIR="$SOURCE_PATH/swift-foundation" \ -D _SwiftFoundationICU_SourceDIR="$SOURCE_PATH/swift-foundation-icu" \