Skip to content

Commit

Permalink
Merge branch 'develop' into H5Rs
Browse files Browse the repository at this point in the history
  • Loading branch information
brtnfld authored Apr 30, 2024
2 parents 2eb91a7 + b23affc commit 078350f
Show file tree
Hide file tree
Showing 93 changed files with 14,410 additions and 12,472 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/h5py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Run a multi-line script
run: |
sed -i 's/hdf5@1.8.4:1.14/hdf5@1.8.4:/g' \
sed -i 's/hdf5@1.10.4:1.14/hdf5@1.10.4:/g' \
./spack/var/spack/repos/builtin/packages/py-h5py/package.py
. ./spack/share/spack/setup-env.sh
./spack/bin/spack spec py-h5py@master+mpi ^[email protected]
Expand Down
72 changes: 36 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,42 @@ if (BUILD_STATIC_EXECS)
endif ()
endif ()

option (HDF5_ENABLE_ANALYZER_TOOLS "enable the use of Clang tools" OFF)
mark_as_advanced (HDF5_ENABLE_ANALYZER_TOOLS)
if (HDF5_ENABLE_ANALYZER_TOOLS)
include (${HDF5_SOURCE_DIR}/config/sanitizer/tools.cmake)
endif ()
option (HDF5_ENABLE_SANITIZERS "execute the Clang sanitizer" OFF)
mark_as_advanced (HDF5_ENABLE_SANITIZERS)
if (HDF5_ENABLE_SANITIZERS)
include (${HDF5_SOURCE_DIR}/config/sanitizer/sanitizers.cmake)
endif ()
option (HDF5_ENABLE_FORMATTERS "format source files" OFF)
mark_as_advanced (HDF5_ENABLE_FORMATTERS)
if (HDF5_ENABLE_FORMATTERS)
include (${HDF5_SOURCE_DIR}/config/sanitizer/formatting.cmake)
endif ()

#-----------------------------------------------------------------------------
# Option to use code coverage
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" OFF)
if (HDF5_ENABLE_COVERAGE)
include (${HDF5_SOURCE_DIR}/config/sanitizer/code-coverage.cmake)
if(CODE_COVERAGE AND CODE_COVERAGE_ADDED)
add_code_coverage () # Adds instrumentation to all targets
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --coverage -O0 -fprofile-arcs -ftest-coverage")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (LDFLAGS "${LDFLAGS} -fprofile-arcs -ftest-coverage")
link_libraries (gcov)
else ()
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif ()
endif ()
endif ()

