diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2024-03-05 17:05:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 17:05:38 (GMT) |
commit | 42c7e1d073d6e8070d5483bfdf30f5039a69b264 (patch) | |
tree | 38d7df22098420596a35049b21561688140abf8d /config/sanitizer | |
parent | f5f6975c2fc123a2c7f9d26cdbcda87d31ac4ea8 (diff) | |
download | hdf5-42c7e1d073d6e8070d5483bfdf30f5039a69b264.zip hdf5-42c7e1d073d6e8070d5483bfdf30f5039a69b264.tar.gz hdf5-42c7e1d073d6e8070d5483bfdf30f5039a69b264.tar.bz2 |
Ignore UserPresets and Use only C compiler for sanitizers (#4066)
* Remove user presets file
* Only use C compiler for sanitzers
Diffstat (limited to 'config/sanitizer')
-rw-r--r-- | config/sanitizer/sanitizers.cmake | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/config/sanitizer/sanitizers.cmake b/config/sanitizer/sanitizers.cmake index 53591d2..bf2aad2 100644 --- a/config/sanitizer/sanitizers.cmake +++ b/config/sanitizer/sanitizers.cmake @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations under # the License. -include(CheckCXXSourceCompiles) - set(USE_SANITIZER "" CACHE @@ -44,11 +42,12 @@ function(test_san_flags return_var flags) unset(${return_var} CACHE) set(FLAGS_BACKUP ${CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS "${flags}") - check_cxx_source_compiles("int main() { return 0; }" ${return_var}) + check_c_source_compiles("int main() { return 0; }" ${return_var}) set(CMAKE_REQUIRED_FLAGS "${FLAGS_BACKUP}") set(CMAKE_REQUIRED_QUIET "${QUIET_BACKUP}") endfunction() +message(STATUS "USE_SANITIZER=${USE_SANITIZER}, CMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}") if(USE_SANITIZER) if(CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -56,10 +55,11 @@ if(USE_SANITIZER) unset(SANITIZER_SELECTED_FLAGS) if(UNIX) - append("-fno-omit-frame-pointer" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fno-omit-frame-pointer" CMAKE_C_FLAGS) + message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}") if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - append("-O1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-O1" CMAKE_C_FLAGS) endif() if(USE_SANITIZER MATCHES "([Aa]ddress)") @@ -72,10 +72,10 @@ if(USE_SANITIZER) append("${SANITIZER_ADDR_FLAG}" SANITIZER_SELECTED_FLAGS) if(AFL) - append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() - message(FATAL_ERROR "Address sanitizer not available for ${CMAKE_CXX_COMPILER}") + message(FATAL_ERROR "Address sanitizer not available for ${CMAKE_C_COMPILER}") endif() endif() @@ -98,10 +98,10 @@ if(USE_SANITIZER) append("${SANITIZER_MEM_FLAG}" SANITIZER_SELECTED_FLAGS) if(AFL) - append_quoteless(AFL_USE_MSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_MSAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() - message(FATAL_ERROR "Memory [With Origins] sanitizer not available for ${CMAKE_CXX_COMPILER}") + message(FATAL_ERROR "Memory [With Origins] sanitizer not available for ${CMAKE_C_COMPILER}") endif() endif() @@ -117,10 +117,10 @@ if(USE_SANITIZER) append("${SANITIZER_UB_FLAG}" SANITIZER_SELECTED_FLAGS) if(AFL) - append_quoteless(AFL_USE_UBSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_UBSAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() - message(FATAL_ERROR "Undefined Behaviour sanitizer not available for ${CMAKE_CXX_COMPILER}") + message(FATAL_ERROR "Undefined Behaviour sanitizer not available for ${CMAKE_C_COMPILER}") endif() endif() @@ -133,10 +133,10 @@ if(USE_SANITIZER) append("${SANITIZER_THREAD_FLAG}" SANITIZER_SELECTED_FLAGS) if(AFL) - append_quoteless(AFL_USE_TSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_TSAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() - message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_CXX_COMPILER}") + message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_C_COMPILER}") endif() endif() @@ -149,10 +149,10 @@ if(USE_SANITIZER) append("${SANITIZER_LEAK_FLAG}" SANITIZER_SELECTED_FLAGS) if(AFL) - append_quoteless(AFL_USE_LSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_LSAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() - message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_CXX_COMPILER}") + message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_C_COMPILER}") endif() endif() @@ -165,10 +165,10 @@ if(USE_SANITIZER) append("${SANITIZER_LEAK_FLAG}" SANITIZER_SELECTED_FLAGS) if(AFL) - append_quoteless(AFL_USE_CFISAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_CFISAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() - message(FATAL_ERROR "Control Flow Integrity(CFI) sanitizer not available for ${CMAKE_CXX_COMPILER}") + message(FATAL_ERROR "Control Flow Integrity(CFI) sanitizer not available for ${CMAKE_C_COMPILER}") endif() endif() @@ -176,17 +176,17 @@ if(USE_SANITIZER) test_san_flags(SANITIZER_SELECTED_COMPATIBLE ${SANITIZER_SELECTED_FLAGS}) if(SANITIZER_SELECTED_COMPATIBLE) message(STATUS " Building with ${SANITIZER_SELECTED_FLAGS}") - append("${SANITIZER_SELECTED_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("${SANITIZER_SELECTED_FLAGS}" CMAKE_C_FLAGS) else() - message(FATAL_ERROR " Sanitizer flags ${SANITIZER_SELECTED_FLAGS} are not compatible.") + message(FATAL_ERROR "Unsupported value of USE_SANITIZER: ${USE_SANITIZER}") endif() 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_FLAGS) if(AFL) - append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER) + append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER) endif() else() message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}") @@ -197,7 +197,7 @@ if(USE_SANITIZER) 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_FLAGS) else() message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}") endif() |