From 4d6c98115bbedd780cd1314f79742cc8f0cf6bdd Mon Sep 17 00:00:00 2001 From: henrydf Date: Wed, 6 Mar 2024 15:56:45 +0800 Subject: [PATCH] Fix Emscripten build Co-authored-by: Henry --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b3e2e..7a37825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,18 @@ target_include_directories(qjs PUBLIC if(EMSCRIPTEN) add_executable(qjs_wasm ${qjs_sources}) + target_link_options(qjs_wasm PRIVATE + # in emscripten 3.x, this will be set to 16k which is too small for quickjs. #write sth. to force github rebuild + -sSTACK_SIZE=2097152 # let it be 2m = 2 * 1024 * 1024 = 2097152, otherwise, stack overflow may be occured at bootstrap + -sNO_INVOKE_RUN + -sNO_EXIT_RUNTIME + -sMODULARIZE # do not mess the global + -sEXPORT_ES6 # export js file to morden es module + -sEXPORT_NAME=getQuickJs # give a name + -sTEXTDECODER=1 # it will be 2 if we use -Oz, and that will cause js -> c string convertion fail + -sNO_DEFAULT_TO_CXX # this project is pure c project, no need for c plus plus handle + -sEXPORTED_RUNTIME_METHODS=ccall,cwrap + ) target_compile_definitions(qjs_wasm PRIVATE ${qjs_defines}) target_link_libraries(qjs_wasm m) endif()