Skip to content

Commit d60d3d7

Browse files
build: Repair the build on WASI (#21)
Timezone support is generally not available on WASI, so disable it. Additionally, the signal and mman needs explicit emulation options.
1 parent c7ed2ab commit d60d3d7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Package.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ var buildSettings: [CXXSetting] = [
2020
.driverKit,
2121
.android,
2222
.linux,
23-
.wasi
2423
])),
2524
.define("U_TIMEZONE_PACKAGE", to: "\"icutz44l\""),
25+
.define("U_HAVE_TZSET", to: "0", .when(platforms: [.wasi])),
26+
.define("U_HAVE_TZNAME", to: "0", .when(platforms: [.wasi])),
27+
.define("U_HAVE_TIMEZONE", to: "0", .when(platforms: [.wasi])),
2628
.define("FORTIFY_SOURCE", to: "2"),
2729
.define("STD_INSPIRED"),
2830
.define("MAC_OS_X_VERSION_MIN_REQUIRED", to: "101500"),
31+
.define("_WASI_EMULATED_SIGNAL", .when(platforms: [.wasi])),
32+
.define("_WASI_EMULATED_MMAN", .when(platforms: [.wasi])),
2933
.define("U_HAVE_STRTOD_L", to: "1"),
3034
.define("U_HAVE_XLOCALE_H", to: "1"),
3135
.define("U_HAVE_STRING_VIEW", to: "1"),
@@ -68,6 +72,11 @@ let stubDataBuildSettings: [CXXSetting] = buildSettings.appending([
6872
.headerSearchPath("."),
6973
])
7074

75+
let linkerSettings: [LinkerSetting] = [
76+
.linkedLibrary("wasi-emulated-signal", .when(platforms: [.wasi])),
77+
.linkedLibrary("wasi-emulated-mman", .when(platforms: [.wasi])),
78+
]
79+
7180
let package = Package(
7281
name: "FoundationICU",
7382
products: [
@@ -112,6 +121,10 @@ let package = Package(
112121
cxxLanguageStandard: .cxx14
113122
)
114123

124+
for target in package.targets {
125+
target.linkerSettings = linkerSettings
126+
}
127+
115128
fileprivate extension Array {
116129
func appending(_ other: Self) -> Self {
117130
var me = self

0 commit comments

Comments
 (0)