Skip to content

Commit

Permalink
1393 add undefined behavior sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Sep 15, 2021
1 parent c8a2c2f commit 82561cc
Show file tree
Hide file tree
Showing 43 changed files with 200 additions and 57 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
VT_MIMALLOC: 0
VT_DOCS: 1
VT_ASAN: 0
VT_UBSAN: 0
TOKEN: ${{ secrets.GH_PAT }}

steps:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ endif()
option(vt_mimalloc_enabled "Build VT with mimalloc" OFF)
option(vt_mimalloc_static "Build VT with mimalloc using static linking" ON)
option(vt_asan_enabled "Build VT with address sanitizer" OFF)
option(vt_ubsan_enabled "Build VT with undefined behavior sanitizer" OFF)

option(vt_werror_enabled "Build VT with -Werror enabled" OFF)
if (vt_werror_enabled)
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-10-alpine-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
3 changes: 2 additions & 1 deletion ci/azure/azure-clang-10-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
############## Warning this is a generated file---do not modify ###############
###############################################################################

name: PR tests (clang-10, ubuntu, mpich)
name: PR tests (clang-10, ubuntu, mpich, undefined behavior sanitizer)

trigger:
branches:
Expand Down Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 1
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-3.9-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-5.0-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-9-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-10-ubuntu-openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-5-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-6-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-7-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-8-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 1
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 0
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-9-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 1
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-intel-18-ubuntu-mpich-extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 0
VT_POOL: 0
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-intel-18-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 0
VT_EXTENDED_TESTS: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-intel-19-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 0
VT_EXTENDED_TESTS: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-nvidia-10-ubuntu-mpich-extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 0
VT_POOL: 0
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-nvidia-10-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 0
VT_EXTENDED_TESTS: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-nvidia-11-ubuntu-mpich-extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 0
VT_POOL: 0
VT_EXTENDED_TESTS: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-nvidia-11-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ variables:
VT_MIMALLOC: 0
VT_DOCS: 0
VT_ASAN: 0
VT_UBSAN: 0
VT_WERROR: 1
VT_POOL: 0
VT_EXTENDED_TESTS: 0
Expand Down
1 change: 1 addition & 0 deletions ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-Dvt_doxygen_enabled="${VT_DOXYGEN_ENABLED:-0}" \
-Dvt_mimalloc_enabled="${VT_MIMALLOC_ENABLED:-0}" \
-Dvt_asan_enabled="${VT_ASAN_ENABLED:-0}" \
-Dvt_ubsan_enabled="${VT_UBSAN_ENABLED:-0}" \
-Dvt_werror_enabled="${VT_WERROR_ENABLED:-0}" \
-Dvt_pool_enabled="${VT_POOL_ENABLED:-1}" \
-Dvt_build_extended_tests="${VT_EXTENDED_TESTS_ENABLED:-1}" \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/alpine-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -75,6 +76,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_PRODUCTION_BUILD_ENABLED=${VT_PRODUCTION_BUILD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/develop.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_ZOLTAN_ENABLED
Expand All @@ -52,6 +53,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-18.04-clang-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -74,6 +75,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_PRODUCTION_BUILD_ENABLED=${VT_PRODUCTION_BUILD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-18.04-gnu-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -100,6 +101,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-18.04-gnu-docs.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -68,6 +69,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_PRODUCTION_BUILD_ENABLED=${VT_PRODUCTION_BUILD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-18.04-intel-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -74,6 +75,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-18.04-nvidia-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -115,6 +116,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_EXTENDED_TESTS_ENABLED=${VT_EXTENDED_TESTS_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-20.04-clang-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -74,6 +75,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-20.04-gnu-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -94,6 +95,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
Expand Down
2 changes: 2 additions & 0 deletions ci/docker/ubuntu-20.04-gnu-openmpi-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_ASAN_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
Expand All @@ -99,6 +100,7 @@ ENV VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
Expand Down
1 change: 1 addition & 0 deletions ci/test_spack_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ git clone https://github.com/DARMA-tasking/spack-package.git
doxygen_enabled="$VT_DOXYGEN_ENABLED" \
mimalloc_enabled="$VT_MIMALLOC_ENABLED" \
asan_enabled="$VT_ASAN_ENABLED" \
ubsan_enabled="$VT_UBSAN_ENABLED" \
werror_enabled="$VT_WERROR_ENABLED" \
pool_enabled="$VT_POOL_ENABLED" \
zoltan_enabled="$VT_ZOLTAN_ENABLED" \
Expand Down
4 changes: 4 additions & 0 deletions cmake-modules/SetCXXCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ elseif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
message(FATAL_ERROR "Your C++ compiler may not support C++14.")
endif ()

if (vt_ubsan_enabled)
add_definitions(-DVT_UBSAN_ENABLED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
endmacro()
4 changes: 4 additions & 0 deletions cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,8 @@ function(link_target_with_vt)
if (vt_asan_enabled)
target_link_libraries(${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} -fsanitize=address)
endif()

if (vt_ubsan_enabled)
target_link_libraries(${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} -fsanitize=undefined)
endif()
endfunction()
15 changes: 14 additions & 1 deletion cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (vt_mimalloc_enabled)
endif()
endif()

# Check if address sanitizer can be enabled
# Check if sanitizers can be enabled
if (vt_asan_enabled)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
Expand All @@ -60,3 +60,16 @@ if (vt_asan_enabled)
message(SEND_ERROR "Cannot use ASAN without clang or gcc >= 4.8")
endif()
endif()

if (vt_ubsan_enabled)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
(CMAKE_CXX_COMPILER_ID
STREQUAL
"GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8"))
message(STATUS "Building with undefined behavior sanitizer enabled")
else()
message(SEND_ERROR "Cannot use UBSan without clang or gcc >= 4.8")
endif()
endif()
Loading

0 comments on commit 82561cc

Please sign in to comment.