From 42c7e1d073d6e8070d5483bfdf30f5039a69b264 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Tue, 5 Mar 2024 11:05:38 -0600 Subject: Ignore UserPresets and Use only C compiler for sanitizers (#4066) * Remove user presets file * Only use C compiler for sanitzers --- .gitignore | 1 + HDF5Examples/CMakeUserPresets.json | 244 ------------------------------------- config/sanitizer/sanitizers.cmake | 44 +++---- 3 files changed, 23 insertions(+), 266 deletions(-) delete mode 100644 HDF5Examples/CMakeUserPresets.json diff --git a/.gitignore b/.gitignore index cbaccb2..d2fc4c7 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ src/H5version.h /.classpath /CMakeUserPresets.json +HDF5Examples/CMakeUserPresets.json diff --git a/HDF5Examples/CMakeUserPresets.json b/HDF5Examples/CMakeUserPresets.json deleted file mode 100644 index 5b479be..0000000 --- a/HDF5Examples/CMakeUserPresets.json +++ /dev/null @@ -1,244 +0,0 @@ -{ - "version": 6, - "configurePresets": [ - { - "name": "my-HDF5114", - "hidden": true, - "environment": { - "HDF5_ROOT": "${sourceParentDir}/temp/HDF_Group/HDF5/1.14.3", - "HDF5_PLUGIN_PATH": "${sourceParentDir}/temp/HDF_Group/HDF5/1.14.3/lib/plugin" - }, - "cacheVariables": { - "HDF5_ROOT": {"type": "STRING", "value": "${sourceParentDir}/temp/HDF_Group/HDF5/1.14.3"}, - "HDF_BUILD_FORTRAN": "ON", - "HDF_BUILD_JAVA": "ON", - "HDF_BUILD_FILTERS": "ON", - "H5EX_BUILD_TESTING": "ON" - } - }, - { - "name": "my-HDF5Dev", - "hidden": true, - "environment": { - "HDF5_ROOT": "${sourceParentDir}/temp/HDF_Group/HDF5/1.15.0", - "HDF5_PLUGIN_PATH": "${sourceParentDir}/temp/HDF_Group/HDF5/1.15.0/lib/plugin" - }, - "cacheVariables": { - "HDF5_ROOT": {"type": "STRING", "value": "${sourceParentDir}/temp/HDF_Group/HDF5/1.15.0"}, - "HDF_BUILD_FORTRAN": "ON", - "HDF_BUILD_JAVA": "ON", - "HDF_BUILD_FILTERS": "ON", - "H5EX_BUILD_TESTING": "ON" - } - }, - { - "name": "my-StdShar", - "hidden": true, - "inherits": ["ci-base", "ci-base-examples", "ci-StdPlugins"], - "cacheVariables": { - "BUILD_SHARED_LIBS": "ON", - "USE_SHARED_LIBS": "ON" - } - }, - { - "name": "my-StdShar-MSVC", - "description": "MSVC Standard Config for x64 (Release)", - "inherits": [ - "ci-x64-Release-MSVC", - "my-StdShar", - "my-HDF5Dev" - ] - }, - { - "name": "my-StdShar-Clang", - "description": "Clang Standard Config for x64 (Release)", - "inherits": [ - "ci-x64-Release-Clang", - "my-StdShar", - "my-HDF5Dev" - ] - }, - { - "name": "my-StdShar-GNUC", - "description": "GNUC Standard Config for x64 (Release)", - "inherits": [ - "ci-x64-Release-GNUC", - "my-StdShar", - "my-HDF5Dev" - ] - }, - { - "name": "my-114Shar-MSVC", - "description": "MSVC 1.14 Config for x64 (Release)", - "inherits": [ - "ci-x64-Release-MSVC", - "my-StdShar", - "my-HDF5114" - ] - }, - { - "name": "my-114Shar-Clang", - "description": "Clang 1.14 Config for x64 (Release)", - "inherits": [ - "ci-x64-Release-Clang", - "my-StdShar", - "my-HDF5114" - ] - }, - { - "name": "my-114Shar-GNUC", - "description": "GNUC 1.14 Config for x64 (Release)", - "inherits": [ - "ci-x64-Release-GNUC", - "my-StdShar", - "my-HDF5114" - ] - } - ], - "buildPresets": [ - { - "name": "my-StdShar-MSVC", - "description": "MSVC Standard Build for x64 (Release)", - "configurePreset": "my-StdShar-MSVC", - "inherits": [ - "ci-x64-Release-MSVC" - ] - }, - { - "name": "my-StdShar-Clang", - "description": "Clang Standard Build for x64 (Release)", - "configurePreset": "my-StdShar-Clang", - "inherits": [ - "ci-x64-Release-Clang" - ] - }, - { - "name": "my-StdShar-GNUC", - "description": "GNUC Standard Build for x64 (Release)", - "configurePreset": "my-StdShar-GNUC", - "verbose": true, - "inherits": [ - "ci-x64-Release-GNUC" - ] - }, - { - "name": "my-114Shar-MSVC", - "description": "MSVC 1.14 Build for x64 (Release)", - "configurePreset": "my-114Shar-MSVC", - "inherits": [ - "ci-x64-Release-MSVC" - ] - }, - { - "name": "my-114Shar-Clang", - "description": "Clang 1.14 Build for x64 (Release)", - "configurePreset": "my-114Shar-Clang", - "inherits": [ - "ci-x64-Release-Clang" - ] - }, - { - "name": "my-114Shar-GNUC", - "description": "GNUC 1.14 Build for x64 (Release)", - "configurePreset": "my-114Shar-GNUC", - "verbose": true, - "inherits": [ - "ci-x64-Release-GNUC" - ] - } - ], - "testPresets": [ - { - "name": "my-StdShar-MSVC", - "configurePreset": "my-StdShar-MSVC", - "inherits": [ - "ci-x64-Release-MSVC" - ] - }, - { - "name": "my-StdShar-Clang", - "configurePreset": "my-StdShar-Clang", - "inherits": [ - "ci-x64-Release-Clang" - ] - }, - { - "name": "my-StdShar-GNUC", - "configurePreset": "my-StdShar-GNUC", - "inherits": [ - "ci-x64-Release-GNUC" - ] - }, - { - "name": "my-114Shar-MSVC", - "configurePreset": "my-114Shar-MSVC", - "inherits": [ - "ci-x64-Release-MSVC" - ] - }, - { - "name": "my-114Shar-Clang", - "configurePreset": "my-114Shar-Clang", - "inherits": [ - "ci-x64-Release-Clang" - ] - }, - { - "name": "my-114Shar-GNUC", - "configurePreset": "my-114Shar-GNUC", - "inherits": [ - "ci-x64-Release-GNUC" - ] - } - ], - "workflowPresets": [ - { - "name": "my-StdShar-MSVC", - "steps": [ - {"type": "configure", "name": "my-StdShar-MSVC"}, - {"type": "build", "name": "my-StdShar-MSVC"}, - {"type": "test", "name": "my-StdShar-MSVC"} - ] - }, - { - "name": "my-StdShar-Clang", - "steps": [ - {"type": "configure", "name": "my-StdShar-Clang"}, - {"type": "build", "name": "my-StdShar-Clang"}, - {"type": "test", "name": "my-StdShar-Clang"} - ] - }, - { - "name": "my-StdShar-GNUC", - "steps": [ - {"type": "configure", "name": "my-StdShar-GNUC"}, - {"type": "build", "name": "my-StdShar-GNUC"}, - {"type": "test", "name": "my-StdShar-GNUC"} - ] - }, - { - "name": "my-114Shar-MSVC", - "steps": [ - {"type": "configure", "name": "my-114Shar-MSVC"}, - {"type": "build", "name": "my-114Shar-MSVC"}, - {"type": "test", "name": "my-114Shar-MSVC"} - ] - }, - { - "name": "my-114Shar-Clang", - "steps": [ - {"type": "configure", "name": "my-114Shar-Clang"}, - {"type": "build", "name": "my-114Shar-Clang"}, - {"type": "test", "name": "my-114Shar-Clang"} - ] - }, - { - "name": "my-114Shar-GNUC", - "steps": [ - {"type": "configure", "name": "my-114Shar-GNUC"}, - {"type": "build", "name": "my-114Shar-GNUC"}, - {"type": "test", "name": "my-114Shar-GNUC"} - ] - } - ] -} \ No newline at end of file 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() -- cgit v0.12