Skip to content

Commit f2ef034

Browse files
[CMake] Add option for building w/ ThreadSanitizer
1 parent 8c2a041 commit f2ef034

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

CMakeLists.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ else()
4545
set(USE_LIBCXX_default FALSE)
4646
endif()
4747

48-
option(BUILD_SHARED_LIBS "Build mutable as a shared library" OFF)
49-
option(ENABLE_SANITIZERS "Build mutable with address and UB sanitizers" ON)
50-
option(ENABLE_SANITY_FIELDS "Build mutable with sanity fields enabled" ON)
51-
option(USE_LIBCXX "Use libcxx (aka. libc++), LLVM's new implementation of the C++ standard library, instead of GNU's libstdc++" ${USE_LIBCXX_default})
52-
option(USE_LLD "Use LLD, a linker from the LLVM project" ${HAS_LLD})
48+
option(BUILD_SHARED_LIBS "Build mutable as a shared library" OFF)
49+
option(ENABLE_SANITIZERS "Build mutable with address and UB sanitizers" ON)
50+
option(ENABLE_THREAD_SANITIZER "Build mutable with thread sanitizer" OFF)
51+
option(ENABLE_SANITY_FIELDS "Build mutable with sanity fields enabled" ON)
52+
option(USE_LIBCXX "Use libcxx (aka. libc++), LLVM's new implementation of the C++ standard library, instead of GNU's libstdc++" ${USE_LIBCXX_default})
53+
option(USE_LLD "Use LLD, a linker from the LLVM project" ${HAS_LLD})
5354

5455
# Enable backends
55-
option(WITH_V8 "Build with the V8-based WebAssembly execution backend." ON)
56+
option(WITH_V8 "Build with the V8-based WebAssembly execution backend." ON)
5657

5758
if(${BUILD_SHARED_LIBS})
5859
set(LIB_TYPE SHARED)
@@ -159,10 +160,18 @@ if(${USE_LLD})
159160
add_link_options("-fuse-ld=lld")
160161
endif()
161162

163+
if (${ENABLE_SANITIZERS} AND ${ENABLE_THREAD_SANITIZER})
164+
message(SEND_ERROR "ENABLE_SANITIZERS and ENABLE_THREAD_SANITIZER are mutually exclusive. Cannot combine UBSan and ASan with ThreadSan.")
165+
endif()
166+
162167
if(${ENABLE_SANITIZERS})
163168
message("[mutable] Compiling with address and UB sanitizers")
164169
add_compile_options(-fsanitize=address -fsanitize=undefined -fno-sanitize=vptr -fsanitize-link-c++-runtime)
165170
add_link_options(-fsanitize=address -fsanitize=undefined -fno-sanitize=vptr -fsanitize-link-c++-runtime)
171+
elseif(${ENABLE_THREAD_SANITIZER})
172+
message("[mutable] Compiling with thread sanitizer")
173+
add_compile_options(-fsanitize=thread -fsanitize-link-c++-runtime)
174+
add_link_options(-fsanitize=thread -fsanitize-link-c++-runtime)
166175
endif()
167176

168177
if(${ENABLE_SANITY_FIELDS})

0 commit comments

Comments
 (0)