Skip to content

Commit f7d3cde

Browse files
Merge pull request #4914 from kateinoigakukun/pr-0e428ab1d3cbb96680c2c10a64f35b9d4b23b71c
[wasm] Enable wasi-libc emulations for Foundation
2 parents 514e2bd + ee05d2d commit f7d3cde

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Sources/Foundation/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,18 @@ elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
225225
target_link_options(Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
226226
endif()
227227

228+
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
229+
target_compile_options(Foundation PRIVATE
230+
"SHELL:-Xcc -D_WASI_EMULATED_MMAN
231+
-Xcc -D_WASI_EMULATED_SIGNAL
232+
-Xcc -D_WASI_EMULATED_PROCESS_CLOCKS
233+
-Xcc -D_WASI_EMULATED_GETPID")
234+
# Link wasi-libc emulation libraries. Other emulation libs are also used in stdlib
235+
target_compile_options(Foundation
236+
PRIVATE
237+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend wasi-emulated-getpid")
238+
endif()
239+
228240

229241
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation)
230242
_install_target(Foundation)

Sources/FoundationXML/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
4343
target_link_options(FoundationXML PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
4444
endif()
4545

46+
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
47+
target_compile_options(FoundationXML PRIVATE
48+
"SHELL:-Xcc -D_WASI_EMULATED_SIGNAL
49+
-Xcc -D_WASI_EMULATED_PROCESS_CLOCKS
50+
-Xcc -D_WASI_EMULATED_MMAN")
51+
endif()
4652

4753
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML)
4854
_install_target(FoundationXML)

0 commit comments

Comments
 (0)