@@ -94,7 +94,7 @@ endif()
9494
9595# System dependencies
9696find_package (dispatch CONFIG)
97- if (NOT dispatch_FOUND)
97+ if (NOT dispatch_FOUND AND NOT CMAKE_SYSTEM_NAME STREQUAL WASI )
9898 if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android" )
9999 set (DEFAULT_DISPATCH_INCLUDE_PATH "/usr/lib/swift" )
100100 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
@@ -113,7 +113,6 @@ find_package(CURL REQUIRED)
113113list (APPEND _Foundation_common_build_flags
114114 "-DDEPLOYMENT_RUNTIME_SWIFT"
115115 "-DCF_BUILDING_CF"
116- "-DDEPLOYMENT_ENABLE_LIBDISPATCH"
117116 "-DHAVE_STRUCT_TIMESPEC"
118117 "-Wno-shorten-64-to-32"
119118 "-Wno-deprecated-declarations"
@@ -126,16 +125,10 @@ list(APPEND _Foundation_common_build_flags
126125 "-Wno-switch"
127126 "-fblocks" )
128127
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" )
139132endif ()
140133
141134if (NOT "${CMAKE_C_SIMULATE_ID} " STREQUAL "MSVC" )
@@ -168,16 +161,17 @@ list(APPEND _Foundation_swift_build_flags
168161 "-Xfrontend"
169162 "-require-explicit-sendable" )
170163
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 ()
177171else ()
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" )
181175endif ()
182176
183177if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android" )
0 commit comments