Skip to content

Commit a869b45

Browse files
authored
[wasm][coreCLR] unify -fwasm-exceptions and -msimd128 (#120365)
1 parent a12d216 commit a869b45

File tree

8 files changed

+40
-7
lines changed

8 files changed

+40
-7
lines changed

src/coreclr/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ endif()
3636
OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
3737

3838
if (CLR_CMAKE_TARGET_ARCH_WASM)
39-
add_compile_options(-fwasm-exceptions)
39+
add_compile_options(
40+
-fwasm-exceptions
41+
-msimd128)
42+
add_link_options(
43+
-fwasm-exceptions
44+
-msimd128
45+
)
4046
endif()
4147

4248
#----------------------------------------------------

src/coreclr/clrdefinitions.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ function(set_target_definitions_to_custom_os_and_arch)
230230
set_target_properties(${TARGETDETAILS_TARGET} PROPERTIES IGNORE_DEFAULT_TARGET_ARCH TRUE)
231231
set_target_properties(${TARGETDETAILS_TARGET} PROPERTIES IGNORE_DEFAULT_TARGET_OS TRUE)
232232

233+
if (TARGETDETAILS_OS STREQUAL "browser")
234+
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_UNIX)
235+
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_BROWSER)
236+
endif()
237+
if (TARGETDETAILS_OS STREQUAL "wasi")
238+
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_UNIX)
239+
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_WASI)
240+
endif()
233241
if ((TARGETDETAILS_OS MATCHES "^unix"))
234242
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_UNIX)
235243
if (TARGETDETAILS_ARCH STREQUAL "x64")
@@ -269,6 +277,8 @@ function(set_target_definitions_to_custom_os_and_arch)
269277
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_LOONGARCH64)
270278
elseif((TARGETDETAILS_ARCH STREQUAL "arm") OR (TARGETDETAILS_ARCH STREQUAL "armel"))
271279
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_ARM)
280+
elseif(TARGETDETAILS_ARCH STREQUAL "wasm")
281+
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_WASM)
272282
elseif((TARGETDETAILS_ARCH STREQUAL "riscv64"))
273283
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_64BIT)
274284
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_RISCV64)

src/coreclr/gcinfo/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ endif (NOT CLR_CMAKE_TARGET_ARCH_RISCV64)
8989
if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
9090
create_gcinfo_lib(TARGET gcinfo_unix_x86 OS unix ARCH x86)
9191
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
92+
93+
if (CLR_CMAKE_TARGET_ARCH_WASM)
94+
create_gcinfo_lib(TARGET gcinfo_unix_wasm OS browser ARCH wasm)
95+
endif (CLR_CMAKE_TARGET_ARCH_WASM)

src/coreclr/hosts/corerun/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ else(CLR_CMAKE_HOST_WIN32)
5151
System.Native.TimeZoneData)
5252
# linker options for NodeJs, link in JavaScript helper, access to local filesystem
5353
if (CLR_CMAKE_TARGET_BROWSER)
54-
target_compile_options(corerun PRIVATE -fwasm-exceptions)
54+
target_compile_options(corerun PRIVATE
55+
-fwasm-exceptions
56+
-msimd128
57+
)
5558
target_link_libraries(corerun PRIVATE
5659
System.Native.Browser-Static)
5760
set(JS_SYSTEM_NATIVE_BROWSER
@@ -66,6 +69,7 @@ else(CLR_CMAKE_HOST_WIN32)
6669
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
6770
target_link_options(corerun PRIVATE
6871
-fwasm-exceptions
72+
-msimd128
6973
-sEXIT_RUNTIME=1
7074
-sINITIAL_MEMORY=134217728
7175
-sENVIRONMENT=node,shell

src/coreclr/hosts/corewasmrun/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ target_include_directories(corewasmrun PRIVATE
1616
../corerun
1717
)
1818

19-
target_compile_options(corewasmrun PRIVATE -fwasm-exceptions)
19+
target_compile_options(corewasmrun PRIVATE
20+
-fwasm-exceptions
21+
-msimd128
22+
)
2023

2124
set(JS_SYSTEM_NATIVE_BROWSER
2225
"${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js")
@@ -30,6 +33,7 @@ set_target_properties(corewasmrun PROPERTIES
3033
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
3134
target_link_options(corewasmrun PRIVATE
3235
-fwasm-exceptions
36+
-msimd128
3337
-sEXIT_RUNTIME=1
3438
-sINITIAL_MEMORY=134217728
3539
-sSTACK_SIZE=5MB

src/coreclr/inc/switches.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#define GC_STATS
4444
#endif
4545

46-
#if defined(TARGET_X86) || defined(TARGET_ARM) || defined(TARGET_BROWSER)
46+
#if defined(TARGET_X86) || defined(TARGET_ARM) || defined(TARGET_WASM)
4747
#define USE_LAZY_PREFERRED_RANGE 0
4848

4949
#elif defined(TARGET_64BIT)

src/coreclr/pal/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ include_directories(${COREPAL_SOURCE_DIR}/../inc)
99
if (NOT CLR_CMAKE_TARGET_BROWSER)
1010
add_compile_options(-fexceptions)
1111
else()
12-
add_compile_options(-fwasm-exceptions)
13-
add_link_options(-fwasm-exceptions -sEXIT_RUNTIME=1)
12+
add_compile_options(
13+
-fwasm-exceptions
14+
-msimd128
15+
)
16+
add_link_options(
17+
-fwasm-exceptions
18+
-msimd128
19+
)
1420
endif()
1521

1622
add_subdirectory(src)

src/native/corehost/browserhost/sample/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
# this is just a incomplete sample app deployment
55
# WASM-TODO: implement proper in-tree project via MSBuild and WASM SDK
6-
# WASM-TODO: deploy *.js.map when available
76
set(SAMPLE_ASSETS
87
index.html
98
main.mjs

0 commit comments

Comments
 (0)