Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into threading_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
qkoziol committed Apr 30, 2024
2 parents 410602a + b23affc commit e46edd6
Show file tree
Hide file tree
Showing 19 changed files with 1,110 additions and 155 deletions.
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 @@ -1142,40 +1178,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)
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
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ if test "X$HDF5_DOXYGEN" = "Xyes"; then
DOXYGEN_OPTIMIZE_OUTPUT_FOR_C=YES
DOXYGEN_MACRO_EXPANSION=YES
DOXYGEN_OUTPUT_DIRECTORY=hdf5lib_docs
DOXYGEN_EXAMPLES_DIRECTORY='$(SRCDIR)/doxygen/dox/cookbook $(SRCDIR)/doxygen/examples $(SRCDIR)/src $(SRCDIR)/examples $(SRCDIR)/test'
DOXYGEN_EXAMPLES_DIRECTORY='$(SRCDIR)/doxygen/dox/cookbook $(SRCDIR)/doxygen/examples $(SRCDIR)/src $(SRCDIR)/release_docs $(SRCDIR)/test'
DOXYGEN_LAYOUT_FILE='$(SRCDIR)/doxygen/hdf5doxy_layout.xml'
DOXYGEN_HTML_HEADER='$(SRCDIR)/doxygen/hdf5_header.html'
DOXYGEN_HTML_FOOTER='$(SRCDIR)/doxygen/hdf5_footer.html'
Expand Down
2 changes: 1 addition & 1 deletion doxygen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (DOXYGEN_FOUND)
set (DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
set (DOXYGEN_MACRO_EXPANSION YES)
set (DOXYGEN_OUTPUT_DIRECTORY ${HDF5_BINARY_DIR}/hdf5lib_docs)
set (DOXYGEN_EXAMPLES_DIRECTORY "${HDF5_DOXYGEN_DIR}/dox/cookbook ${HDF5_DOXYGEN_DIR}/examples ${HDF5_SRC_DIR} ${HDF5_SOURCE_DIR}/examples ${HDF5_TEST_SRC_DIR}")
set (DOXYGEN_EXAMPLES_DIRECTORY "${HDF5_DOXYGEN_DIR}/dox/cookbook ${HDF5_DOXYGEN_DIR}/examples ${HDF5_SRC_DIR} ${HDF5_SOURCE_DIR}/release_docs ${HDF5_TEST_SRC_DIR}")
set (DOXYGEN_LAYOUT_FILE ${HDF5_DOXYGEN_DIR}/hdf5doxy_layout.xml)
set (DOXYGEN_HTML_HEADER ${HDF5_DOXYGEN_DIR}/hdf5_header.html)
set (DOXYGEN_HTML_FOOTER ${HDF5_DOXYGEN_DIR}/hdf5_footer.html)
Expand Down
19 changes: 19 additions & 0 deletions doxygen/dox/LearnBasics1.dox
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ directories and files, an HDF5 object in an HDF5 file is often referred to by it

\li <code style="background-color:whitesmoke;">/foo/zoo</code> signifies a member of the group foo, which in turn is a member of the root group.

<hr>
Next Chapter \ref LBAPI

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBAPI The HDF5 API
Expand Down Expand Up @@ -135,6 +138,9 @@ The APIs are listed below:
</tr>
</table>

<hr>
Previous Chapter \ref LBFileOrg - Next Chapter \ref LBProg

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBProg Programming Issues
Expand Down Expand Up @@ -203,6 +209,9 @@ Java: Add <code>"import hdf.hdf5lib.H5;
</li>
</ul>

<hr>
Previous Chapter \ref LBAPI - Next Chapter \ref LBFileCreate

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBFileCreate Creating an HDF5 File
Expand Down Expand Up @@ -395,6 +404,9 @@ The simplified DDL for file definition is as follows:
<group_member> ::= <group> | <dataset>
\endcode

<hr>
Previous Chapter \ref LBProg - Next Chapter \ref LBDsetCreate

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBDsetCreate Creating a Dataset
Expand Down Expand Up @@ -712,6 +724,9 @@ The following is the simplified DDL dataset definition:
\endcode

<hr>

Previous Chapter \ref LBFileCreate - Next Chapter \ref LBDsetRW

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBDsetRW Reading From and Writing To a Dataset
Expand Down Expand Up @@ -852,6 +867,8 @@ Shown below is the contents of dsetf.h5 (created by the FORTRAN program).
\endcode

<hr>
Previous Chapter \ref LBDsetCreate - Next Chapter \ref LBAttrCreate

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBAttrCreate Creating an Attribute
Expand Down Expand Up @@ -1018,6 +1035,8 @@ ATTRIBUTE "attr" {
\endcode

<hr>
Previous Chapter \ref LBDsetRW - Next Chapter \ref LBGrpCreate

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

*/
10 changes: 10 additions & 0 deletions doxygen/dox/LearnBasics2.dox
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ GROUP "/" {
\endcode

<hr>
Previous Chapter \ref LBAttrCreate - Next Chapter \ref LBGrpCreateNames

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBGrpCreateNames Creating Groups using Absolute and Relative Names
Expand Down Expand Up @@ -189,6 +191,8 @@ GROUP "/" {
\endcode

<hr>
Previous Chapter \ref LBGrpCreate - Next Chapter \ref LBGrpDset

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBGrpDset Creating Datasets in Groups
Expand Down Expand Up @@ -298,6 +302,8 @@ DATASET "dset1" {
\endcode

<hr>
Previous Chapter \ref LBGrpCreateNames - Next Chapter \ref LBDsetSubRW

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBDsetSubRW Reading From or Writing To a Subset of a Dataset
Expand Down Expand Up @@ -477,6 +483,8 @@ example code. The memory dataspace was defined as one-dimensional.
for these parameters, rather than passing in an array for each, and for Fortran 90 you can omit these parameters.

<hr>
Previous Chapter \ref LBGrpDset - Next Chapter \ref LBDatatypes

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

@page LBDatatypes Datatype Basics
Expand Down Expand Up @@ -1159,6 +1167,8 @@ If nested VL datatypes were used to create the buffer, this routine frees them f
releasing all the memory without creating memory leaks.

<hr>
Previous Chapter \ref LBDsetSubRW - Next Chapter \ref LBPropsList

Navigate back: \ref index "Main" / \ref GettingStarted / \ref LearnBasics

*/
Loading

0 comments on commit e46edd6

Please sign in to comment.