Skip to content

Commit 3428247

Browse files
authored
[wasm] Fix Debug configuration builds (#70683)
* Fix cmake error ``` Manually-specified variables were not used by the project: CONFIGURATION_WASM_OPT_FLAGS ``` * Build the interpreter with -O1 on Wasm in Debug configs Otherwise `interp_exec_method` and `generate_code` can easily overflow the stack in some browsers with even a few recursive calls (for example during .cctor initializaiton)
1 parent 20cb077 commit 3428247

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/mono/mono/mini/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ if(ENABLE_INTERP_LIB)
289289
add_library(mono-ee-interp STATIC "${interp_sources}")
290290
target_link_libraries(mono-ee-interp monoapi)
291291
install(TARGETS mono-ee-interp LIBRARY)
292+
if(HOST_WASM AND CMAKE_BUILD_TYPE STREQUAL "Debug")
293+
# Always optimize the interpreter, even in Debug builds. Unoptimized interp_exec_method and
294+
# generate_code are so big that some browsers overflow the stack with even a few recursive
295+
# invocations (e.g. during .cctor initialization)
296+
target_compile_options(mono-ee-interp PRIVATE -O1)
297+
endif()
292298
endif()
293299

294300
if(ENABLE_LLVM)

src/mono/wasm/runtime/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ set_target_properties(dotnet PROPERTIES
3434
LINK_FLAGS "@${NATIVE_BIN_DIR}/src/emcc-default.rsp @${NATIVE_BIN_DIR}/src/emcc-link.rsp ${CONFIGURATION_LINK_FLAGS} --extern-pre-js ${NATIVE_BIN_DIR}/src/cjs/runtime.cjs.iffe.js --pre-js ${NATIVE_BIN_DIR}/src/cjs/dotnet.cjs.pre.js --js-library ${NATIVE_BIN_DIR}/src/cjs/dotnet.cjs.lib.js --js-library ${NATIVE_BIN_DIR}/src/pal_random.lib.js --post-js ${NATIVE_BIN_DIR}/src/cjs/dotnet.cjs.post.js --extern-post-js ${NATIVE_BIN_DIR}/src/cjs/dotnet.cjs.extpost.js "
3535
RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}")
3636

37+
set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}")
38+
3739
if(CMAKE_BUILD_TYPE STREQUAL "Release")
3840
add_custom_command(TARGET dotnet
3941
POST_BUILD COMMAND ${EMSDK_PATH}/upstream/bin/wasm-opt --enable-exception-handling ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.wasm -o ${NATIVE_BIN_DIR}/dotnet.wasm

0 commit comments

Comments
 (0)