summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-02-12 15:42:23 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-02-12 15:42:23 (GMT)
commita68302883a243c33ceb495e3e151331fa267f455 (patch)
tree4a85b8c5c96bd9664b5f3dd180e555ea71b92f52
parentb8a57cb8dcd991f95a725c5691378d78a387fcbb (diff)
downloadhdf5-a68302883a243c33ceb495e3e151331fa267f455.zip
hdf5-a68302883a243c33ceb495e3e151331fa267f455.tar.gz
hdf5-a68302883a243c33ceb495e3e151331fa267f455.tar.bz2
TRILAB-148 fix sanitizer and -fsanitize usage
-rw-r--r--CMakeLists.txt3
-rw-r--r--config/cmake/HDFCompilerFlags.cmake4
-rw-r--r--config/sanitizer/sanitizers.cmake27
3 files changed, 17 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dbbf55f..129a73a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -394,9 +394,6 @@ HDF_DIR_PATHS(${HDF5_PACKAGE_NAME})
include (${HDF_RESOURCES_EXT_DIR}/HDFLibMacros.cmake)
include (${HDF_RESOURCES_DIR}/HDF5Macros.cmake)
-if (HDF5_ENABLE_SANITIZERS)
- include (${HDF5_SOURCE_DIR}/config/sanitizer/sanitizers.cmake)
-endif ()
#-----------------------------------------------------------------------------
# Targets built within this project are exported at Install time for use
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index ea85736..17b0854 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -30,8 +30,10 @@ macro (ADD_H5_FLAGS h5_flag_var infile)
#message (STATUS "h5_flag_var=${${h5_flag_var}}")
endmacro ()
-message (STATUS "Warnings Configuration:")
set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}")
+set (CMAKE_C_FLAGS "${CMAKE_C_SANITIZER_FLAGS} ${CMAKE_C_FLAGS}")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}")
+message (STATUS "Warnings Configuration: default: ${CMAKE_C_FLAGS} : ${CMAKE_CXX_FLAGS}")
#-----------------------------------------------------------------------------
# Compiler specific flags : Shouldn't there be compiler tests for these
#-----------------------------------------------------------------------------
diff --git a/config/sanitizer/sanitizers.cmake b/config/sanitizer/sanitizers.cmake
index 2625ec3..ecee2de 100644
--- a/config/sanitizer/sanitizers.cmake
+++ b/config/sanitizer/sanitizers.cmake
@@ -28,52 +28,53 @@ function(append value)
endforeach(variable)
endfunction()
-if(USE_SANITIZER AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+message(STATUS "USE_SANITIZER=${USE_SANITIZER}, CMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}")
+if(USE_SANITIZER AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
- append("-fno-omit-frame-pointer" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fno-omit-frame-pointer" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}")
if(UNIX)
if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
- append("-O1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-O1" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
endif()
if(USE_SANITIZER MATCHES "([Aa]ddress);([Uu]ndefined)"
OR USE_SANITIZER MATCHES "([Uu]ndefined);([Aa]ddress)")
message(STATUS "Building with Address, Undefined sanitizers")
- append("-fsanitize=address,undefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=address,undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
set(MEMCHECK_TYPE AddressSanitizer)
elseif(USE_SANITIZER MATCHES "([Aa]ddress)")
# Optional: -fno-optimize-sibling-calls -fsanitize-address-use-after-scope
message(STATUS "Building with Address sanitizer")
- append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
set(MEMCHECK_TYPE AddressSanitizer)
elseif(USE_SANITIZER MATCHES "([Mm]emory([Ww]ith[Oo]rigins)?)")
# Optional: -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2
- append("-fsanitize=memory" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=memory" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
if(USE_SANITIZER MATCHES "([Mm]emory[Ww]ith[Oo]rigins)")
message(STATUS "Building with MemoryWithOrigins sanitizer")
- append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize-memory-track-origins" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
else()
message(STATUS "Building with Memory sanitizer")
endif()
set(MEMCHECK_TYPE MemorySanitizer)
elseif(USE_SANITIZER MATCHES "([Uu]ndefined)")
message(STATUS "Building with Undefined sanitizer")
- append("-fsanitize=undefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
if(EXISTS "${BLACKLIST_FILE}")
- append("-fsanitize-blacklist=${BLACKLIST_FILE}" CMAKE_C_FLAGS
- CMAKE_CXX_FLAGS)
+ append("-fsanitize-blacklist=${BLACKLIST_FILE}" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
endif()
set(MEMCHECK_TYPE UndefinedBehaviorSanitizer)
elseif(USE_SANITIZER MATCHES "([Tt]hread)")
message(STATUS "Building with Thread sanitizer")
- append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=thread" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
set(MEMCHECK_TYPE ThreadSanitizer)
elseif(USE_SANITIZER MATCHES "([Ll]eak)")
message(STATUS "Building with Leak sanitizer")
- append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=leak" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
set(MEMCHECK_TYPE LeakSanitizer)
else()
message(
@@ -82,7 +83,7 @@ if(USE_SANITIZER AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
elseif(MSVC)
if(USE_SANITIZER MATCHES "([Aa]ddress)")
message(STATUS "Building with Address sanitizer")
- append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
else()
message(
FATAL_ERROR