#-----------------------------------------------------------------------------
# Option to indicate using a memory checker
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1147,40 +1183,4 @@ if (EXISTS "${HDF5_SOURCE_DIR}/HDF5Examples" AND IS_DIRECTORY "${HDF5_SOURCE_DIR
endif ()
endif ()

option (HDF5_ENABLE_ANALYZER_TOOLS "enable the use of Clang tools" OFF)
mark_as_advanced (HDF5_ENABLE_ANALYZER_TOOLS)
if (HDF5_ENABLE_ANALYZER_TOOLS)
include (${HDF5_SOURCE_DIR}/config/sanitizer/tools.cmake)
endif ()
option (HDF5_ENABLE_SANITIZERS "execute the Clang sanitizer" OFF)
mark_as_advanced (HDF5_ENABLE_SANITIZERS)
if (HDF5_ENABLE_SANITIZERS)
include (${HDF5_SOURCE_DIR}/config/sanitizer/sanitizers.cmake)
endif ()
option (HDF5_ENABLE_FORMATTERS "format source files" OFF)
mark_as_advanced (HDF5_ENABLE_FORMATTERS)
if (HDF5_ENABLE_FORMATTERS)
include (${HDF5_SOURCE_DIR}/config/sanitizer/formatting.cmake)
endif ()

#-----------------------------------------------------------------------------
# Option to use code coverage
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" OFF)
if (HDF5_ENABLE_COVERAGE)
include (${HDF5_SOURCE_DIR}/config/sanitizer/code-coverage.cmake)
if(CODE_COVERAGE AND CODE_COVERAGE_ADDED)
add_code_coverage () # Adds instrumentation to all targets
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --coverage -O0 -fprofile-arcs -ftest-coverage")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (LDFLAGS "${LDFLAGS} -fprofile-arcs -ftest-coverage")
link_libraries (gcov)
else ()
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif ()
endif ()
endif ()

include (CMakeInstallation.cmake)
35 changes: 31 additions & 4 deletions bin/make_err
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ sub create_init ($) {
my $desc; # Description of error message
my $sect_name; # Section of minor error messages
my $sect_desc; # Description of section
my $first_major = 0; # Whether the first major error code was saved
my $first_minor = 0; # Whether the first minor error code was saved

# Rename previous file
# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup";
Expand All @@ -241,12 +243,22 @@ sub create_init ($) {
print HEADER "/* Major error codes */\n";
print HEADER "/*********************/\n\n";
foreach $name (keys %major) {
print HEADER " "x(0*$indent),"assert(${name}_g==(-1));\n";
print HEADER " "x(0*$indent),"assert(${name}_g==H5I_INVALID_HID);\n";
print HEADER " "x(0*$indent),"if((msg = H5E__create_msg(cls, H5E_MAJOR, \"${major{$name}}\"))==NULL)\n";
print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\");\n";
print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, false))<0)\n";
print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\");\n";
if ($first_major == 0) {
print HEADER " "x(0*$indent),"\n/* Remember first major error code ID */\n";
print HEADER " "x(0*$indent),"assert(H5E_first_maj_id_g==H5I_INVALID_HID);\n";
print HEADER " "x(0*$indent),"H5E_first_maj_id_g = ${name}_g;\n\n";
$first_major = 1;
}
$last_name = $name;
}
print HEADER " "x(0*$indent),"\n/* Remember last major error code ID */\n";
print HEADER " "x(0*$indent),"assert(H5E_last_maj_id_g==H5I_INVALID_HID);\n";
print HEADER " "x(0*$indent),"H5E_last_maj_id_g = ${last_name}_g;\n\n";

# Iterate over all the minor error sections
print HEADER "\n/*********************/\n";
Expand All @@ -257,13 +269,24 @@ sub create_init ($) {

# Iterate over all the minor errors in each section
for $name ( @{$section_list{$sect_name}}) {
print HEADER " "x(0*$indent),"assert(${name}_g==(-1));\n";
print HEADER " "x(0*$indent),"assert(${name}_g==H5I_INVALID_HID);\n";
print HEADER " "x(0*$indent),"if((msg = H5E__create_msg(cls, H5E_MINOR, \"${minor{$name}}\"))==NULL)\n";
print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\");\n";
print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, true))<0)\n";
print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\");\n";

if ($first_minor == 0) {
print HEADER " "x(0*$indent),"\n/* Remember first minor error code ID */\n";
print HEADER " "x(0*$indent),"assert(H5E_first_min_id_g==H5I_INVALID_HID);\n";
print HEADER " "x(0*$indent),"H5E_first_min_id_g = ${name}_g;\n\n";
$first_minor = 1;
}
$last_name = $name;
}
}
print HEADER " "x(0*$indent),"\n/* Remember last minor error code ID */\n";
print HEADER " "x(0*$indent),"assert(H5E_last_min_id_g==H5I_INVALID_HID);\n";
print HEADER " "x(0*$indent),"H5E_last_min_id_g = ${last_name}_g;\n";

print_endprotect(*HEADER, $file);

