Skip to content

Commit 0349616

Browse files
authored
Explain chosen flags used for compiling test executables
1 parent 471ffd8 commit 0349616

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

unittests/CppInterOp/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ add_cppinterop_unittest(CppInterOpTests
2626

2727

2828
if(EMSCRIPTEN)
29+
# Explaination of compile and link flags
30+
# To dynamically link to a shared library for Emscripten builds you must use the MAIN_MODULE flag (see both https://github.com/emscripten-core/emscripten/issues/23543#issuecomment-2625334414
31+
# and https://emscripten.org/docs/compiling/Dynamic-Linking.html)
32+
# Without WASM_BIGINT flag then you get fatal errors when trying to run compiled Javascript about trying to convert between BigInt and non BigInt types
33+
# EXPORTED_RUNTIME_METHODS='[\"FS\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]' and --preload-file ${SYSROOT_PATH}/include@/include are not allow the Javascript that is
34+
# compiled to have access to the standard library headers (approach taken from xeus-cpp)
35+
# Without ALLOW_MEMORY_GROWTH=1 tests will fail with aborted(OOM). Approach to fix taken from answers to
36+
# https://stackoverflow.com/questions/67222200/runtimeerror-abortoom-build-with-s-assertions-1-for-more-info
2937
set_target_properties(CppInterOpTests PROPERTIES
3038
COMPILE_FLAGS "-s MAIN_MODULE=1"
3139
LINK_FLAGS "-s MAIN_MODULE=1 -s WASM_BIGINT -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]' --preload-file ${SYSROOT_PATH}/include@/include -s ALLOW_MEMORY_GROWTH=1"
@@ -73,6 +81,14 @@ target_link_libraries(DynamicLibraryManagerTests
7381
)
7482

7583
if(EMSCRIPTEN)
84+
# Explaination of compile and link flags
85+
# To dynamically link to a shared library for Emscripten builds you must use the MAIN_MODULE flag (see both https://github.com/emscripten-core/emscripten/issues/23543#issuecomment-2625334414
86+
# and https://emscripten.org/docs/compiling/Dynamic-Linking.html)
87+
# Without WASM_BIGINT flag then you get fatal errors when trying to run compiled Javascript about trying to convert between BigInt and non BigInt types
88+
# EXPORTED_RUNTIME_METHODS='[\"FS\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]' and --preload-file ${SYSROOT_PATH}/include@/include are not allow the Javascript that is
89+
# compiled to have access to the standard library headers (approach taken from xeus-cpp)
90+
# Without ALLOW_MEMORY_GROWTH=1 tests will fail with aborted(OOM). Approach to fix taken from answers to
91+
# https://stackoverflow.com/questions/67222200/runtimeerror-abortoom-build-with-s-assertions-1-for-more-info
7692
set_target_properties(DynamicLibraryManagerTests PROPERTIES
7793
COMPILE_FLAGS "-s MAIN_MODULE=1"
7894
LINK_FLAGS "-s MAIN_MODULE=1 -s WASM_BIGINT -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]' --preload-file ${SYSROOT_PATH}/include@/include -s ALLOW_MEMORY_GROWTH=1"

0 commit comments

Comments
 (0)