From 6c13900018567f4e8328a5f138fd0cca8ce34457 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:32:42 +0000 Subject: [PATCH 1/2] Update base tag for release-6.1 to swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-15-a --- schemes/release-6.1/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemes/release-6.1/manifest.json b/schemes/release-6.1/manifest.json index 7b6116b..928dc66 100644 --- a/schemes/release-6.1/manifest.json +++ b/schemes/release-6.1/manifest.json @@ -1,6 +1,6 @@ { "update-checkout-scheme": "release/6.1", - "base-tag": "swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-12-a", + "base-tag": "swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-15-a", "build-compiler": false, "icu4c": [], "libxml2": [ From 50d6c8347c1125ffebbf612f9171552331c000a0 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 17 Dec 2024 04:08:33 +0000 Subject: [PATCH 2/2] Check 6.1 cherry-pick patches --- ...build-of-_copyDirectoryMetadata-1094.patch | 34 +++++++ ...-to-make-it-work-with-wasi-libc-1095.patch | 96 +++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 schemes/release-6.1/swift-foundation/0001-Fix-WASI-build-of-_copyDirectoryMetadata-1094.patch create mode 100644 schemes/release-6.1/swift-foundation/0002-Follow-up-fixes-to-make-it-work-with-wasi-libc-1095.patch diff --git a/schemes/release-6.1/swift-foundation/0001-Fix-WASI-build-of-_copyDirectoryMetadata-1094.patch b/schemes/release-6.1/swift-foundation/0001-Fix-WASI-build-of-_copyDirectoryMetadata-1094.patch new file mode 100644 index 0000000..a9b2688 --- /dev/null +++ b/schemes/release-6.1/swift-foundation/0001-Fix-WASI-build-of-_copyDirectoryMetadata-1094.patch @@ -0,0 +1,34 @@ +From 8aff4298d3f64d0163ede2c0618292de449d818c Mon Sep 17 00:00:00 2001 +From: Yuta Saito +Date: Sat, 14 Dec 2024 02:29:45 +0900 +Subject: [PATCH 1/2] Fix WASI build of `_copyDirectoryMetadata` (#1094) + +Extended attributes don't exist in WASI, so we need to exclude the use +of xattr-related APIs including `flistxattr`. +--- + Sources/FoundationEssentials/FileManager/FileOperations.swift | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift +index 83d131a..ce4de44 100644 +--- a/Sources/FoundationEssentials/FileManager/FileOperations.swift ++++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift +@@ -911,6 +911,7 @@ enum _FileOperations { + + #if !canImport(Darwin) + private static func _copyDirectoryMetadata(srcFD: CInt, srcPath: @autoclosure () -> String, dstFD: CInt, dstPath: @autoclosure () -> String, delegate: some LinkOrCopyDelegate) throws { ++ #if !os(WASI) + // Copy extended attributes + var size = flistxattr(srcFD, nil, 0) + if size > 0 { +@@ -936,6 +937,7 @@ enum _FileOperations { + } + } + } ++ #endif + var statInfo = stat() + if fstat(srcFD, &statInfo) == 0 { + // Copy owner/group +-- +2.46.0 + diff --git a/schemes/release-6.1/swift-foundation/0002-Follow-up-fixes-to-make-it-work-with-wasi-libc-1095.patch b/schemes/release-6.1/swift-foundation/0002-Follow-up-fixes-to-make-it-work-with-wasi-libc-1095.patch new file mode 100644 index 0000000..ccc8a74 --- /dev/null +++ b/schemes/release-6.1/swift-foundation/0002-Follow-up-fixes-to-make-it-work-with-wasi-libc-1095.patch @@ -0,0 +1,96 @@ +From 7e0817f4c7dbc748fc70c45c20edd5acc98a34d7 Mon Sep 17 00:00:00 2001 +From: Yuta Saito +Date: Tue, 17 Dec 2024 04:19:39 +0900 +Subject: [PATCH 2/2] Follow-up fixes to make it work with wasi-libc (#1095) + +* Gate `fchown` and `fchmod` calls behind `os(WASI)` + +They are not available on WASI, so we gate them behind `os(WASI)`. + +* Add missing constant shims for wasi-libc + +* Use `futimens` instead of legacy `futimes` + +wasi-libc does not provide `futimes` as it is a legacy function. +https://github.com/WebAssembly/wasi-libc/blob/574b88da481569b65a237cb80daf9a2d5aeaf82d/libc-top-half/musl/include/sys/time.h#L34 +--- + .../FileManager/FileOperations.swift | 10 +++++++--- + Sources/FoundationEssentials/WASILibc+Extensions.swift | 9 +++++++++ + Sources/_FoundationCShims/include/platform_shims.h | 4 ++++ + 3 files changed, 20 insertions(+), 3 deletions(-) + +diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift +index ce4de44..96ee566 100644 +--- a/Sources/FoundationEssentials/FileManager/FileOperations.swift ++++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift +@@ -940,26 +940,30 @@ enum _FileOperations { + #endif + var statInfo = stat() + if fstat(srcFD, &statInfo) == 0 { ++ #if !os(WASI) // WASI doesn't have fchown for now + // Copy owner/group + if fchown(dstFD, statInfo.st_uid, statInfo.st_gid) != 0 { + try delegate.throwIfNecessary(errno, srcPath(), dstPath()) + } ++ #endif + + // Copy modification date +- let value = timeval(tv_sec: statInfo.st_mtim.tv_sec, tv_usec: statInfo.st_mtim.tv_nsec / 1000) ++ let value = statInfo.st_mtim + var tv = (value, value) + try withUnsafePointer(to: &tv) { +- try $0.withMemoryRebound(to: timeval.self, capacity: 2) { +- if futimes(dstFD, $0) != 0 { ++ try $0.withMemoryRebound(to: timespec.self, capacity: 2) { ++ if futimens(dstFD, $0) != 0 { + try delegate.throwIfNecessary(errno, srcPath(), dstPath()) + } + } + } + ++ #if !os(WASI) // WASI doesn't have fchmod for now + // Copy permissions + if fchmod(dstFD, statInfo.st_mode) != 0 { + try delegate.throwIfNecessary(errno, srcPath(), dstPath()) + } ++ #endif + } else { + try delegate.throwIfNecessary(errno, srcPath(), dstPath()) + } +diff --git a/Sources/FoundationEssentials/WASILibc+Extensions.swift b/Sources/FoundationEssentials/WASILibc+Extensions.swift +index 351fe19..44f3f93 100644 +--- a/Sources/FoundationEssentials/WASILibc+Extensions.swift ++++ b/Sources/FoundationEssentials/WASILibc+Extensions.swift +@@ -49,5 +49,14 @@ internal var O_TRUNC: Int32 { + internal var O_WRONLY: Int32 { + return _platform_shims_O_WRONLY() + } ++internal var O_RDONLY: Int32 { ++ return _platform_shims_O_RDONLY() ++} ++internal var O_DIRECTORY: Int32 { ++ return _platform_shims_O_DIRECTORY() ++} ++internal var O_NOFOLLOW: Int32 { ++ return _platform_shims_O_NOFOLLOW() ++} + + #endif // os(WASI) +diff --git a/Sources/_FoundationCShims/include/platform_shims.h b/Sources/_FoundationCShims/include/platform_shims.h +index 6bc0a0e..e02b581 100644 +--- a/Sources/_FoundationCShims/include/platform_shims.h ++++ b/Sources/_FoundationCShims/include/platform_shims.h +@@ -102,6 +102,10 @@ static inline int32_t _platform_shims_O_CREAT(void) { return O_CREAT; } + static inline int32_t _platform_shims_O_EXCL(void) { return O_EXCL; } + static inline int32_t _platform_shims_O_TRUNC(void) { return O_TRUNC; } + static inline int32_t _platform_shims_O_WRONLY(void) { return O_WRONLY; } ++static inline int32_t _platform_shims_O_RDONLY(void) { return O_RDONLY; } ++static inline int32_t _platform_shims_O_DIRECTORY(void) { return O_DIRECTORY; } ++static inline int32_t _platform_shims_O_NOFOLLOW(void) { return O_NOFOLLOW; } ++ + #endif + + #endif /* CSHIMS_PLATFORM_SHIMS */ +-- +2.46.0 +