Expand Down Expand Up @@ -299,7 +322,9 @@ sub create_term ($) {
foreach $name (keys %major) {
print HEADER " "x($indent),"\n${name}_g=";
}
print HEADER " (-1);\n";
print HEADER " H5I_INVALID_HID;\n";
print HEADER " "x(0*$indent),"H5E_first_maj_id_g = H5I_INVALID_HID;\n\n";
print HEADER " "x(0*$indent),"H5E_last_maj_id_g = H5I_INVALID_HID;\n\n";

# Iterate over all the minor error sections
print HEADER "\n/* Reset minor error IDs */\n";
Expand All @@ -311,7 +336,9 @@ sub create_term ($) {
print HEADER " "x($indent),"\n${name}_g=";
}
}
print HEADER " (-1);\n";
print HEADER " H5I_INVALID_HID;\n";
print HEADER " "x(0*$indent),"H5E_first_min_id_g = H5I_INVALID_HID;\n\n";
print HEADER " "x(0*$indent),"H5E_last_min_id_g = H5I_INVALID_HID;\n\n";

print_endprotect(*HEADER, $file);

Expand Down
2 changes: 1 addition & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ cp -p Makefile.dist Makefile

# Update README.md and release_docs/RELEASE.txt with release information in
# line 1.
for f in README.md release_docs/RELEASE.txt; do
for f in README.md release_docs/RELEASE.txt release_docs/NEWSLETTER.txt; do
echo "HDF5 version $VERS released on $release_date" >$f.x
sed -e 1d $f >>$f.x
mv $f.x $f
Expand Down
1 change: 1 addition & 0 deletions config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ endif ()
if (MINGW OR NOT WINDOWS)
foreach (other_test
HAVE_ATTRIBUTE
HAVE_BUILTIN_EXPECT
SYSTEM_SCOPE_THREADS
HAVE_SOCKLEN_T
)
Expand Down
3 changes: 3 additions & 0 deletions config/cmake/H5pubconf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@
/* Define to 1 if you have the <szlib.h> header file. */
#cmakedefine H5_HAVE_SZLIB_H @H5_HAVE_SZLIB_H@

/* Define to 1 if the compiler supports the __builtin_expect() extension */
#cmakedefine H5_HAVE_BUILTIN_EXPECT @H5_HAVE_BUILTIN_EXPECT@

#if defined(_WIN32) && !defined(H5_BUILT_AS_DYNAMIC_LIB)
/* Not supported on WIN32 platforms with static linking */
/* #undef H5_HAVE_THREADSAFE */
Expand Down
15 changes: 15 additions & 0 deletions config/cmake/HDFTests.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
#define SIMPLE_TEST(x) int main(void){ x; return 0; }


#ifdef HAVE_BUILTIN_EXPECT

int
main ()
{
void *ptr = (void*) 0;

if (__builtin_expect (ptr != (void*) 0, 1))
return 0;

return 0;
}

#endif /* HAVE_BUILTIN_EXPECT */

#ifdef HAVE_ATTRIBUTE

int
Expand Down
77 changes: 13 additions & 64 deletions config/sanitizer/sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,18 @@ function(test_san_flags return_var flags)
endfunction()

