@@ -25,12 +25,29 @@ add_cppinterop_unittest(CppInterOpTests
2525)
2626
2727if (EMSCRIPTEN)
28-
28+ # Explanation of Emscripten-specific link flags for CppInterOpTests:
29+ #
30+ # MAIN_MODULE=1:
31+ # Enables building CppInterOpTests.js as the main WebAssembly module, allowing dynamic linking of side modules.
32+ #
33+ # WASM_BIGINT:
34+ # Ensures support for 64-bit integer types by enabling JavaScript BigInt integration in WASM.
35+ #
36+ # ALLOW_MEMORY_GROWTH=1:
37+ # Allows the WebAssembly memory to grow dynamically at runtime to accommodate increasing memory needs.
38+ # Would lead to an abortOnCannotGrowMemory error if memory cannot be grown while running the tests.
39+ #
40+ # STACK_SIZE=32mb: Allocates 32MB of stack space to handle deep recursion or large stack-allocated objects safely.
41+ # INITIAL_MEMORY=128mb: Sets the initial linear memory size to 128MB to reduce the likelihood of early memory expansion and improve performance.
42+ # The STACK_SIZE and INITIAL_MEMORY values are chosen based on what has been put to use for running xeus-cpp-lite.
43+ # Check https://github.com/jupyter-xeus/xeus/blob/main/cmake/WasmBuildOptions.cmake#L35-L36 for more details.
44+ # Not setting these flags would lead to a memory access out of bounds error while running the tests.
45+ #
46+ # --preload-file ${SYSROOT_PATH}/include@/include:
47+ # Preloads the system include directory into the Emscripten virtual filesystem to make headers accessible at runtime.
2948 target_link_options (CppInterOpTests
30- PUBLIC "SHELL: -fexceptions"
3149 PUBLIC "SHELL: -s MAIN_MODULE=1"
3250 PUBLIC "SHELL: -s WASM_BIGINT"
33- PUBLIC "SHELL: -s ASSERTIONS=0"
3451 PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
3552 PUBLIC "SHELL: -s STACK_SIZE=32mb"
3653 PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
@@ -69,12 +86,10 @@ target_link_libraries(DynamicLibraryManagerTests
6986)
7087
7188if (EMSCRIPTEN)
72-
89+ # Check explanation of Emscripten-specific link flags for CppInterOpTests above for DynamicLibraryManagerTests as well.
7390 target_link_options (DynamicLibraryManagerTests
74- PUBLIC "SHELL: -fexceptions"
7591 PUBLIC "SHELL: -s MAIN_MODULE=1"
7692 PUBLIC "SHELL: -s WASM_BIGINT"
77- PUBLIC "SHELL: -s ASSERTIONS=0"
7893 PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
7994 PUBLIC "SHELL: -s STACK_SIZE=32mb"
8095 PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
0 commit comments