mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
Ignore UserPresets and Use only C compiler for sanitizers (#4066)
* Remove user presets file * Only use C compiler for sanitzers
This commit is contained in:
parent
f5f6975c2f
commit
42c7e1d073
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ src/H5version.h
|
||||
|
||||
/.classpath
|
||||
/CMakeUserPresets.json
|
||||
HDF5Examples/CMakeUserPresets.json
|
||||
|
@ -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"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user