@@ -94,7 +94,7 @@ endif()
94
94
95
95
# System dependencies
96
96
find_package (dispatch CONFIG )
97
- if (NOT dispatch_FOUND )
97
+ if (NOT dispatch_FOUND AND NOT CMAKE_SYSTEM_NAME STREQUAL WASI )
98
98
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android" )
99
99
set (DEFAULT_DISPATCH_INCLUDE_PATH "/usr/lib/swift" )
100
100
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
@@ -113,7 +113,6 @@ find_package(CURL REQUIRED)
113
113
list (APPEND _Foundation_common_build_flags
114
114
"-DDEPLOYMENT_RUNTIME_SWIFT"
115
115
"-DCF_BUILDING_CF"
116
- "-DDEPLOYMENT_ENABLE_LIBDISPATCH"
117
116
"-DHAVE_STRUCT_TIMESPEC"
118
117
"-Wno-shorten-64-to-32"
119
118
"-Wno-deprecated-declarations"
@@ -126,16 +125,10 @@ list(APPEND _Foundation_common_build_flags
126
125
"-Wno-switch"
127
126
"-fblocks" )
128
127
129
- if (CMAKE_SYSTEM_NAME STREQUAL "WASI" )
130
- list (APPEND _Foundation_common_build_flags
131
- "-D_WASI_EMULATED_SIGNAL"
132
- "-DHAVE_STRLCPY"
133
- "-DHAVE_STRLCAT"
134
- )
135
- else ()
136
- list (APPEND _Foundation_common_build_flags
137
- "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS"
138
- )
128
+ if (NOT CMAKE_SYSTEM_NAME STREQUAL WASI )
129
+ list (APPEND _Foundation_common_build_flags
130
+ "-DDEPLOYMENT_ENABLE_LIBDISPATCH"
131
+ "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" )
139
132
endif ()
140
133
141
134
if (NOT "${CMAKE_C_SIMULATE_ID} " STREQUAL "MSVC" )
@@ -168,16 +161,17 @@ list(APPEND _Foundation_swift_build_flags
168
161
"-Xfrontend"
169
162
"-require-explicit-sendable" )
170
163
171
- if (CMAKE_SYSTEM_NAME STREQUAL "WASI" )
172
- list (APPEND _Foundation_swift_build_flags
173
- "-D_WASI_EMULATED_SIGNAL"
174
- "-DHAVE_STRLCPY"
175
- "-DHAVE_STRLCAT"
176
- )
164
+ if (CMAKE_SYSTEM_NAME STREQUAL WASI )
165
+ # Enable wasi-libc emulation features
166
+ set (WASI_EMULATION_DEFS _WASI_EMULATED_MMAN _WASI_EMULATED_SIGNAL _WASI_EMULATED_PROCESS_CLOCKS )
167
+ foreach (def ${WASI_EMULATION_DEFS} )
168
+ list (APPEND _Foundation_swift_build_flags "SHELL:-Xcc -D${def} " )
169
+ list (APPEND _Foundation_common_build_flags "-D${def} " )
170
+ endforeach ()
177
171
else ()
178
- list ( APPEND _Foundation_swift_build_flags
179
- "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS"
180
- )
172
+ # Assume we have threads on other platforms
173
+ list ( APPEND _Foundation_swift_build_flags
174
+ "-DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS" )
181
175
endif ()
182
176
183
177
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android" )
0 commit comments