Skip to content

Commit 34e71e5

Browse files
Merge pull request #476 from swiftwasm/update-base-tag/release-6.1-swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-15-a
Update base tag for release-6.1 to swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-15-a
2 parents a9c59c1 + 50d6c83 commit 34e71e5

File tree

3 files changed

+131
-1
lines changed

3 files changed

+131
-1
lines changed

schemes/release-6.1/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"update-checkout-scheme": "release/6.1",
3-
"base-tag": "swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-12-a",
3+
"base-tag": "swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-15-a",
44
"build-compiler": false,
55
"icu4c": [],
66
"libxml2": [
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 8aff4298d3f64d0163ede2c0618292de449d818c Mon Sep 17 00:00:00 2001
2+
From: Yuta Saito <[email protected]>
3+
Date: Sat, 14 Dec 2024 02:29:45 +0900
4+
Subject: [PATCH 1/2] Fix WASI build of `_copyDirectoryMetadata` (#1094)
5+
6+
Extended attributes don't exist in WASI, so we need to exclude the use
7+
of xattr-related APIs including `flistxattr`.
8+
---
9+
Sources/FoundationEssentials/FileManager/FileOperations.swift | 2 ++
10+
1 file changed, 2 insertions(+)
11+
12+
diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift
13+
index 83d131a..ce4de44 100644
14+
--- a/Sources/FoundationEssentials/FileManager/FileOperations.swift
15+
+++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift
16+
@@ -911,6 +911,7 @@ enum _FileOperations {
17+
18+
#if !canImport(Darwin)
19+
private static func _copyDirectoryMetadata(srcFD: CInt, srcPath: @autoclosure () -> String, dstFD: CInt, dstPath: @autoclosure () -> String, delegate: some LinkOrCopyDelegate) throws {
20+
+ #if !os(WASI)
21+
// Copy extended attributes
22+
var size = flistxattr(srcFD, nil, 0)
23+
if size > 0 {
24+
@@ -936,6 +937,7 @@ enum _FileOperations {
25+
}
26+
}
27+
}
28+
+ #endif
29+
var statInfo = stat()
30+
if fstat(srcFD, &statInfo) == 0 {
31+
// Copy owner/group
32+
--
33+
2.46.0
34+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
From 7e0817f4c7dbc748fc70c45c20edd5acc98a34d7 Mon Sep 17 00:00:00 2001
2+
From: Yuta Saito <[email protected]>
3+
Date: Tue, 17 Dec 2024 04:19:39 +0900
4+
Subject: [PATCH 2/2] Follow-up fixes to make it work with wasi-libc (#1095)
5+
6+
* Gate `fchown` and `fchmod` calls behind `os(WASI)`
7+
8+
They are not available on WASI, so we gate them behind `os(WASI)`.
9+
10+
* Add missing constant shims for wasi-libc
11+
12+
* Use `futimens` instead of legacy `futimes`
13+
14+
wasi-libc does not provide `futimes` as it is a legacy function.
15+
https://github.com/WebAssembly/wasi-libc/blob/574b88da481569b65a237cb80daf9a2d5aeaf82d/libc-top-half/musl/include/sys/time.h#L34
16+
---
17+
.../FileManager/FileOperations.swift | 10 +++++++---
18+
Sources/FoundationEssentials/WASILibc+Extensions.swift | 9 +++++++++
19+
Sources/_FoundationCShims/include/platform_shims.h | 4 ++++
20+
3 files changed, 20 insertions(+), 3 deletions(-)
21+
22+
diff --git a/Sources/FoundationEssentials/FileManager/FileOperations.swift b/Sources/FoundationEssentials/FileManager/FileOperations.swift
23+
index ce4de44..96ee566 100644
24+
--- a/Sources/FoundationEssentials/FileManager/FileOperations.swift
25+
+++ b/Sources/FoundationEssentials/FileManager/FileOperations.swift
26+
@@ -940,26 +940,30 @@ enum _FileOperations {
27+
#endif
28+
var statInfo = stat()
29+
if fstat(srcFD, &statInfo) == 0 {
30+
+ #if !os(WASI) // WASI doesn't have fchown for now
31+
// Copy owner/group
32+
if fchown(dstFD, statInfo.st_uid, statInfo.st_gid) != 0 {
33+
try delegate.throwIfNecessary(errno, srcPath(), dstPath())
34+
}
35+
+ #endif
36+
37+
// Copy modification date
38+
- let value = timeval(tv_sec: statInfo.st_mtim.tv_sec, tv_usec: statInfo.st_mtim.tv_nsec / 1000)
39+
+ let value = statInfo.st_mtim
40+
var tv = (value, value)
41+
try withUnsafePointer(to: &tv) {
42+
- try $0.withMemoryRebound(to: timeval.self, capacity: 2) {
43+
- if futimes(dstFD, $0) != 0 {
44+
+ try $0.withMemoryRebound(to: timespec.self, capacity: 2) {
45+
+ if futimens(dstFD, $0) != 0 {
46+
try delegate.throwIfNecessary(errno, srcPath(), dstPath())
47+
}
48+
}
49+
}
50+
51+
+ #if !os(WASI) // WASI doesn't have fchmod for now
52+
// Copy permissions
53+
if fchmod(dstFD, statInfo.st_mode) != 0 {
54+
try delegate.throwIfNecessary(errno, srcPath(), dstPath())
55+
}
56+
+ #endif
57+
} else {
58+
try delegate.throwIfNecessary(errno, srcPath(), dstPath())
59+
}
60+
diff --git a/Sources/FoundationEssentials/WASILibc+Extensions.swift b/Sources/FoundationEssentials/WASILibc+Extensions.swift
61+
index 351fe19..44f3f93 100644
62+
--- a/Sources/FoundationEssentials/WASILibc+Extensions.swift
63+
+++ b/Sources/FoundationEssentials/WASILibc+Extensions.swift
64+
@@ -49,5 +49,14 @@ internal var O_TRUNC: Int32 {
65+
internal var O_WRONLY: Int32 {
66+
return _platform_shims_O_WRONLY()
67+
}
68+
+internal var O_RDONLY: Int32 {
69+
+ return _platform_shims_O_RDONLY()
70+
+}
71+
+internal var O_DIRECTORY: Int32 {
72+
+ return _platform_shims_O_DIRECTORY()
73+
+}
74+
+internal var O_NOFOLLOW: Int32 {
75+
+ return _platform_shims_O_NOFOLLOW()
76+
+}
77+
78+
#endif // os(WASI)
79+
diff --git a/Sources/_FoundationCShims/include/platform_shims.h b/Sources/_FoundationCShims/include/platform_shims.h
80+
index 6bc0a0e..e02b581 100644
81+
--- a/Sources/_FoundationCShims/include/platform_shims.h
82+
+++ b/Sources/_FoundationCShims/include/platform_shims.h
83+
@@ -102,6 +102,10 @@ static inline int32_t _platform_shims_O_CREAT(void) { return O_CREAT; }
84+
static inline int32_t _platform_shims_O_EXCL(void) { return O_EXCL; }
85+
static inline int32_t _platform_shims_O_TRUNC(void) { return O_TRUNC; }
86+
static inline int32_t _platform_shims_O_WRONLY(void) { return O_WRONLY; }
87+
+static inline int32_t _platform_shims_O_RDONLY(void) { return O_RDONLY; }
88+
+static inline int32_t _platform_shims_O_DIRECTORY(void) { return O_DIRECTORY; }
89+
+static inline int32_t _platform_shims_O_NOFOLLOW(void) { return O_NOFOLLOW; }
90+
+
91+
#endif
92+
93+
#endif /* CSHIMS_PLATFORM_SHIMS */
94+
--
95+
2.46.0
96+

0 commit comments

Comments
 (0)