Skip to content

Commit 73e1f36

Browse files
committed
added sanitizer
1 parent 060235a commit 73e1f36

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(ARCH "x64" CACHE STRING "Arch")
66
option(BUILD_SHARED "Option to build shared library" ON)
77
option(BUILD_STATIC "Option to build static library" ON)
88
option(POST_BUILD_COPY_EXT_LIBS "Option to copy external libraries to build directory" ON)
9+
option(ENABLE_SANITIZERS "Enable AddressSanitizer and UBSan for Debug builds" OFF)
910

1011
message(STATUS "PLATFORM: ${PLATFORM}")
1112
message(STATUS "ARCH: ${ARCH}")
@@ -67,6 +68,16 @@ set(CMAKE_C_STANDARD 99)
6768
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
6869
set(CMAKE_C_VISIBILITY_PRESET hidden)
6970

71+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
72+
if(ENABLE_SANITIZERS AND (PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux"))
73+
add_compile_options(-fsanitize=address)
74+
add_link_options(-fsanitize=address)
75+
76+
add_compile_options(-fsanitize=undefined)
77+
add_link_options(-fsanitize=undefined)
78+
endif()
79+
endif()
80+
7081
set(DMDUTIL_SOURCES
7182
src/Config.cpp
7283
src/DMD.cpp

platforms/config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
LIBZEDMD_SHA=154772800e8f36378c629f066bfee563862728ac
6-
LIBSERUM_SHA=a6d43762884b36151ab4e967ebe04cc1a1dde4e8
6+
LIBSERUM_SHA=34e8ad23837b30acaade1e9aaa773d8ea3340622
77
LIBPUPDMD_SHA=124f45e5ddd59ceb339591de88fcca72f8c54612
88

99
if [ -z "${BUILD_TYPE}" ]; then

platforms/macos/arm64/external.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ cmake \
5959
-DARCH=arm64 \
6060
-DBUILD_SHARED=ON \
6161
-DBUILD_STATIC=OFF \
62+
-DENABLE_SANITIZERS=ON \
6263
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
6364
-B build
6465
cmake --build build -- -j${NUM_PROCS}

0 commit comments

Comments
 (0)