Skip to content

Commit

Permalink
asan / ubsan in cmakelists
Browse files Browse the repository at this point in the history
  • Loading branch information
mathis committed Sep 15, 2022
1 parent 29578bf commit fa430d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endif ()

set(BUILD_TARGET client CACHE STRING "Choose build target client/server" )
set(BUILD_PLATFORM app CACHE STRING "Choose targer platform wasm/app" )
set(ENABLE_SANITIZERS OFF CACHE BOOL "Enable ASan / UBSan sanitizers (in debug mode)" )

message(STATUS "Build Target : ${BUILD_TARGET}")
message(STATUS "Build Platform : ${BUILD_PLATFORM}")
Expand Down
16 changes: 16 additions & 0 deletions OpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ else () # wasm
"-fno-rtti \
-Wno-pthreads-mem-growth \
-pthread \
-fsanitize=undefined \
-fsanitize=address \
-s PTHREAD_POOL_SIZE=5 \
-s WASM=1 \
-s USE_SDL=2 \
Expand All @@ -307,16 +309,21 @@ else () # wasm
-s ABORT_ON_WASM_EXCEPTIONS=1 \
-s EXIT_RUNTIME=1 \
-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=wsSendMessage \
-s ASSERTIONS=2 \
-s STACK_OVERFLOW_CHECK=2 \
--preload-file ${CMAKE_SOURCE_DIR}/OpenGL/data@data \
--preload-file ${CMAKE_SOURCE_DIR}/OpenGL/src@src \
-Wno-unused-command-line-argument \
--source-map-base sources/build/Client/Wasm/Debug/ \
-gsource-map -O0"
# -s SAFE_HEAP=1 \
)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
"-fno-rtti \
-Wno-pthreads-mem-growth \
-pthread \
-fsanitize=undefined \
-fsanitize=address \
-s PTHREAD_POOL_SIZE=5 \
-s WASM=1 \
-s USE_SDL=2 \
Expand All @@ -336,11 +343,14 @@ else () # wasm
-s DEMANGLE_SUPPORT=1 \
-s ABORT_ON_WASM_EXCEPTIONS=1 \
-s EXIT_RUNTIME=1 \
-s ASSERTIONS=2 \
-s STACK_OVERFLOW_CHECK=2 \
--preload-file ${CMAKE_SOURCE_DIR}/OpenGL/data@data \
--preload-file ${CMAKE_SOURCE_DIR}/OpenGL/src@src \
-Wno-unused-command-line-argument \
--source-map-base sources/build/Client/Wasm/Debug/ \
-gsource-map -O0"
# -s SAFE_HEAP=1 \
)
endif ()

Expand Down Expand Up @@ -395,3 +405,9 @@ endif ()
# configure logger
target_compile_definitions(${PROJECT_NAME} PUBLIC "$<$<CONFIG:DEBUG>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>")
target_compile_definitions(${PROJECT_NAME} PUBLIC "$<$<CONFIG:DEBUG>:DEBUG>")

# ASan / UBSan
if (${ENABLE_SANITIZERS})
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined")
endif ()
2 changes: 1 addition & 1 deletion OpenGL/src/multiplayer/terrain/PendingChunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PendingChunks::~PendingChunks() {
stopFlag = true;
}
stopSignal.notify_all();
thread.join();
thread.join(); // COMBAK: waiting on the main thread is problematic on wasm.
}

void PendingChunks::update(vec3 playerPos) {
Expand Down

0 comments on commit fa430d2

Please sign in to comment.