Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc64a7e

Browse files
committed
CMake: Provide -fsanitize flag, also specify initial_memory=512Mb
Add info about the new flags
1 parent b3278fa commit fc64a7e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bin/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ if (HAVE_BUILD_TO_WASM)
5656
# "-s ALLOW_MEMORY_GROWTH": Allow dynamic memory growth upto the maximum page size limit
5757
# "-s WASM_BIGINT": Allow use of i64 integers. ASR is needing this option to be enabled.
5858
# "-s EXPORTED_RUNTIME_METHODS=['cwrap']": Export cwarp. cwarp helps us to call our EMSCRIPTEN_KEEPALIVE functions
59+
# "-fsanitize=undefined": Clang's Undefined Behaviour Sanitizer. The LPython parser segfaults.
60+
# This option is for debugging, but currently helps avoid the segfault in the parser.
61+
# "-s INITIAL_MEMORY=536870912": Start the wasm linear memory with sufficiently large size 512Mb.
5962

6063
# Notes:
6164
# STANDALONE_WASM is disabling support for exceptions, so it is currently omitted
6265
# In build_to_wasm.sh, we need CMAKE_CXX_FLAGS_DEBUG="-Wall -Wextra -fexceptions" flags for exception support
63-
set(WASM_COMPILE_FLAGS "-g0 -fexceptions")
66+
set(WASM_COMPILE_FLAGS "-g0 -fexceptions -fsanitize=undefined")
6467
set(WASM_LINK_FLAGS
65-
"-g0 -Oz -fexceptions --preload-file asset_dir -Wall -Wextra --no-entry -s ASSERTIONS -s ALLOW_MEMORY_GROWTH=1 -s WASM_BIGINT -s \"EXPORTED_RUNTIME_METHODS=['cwrap']\""
68+
"-g0 -Oz -fexceptions -fsanitize=undefined --preload-file asset_dir -Wall -Wextra --no-entry -sASSERTIONS=1 -s INITIAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1 -s WASM_BIGINT -s \"EXPORTED_RUNTIME_METHODS=['cwrap']\""
6669
)
6770
set_target_properties(lpython PROPERTIES COMPILE_FLAGS ${WASM_COMPILE_FLAGS})
6871
set_target_properties(lpython PROPERTIES LINK_FLAGS ${WASM_LINK_FLAGS})

0 commit comments

Comments
 (0)