message(STATUS "USE_SANITIZER=${USE_SANITIZER}, CMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}")
if(CMAKE_CXX_COMPILER_LOADED)
message(STATUS "... CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}")
endif()
if(USE_SANITIZER)
if(CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

unset(SANITIZER_SELECTED_FLAGS)

if(UNIX)
append("-fno-omit-frame-pointer" CMAKE_C_FLAGS)
message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}")
if (CMAKE_CXX_COMPILER_LOADED)
append("-fno-omit-frame-pointer" CMAKE_CXX_FLAGS)
endif ()
append("-fno-omit-frame-pointer" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
message(STATUS "Building with sanitize, base flags=${CMAKE_C_FLAGS}")

if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
append("-O1" CMAKE_C_FLAGS)
if (CMAKE_CXX_COMPILER_LOADED)
append("-O1" CMAKE_CXX_FLAGS)
endif ()
append("-O1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()

if(USE_SANITIZER MATCHES "([Aa]ddress)")
Expand All @@ -84,10 +75,7 @@ if(USE_SANITIZER)
append("${SANITIZER_ADDR_FLAG}" SANITIZER_SELECTED_FLAGS)

if(AFL)
append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_ASAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "Address sanitizer not available for ${CMAKE_C_COMPILER}")
Expand Down Expand Up @@ -115,10 +103,7 @@ if(USE_SANITIZER)
append("${SANITIZER_MEM_FLAG}" SANITIZER_SELECTED_FLAGS)

if(AFL)
append_quoteless(AFL_USE_MSAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_MSAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_MSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "Memory [With Origins] sanitizer not available for ${CMAKE_C_COMPILER}")
Expand All @@ -140,16 +125,10 @@ if(USE_SANITIZER)
append("${SANITIZER_UB_FLAG}" SANITIZER_SELECTED_FLAGS)

if(AFL)
append_quoteless(AFL_USE_UBSAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_UBSAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_UBSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "Undefined Behaviour sanitizer not available for ${CMAKE_C_COMPILER}")
if (CMAKE_CXX_COMPILER_LOADED)
message(FATAL_ERROR "Undefined Behaviour sanitizer not available for ${CMAKE_CXX_COMPILER}")
endif ()
endif()
endif()

Expand All @@ -162,16 +141,10 @@ if(USE_SANITIZER)
append("${SANITIZER_THREAD_FLAG}" SANITIZER_SELECTED_FLAGS)

if(AFL)
append_quoteless(AFL_USE_TSAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_TSAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_TSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_C_COMPILER}")
if (CMAKE_CXX_COMPILER_LOADED)
message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_CXX_COMPILER}")
endif ()
endif()
endif()

Expand All @@ -184,16 +157,10 @@ if(USE_SANITIZER)
append("${SANITIZER_LEAK_FLAG}" SANITIZER_SELECTED_FLAGS)

if(AFL)
append_quoteless(AFL_USE_LSAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_LSAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_LSAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_C_COMPILER}")
if (CMAKE_CXX_COMPILER_LOADED)
message(FATAL_ERROR "Thread sanitizer not available for ${CMAKE_CXX_COMPILER}")
endif ()
endif()
endif()

Expand All @@ -206,43 +173,28 @@ if(USE_SANITIZER)
append("${SANITIZER_LEAK_FLAG}" SANITIZER_SELECTED_FLAGS)

if(AFL)
append_quoteless(AFL_USE_CFISAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_CFISAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_CFISAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "Control Flow Integrity(CFI) sanitizer not available for ${CMAKE_C_COMPILER}")
if (CMAKE_CXX_COMPILER_LOADED)
message(FATAL_ERROR "Control Flow Integrity(CFI) sanitizer not available for ${CMAKE_CXX_COMPILER}")
endif ()
endif()
endif()

message(STATUS "Sanitizer flags: ${SANITIZER_SELECTED_FLAGS}")
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)
if (CMAKE_CXX_COMPILER_LOADED)
append("${SANITIZER_SELECTED_FLAGS}" CMAKE_CXX_FLAGS)
endif ()
append("${SANITIZER_SELECTED_FLAGS}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
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)
if (CMAKE_CXX_COMPILER_LOADED)
append("-fsanitize=address" CMAKE_CXX_FLAGS)
endif ()
append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)

if(AFL)
append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER)
if (CMAKE_CXX_COMPILER_LOADED)
append_quoteless(AFL_USE_ASAN=1 CMAKE_CXX_COMPILER_LAUNCHER)
endif ()
append_quoteless(AFL_USE_ASAN=1 CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
endif()
else()
message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}")
Expand All @@ -253,10 +205,7 @@ if(USE_SANITIZER)
elseif(MSVC)
if(USE_SANITIZER MATCHES "([Aa]ddress)")
message(STATUS "Building with Address sanitizer")
append("/fsanitize=address" CMAKE_C_FLAGS)
if (CMAKE_CXX_COMPILER_LOADED)
append("/fsanitize=address" CMAKE_CXX_FLAGS)
endif ()
append("/fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}")
endif()
Expand Down
Loading

0 comments on commit 078350f

Please sign in to comment.