summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-08-20 00:18:30 (GMT)
committerGitHub <noreply@github.com>2022-08-20 00:18:30 (GMT)
commit2b786ffe5a189c203530e42ea0edf7b4a0b93c1a (patch)
tree97aece0796f2d41b284603626adfdf851a94330b /config
parent281db5876e5c0b003b59ef86e0bd6b3bbfab1089 (diff)
downloadhdf5-2b786ffe5a189c203530e42ea0edf7b4a0b93c1a.zip
hdf5-2b786ffe5a189c203530e42ea0edf7b4a0b93c1a.tar.gz
hdf5-2b786ffe5a189c203530e42ea0edf7b4a0b93c1a.tar.bz2
[WIP] Add Developer build mode to CMake (#1659)
* Add Developer build mode to CMake * Set a few CMake variables for Developer build modes * Refactor enabling of debug and developer-level compile definitions * Convert cache debugging macros to normal ifdef style Normal ifdef-style instead of if-style allows build system to define macros without warning about redefining macros with different values (0 vs. 1) * Add HDF5 Developer compile definitions to testing files * Temporarily disable -fanalyzer flag for GCC 12+ Developer builds
Diffstat (limited to 'config')
-rw-r--r--config/cmake/HDF5DeveloperBuild.cmake203
-rw-r--r--config/cmake/HDFCXXCompilerFlags.cmake2
-rw-r--r--config/cmake/HDFCompilerFlags.cmake38
-rw-r--r--config/cmake/HDFMacros.cmake20
-rw-r--r--config/gnu-warnings/developer-124
5 files changed, 256 insertions, 11 deletions
diff --git a/config/cmake/HDF5DeveloperBuild.cmake b/config/cmake/HDF5DeveloperBuild.cmake
new file mode 100644
index 0000000..53c03de
--- /dev/null
+++ b/config/cmake/HDF5DeveloperBuild.cmake
@@ -0,0 +1,203 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+
+# CMake settings for HDF5 Developer mode builds
+
+# Set CMake C++ flags based off of Debug build flags
+set (CMAKE_CXX_FLAGS_DEVELOPER ${CMAKE_CXX_FLAGS_DEBUG} CACHE STRING
+ "Flags used by the C++ compiler during developer builds." FORCE
+)
+
+# Set CMake C flags based off of Debug build flags. Add in -Og
+# option to disable some GCC optimizations that might affect
+# debugging negatively and also include some GCC compiler passes
+# that collect debugging information
+set (CMAKE_C_FLAGS_DEVELOPER "${CMAKE_C_FLAGS_DEBUG} -Og" CACHE STRING
+ "Flags used by the C compiler during developer builds." FORCE
+)
+
+# Set CMake binary linker flags based off of Debug binary linker flags
+set (CMAKE_EXE_LINKER_FLAGS_DEVELOPER ${CMAKE_EXE_LINKER_FLAGS_DEBUG}
+ CACHE STRING "Flags used for linking binaries during developer builds."
+ FORCE
+)
+
+# Set CMake shared library linker flags based off of Debug shared library
+# linker flags
+set (CMAKE_SHARED_LINKER_FLAGS_DEVELOPER ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}
+ CACHE STRING "Flags used by the shared libraries linker during developer builds."
+ FORCE
+)
+
+mark_as_advanced (
+ CMAKE_CXX_FLAGS_DEVELOPER
+ CMAKE_C_FLAGS_DEVELOPER
+ CMAKE_EXE_LINKER_FLAGS_DEVELOPER
+ CMAKE_SHARED_LINKER_FLAGS_DEVELOPER
+)
+
+#-----------------------------------------------------------------------------
+# Define various HDF5 macros for debugging the library
+#-----------------------------------------------------------------------------
+
+# Enable debugging of various HDF5 modules
+set (HDF5_ENABLE_DEBUG_APIS ON CACHE BOOL "Turn on extra debug output in all packages" FORCE)
+
+# HDF5 module debug definitions for debug code which either isn't
+# currently integrated with HDF5_ENABLE_DEBUG_APIS, or which isn't
+# well integrated with HDF5's H5DEBUG(X) (where 'X' is a package
+# letter) system. This type of debug code usually always prints output
+# to stdout, regardless of whether debugging for its particular module
+# has been requested via the HDF5_DEBUG environment variable. Therefore,
+# we don't automatically enable this debug code, but allow developers
+# to quickly add those definitions into their build here, without
+# needing to hack up source files.
+option (HDF5_ENABLE_DEBUG_H5AC_DIRTY_BYTES "Enable printing of H5AC module dirty bytes information" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5AC_DIRTY_BYTES)
+if (HDF5_ENABLE_DEBUG_H5AC_DIRTY_BYTES)
+ list (APPEND HDF5_DEBUG_APIS H5AC_DEBUG_DIRTY_BYTES_CREATION)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FA "Enable debugging of H5FA module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FA)
+if (HDF5_ENABLE_DEBUG_H5FA)
+ list (APPEND HDF5_DEBUG_APIS H5FA_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FD_ALLOC "Enable debugging of H5FD module allocation code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FD_ALLOC)
+if (HDF5_ENABLE_DEBUG_H5FD_ALLOC)
+ list (APPEND HDF5_DEBUG_APIS H5FD_ALLOC_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FL "Enable debugging of H5FL module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FL)
+if (HDF5_ENABLE_DEBUG_H5FL)
+ list (APPEND HDF5_DEBUG_APIS H5FL_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FS "Enable debugging of H5FS module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS)
+if (HDF5_ENABLE_DEBUG_H5FS)
+ list (APPEND HDF5_DEBUG_APIS H5FS_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FS_SINFO "Enable debugging of H5FS module section info" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS_SINFO)
+if (HDF5_ENABLE_DEBUG_H5FS_SINFO)
+ list (APPEND HDF5_DEBUG_APIS H5FS_SINFO_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5MF_AGGR "Enable debugging of H5MF module aggregation code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_AGGR)
+if (HDF5_ENABLE_DEBUG_H5MF_AGGR)
+ list (APPEND HDF5_DEBUG_APIS H5MF_AGGR_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5MF_ALLOC "Enable debugging of H5MF module allocation code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_ALLOC)
+if (HDF5_ENABLE_DEBUG_H5MF_ALLOC)
+ list (APPEND HDF5_DEBUG_APIS H5MF_ALLOC_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5MF_ALLOC_MORE "Enable extra debugging of H5MF module allocation code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_ALLOC_MORE)
+if (HDF5_ENABLE_DEBUG_H5MF_ALLOC_MORE)
+ list (APPEND HDF5_DEBUG_APIS H5MF_ALLOC_DEBUG_MORE)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5MF_ALLOC_DUMP "Enable printing of debugging info for H5MF module allocation code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5MF_ALLOC_DUMP)
+if (HDF5_ENABLE_DEBUG_H5MF_ALLOC_DUMP)
+ list (APPEND HDF5_DEBUG_APIS H5MF_ALLOC_DEBUG_DUMP)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5R "Enable debugging of H5R module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5R)
+if (HDF5_ENABLE_DEBUG_H5R)
+ list (APPEND HDF5_DEBUG_APIS H5R_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5S_HYPER "Enable debugging of H5S hyperslab code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5S_HYPER)
+if (HDF5_ENABLE_DEBUG_H5S_HYPER)
+ list (APPEND HDF5_DEBUG_APIS H5S_HYPER_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5T_REF "Enable debugging of H5T module reference code" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5T_REF)
+if (HDF5_ENABLE_DEBUG_H5T_REF)
+ list (APPEND HDF5_DEBUG_APIS H5T_REF_DEBUG)
+endif ()
+
+# HDF5 module debug definitions for debug code which may add
+# considerable amounts of overhead when enabled and is usually
+# only useful for specific circumstances rather than general
+# developer use.
+option (HDF5_ENABLE_DEBUG_H5B "Enable debugging of H5B module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5B)
+if (HDF5_ENABLE_DEBUG_H5B)
+ list (APPEND HDF5_DEBUG_APIS H5B_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5B2 "Enable debugging of H5B2 module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5B2)
+if (HDF5_ENABLE_DEBUG_H5B2)
+ list (APPEND HDF5_DEBUG_APIS H5B2_DEBUG)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS "Enable full sanity checking in H5C module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS)
+if (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS)
+ list (APPEND HDF5_DEBUG_APIS H5C_DO_SANITY_CHECKS)
+ list (APPEND HDF5_DEBUG_APIS H5C_DO_SLIST_SANITY_CHECKS)
+ list (APPEND HDF5_DEBUG_APIS H5C_DO_TAGGING_SANITY_CHECKS)
+ list (APPEND HDF5_DEBUG_APIS H5C_DO_EXTREME_SANITY_CHECKS)
+
+ # See note in H5Cprivate.h about this #define
+ # list (APPEND HDF5_DEBUG_APIS H5C_DO_MEMORY_SANITY_CHECKS=1)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FL_TRACK "Enable tracking of free list allocations" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FL_TRACK)
+if (HDF5_ENABLE_DEBUG_H5FL_TRACK)
+ list (APPEND HDF5_DEBUG_APIS H5FL_TRACK)
+
+ # Free list tracking requires the codestack functionality
+ set (HDF5_ENABLE_CODESTACK ON CACHE BOOL "Enable the function stack tracing (for developer debugging)." FORCE)
+else ()
+ unset (HDF5_ENABLE_CODESTACK CACHE)
+endif ()
+
+option (HDF5_ENABLE_DEBUG_H5FS_ASSERT "Enable extra debugging of H5FS module" OFF)
+mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS_ASSERT)
+if (HDF5_ENABLE_DEBUG_H5FS_ASSERT)
+ list (APPEND HDF5_DEBUG_APIS H5FS_DEBUG_ASSERT)
+endif ()
+
+# If HDF5 free list debugging wasn't specifically enabled, disable
+# free lists entirely for developer build modes, as they can
+# make certain types of issues (like references to stale pointers)
+# much more difficult to debug
+if (NOT HDF5_ENABLE_DEBUG_H5FL AND NOT HDF5_ENABLE_DEBUG_H5FL_TRACK)
+ list (APPEND HDF5_DEVELOPER_DEFS H5_NO_FREE_LISTS)
+endif ()
+
+# Enable strict checking of the file format
+list (APPEND HDF5_DEVELOPER_DEFS H5_STRICT_FORMAT_CHECKS)
+
+# Enable printing of library memory stats
+option (HDF5_ENABLE_MEMORY_STATS "Enable printing of library memory stats" OFF)
+mark_as_advanced (HDF5_ENABLE_MEMORY_STATS)
+if (HDF5_ENABLE_MEMORY_STATS)
+ list (APPEND HDF5_DEVELOPER_DEFS H5MM_PRINT_MEMORY_STATS)
+endif ()
diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake
index e20ed6b..e654db3 100644
--- a/config/cmake/HDFCXXCompilerFlags.cmake
+++ b/config/cmake/HDFCXXCompilerFlags.cmake
@@ -53,7 +53,7 @@ endif ()
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}")
- if (${HDF_CFG_NAME} MATCHES "Debug")
+ if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common")
endif ()
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index 61218dc..c724547 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -52,7 +52,7 @@ endif()
if (CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
- if (${HDF_CFG_NAME} MATCHES "Debug")
+ if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer")
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common")
endif ()
@@ -174,6 +174,10 @@ endif ()
# Developer warnings (suggestions from gcc, not code problems)
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_DEV_WARNINGS "Enable HDF5 developer group warnings" OFF)
+if (${HDF_CFG_NAME} MATCHES "Developer")
+ # Developer build modes should always have these types of warnings enabled
+ set (HDF5_ENABLE_DEV_WARNINGS ON CACHE BOOL "Enable HDF5 developer group warnings" FORCE)
+endif ()
if (HDF5_ENABLE_DEV_WARNINGS)
message (STATUS "....HDF5 developer group warnings are enabled")
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
@@ -268,6 +272,38 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-10")
endif ()
endif ()
+
+ # Append more extra warning flags that only gcc 12.x+ knows about
+ # or which should only be enabled for gcc 12.x+
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0)
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-12")
+ #else ()
+ # ADD_H5_FLAGS (H5_CFLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-12")
+ endif ()
+ endif ()
+endif ()
+
+#-----------------------------------------------------------------------------
+# Option to allow the user to enable debug output
+# from various HDF5 modules
+#-----------------------------------------------------------------------------
+option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF)
+if (HDF5_ENABLE_DEBUG_APIS)
+ # Add standard debug definitions to any existing ones
+ list (APPEND HDF5_DEBUG_APIS
+ H5AC_DEBUG
+ H5CX_DEBUG
+ H5D_DEBUG
+ H5D_CHUNK_DEBUG
+ H5F_DEBUG
+ H5HL_DEBUG
+ H5I_DEBUG
+ H5O_DEBUG
+ H5S_DEBUG
+ H5T_DEBUG
+ H5Z_DEBUG
+ )
endif ()
#-----------------------------------------------------------------------------
diff --git a/config/cmake/HDFMacros.cmake b/config/cmake/HDFMacros.cmake
index 6f517bd..9d98408 100644
--- a/config/cmake/HDFMacros.cmake
+++ b/config/cmake/HDFMacros.cmake
@@ -34,7 +34,7 @@ macro (SET_HDF_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
- "MinSizeRel" "RelWithDebInfo")
+ "MinSizeRel" "RelWithDebInfo" "Developer")
endif()
endmacro ()
@@ -80,7 +80,7 @@ macro (INSTALL_TARGET_PDB libtarget targetdestination targetcomponent)
if (${libtype} MATCHES "SHARED")
set (targetfilename $<TARGET_PDB_FILE:${libtarget}>)
else ()
- get_property (target_name TARGET ${libtarget} PROPERTY $<IF:$<CONFIG:Debug>,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>)
+ get_property (target_name TARGET ${libtarget} PROPERTY $<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:Developer>>,OUTPUT_NAME_DEBUG,OUTPUT_NAME_RELWITHDEBINFO>)
set (targetfilename $<TARGET_FILE_DIR:${libtarget}>/${target_name}.pdb)
endif ()
install (
@@ -124,6 +124,7 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype)
set_target_properties (${libtarget} PROPERTIES
OUTPUT_NAME ${LIB_RELEASE_NAME}
# OUTPUT_NAME_DEBUG ${LIB_DEBUG_NAME}
+ OUTPUT_NAME_DEVELOPER ${LIB_DEBUG_NAME}
OUTPUT_NAME_RELEASE ${LIB_RELEASE_NAME}
OUTPUT_NAME_MINSIZEREL ${LIB_RELEASE_NAME}
OUTPUT_NAME_RELWITHDEBINFO ${LIB_RELEASE_NAME}
@@ -133,6 +134,7 @@ macro (HDF_SET_LIB_OPTIONS libtarget libname libtype)
if (WIN32)
set_target_properties (${libtarget} PROPERTIES
COMPILE_PDB_NAME_DEBUG ${LIB_DEBUG_NAME}
+ COMPILE_PDB_NAME_DEVELOPER ${LIB_DEBUG_NAME}
COMPILE_PDB_NAME_RELEASE ${LIB_RELEASE_NAME}
COMPILE_PDB_NAME_MINSIZEREL ${LIB_RELEASE_NAME}
COMPILE_PDB_NAME_RELWITHDEBINFO ${LIB_RELEASE_NAME}
@@ -158,7 +160,7 @@ macro (HDF_IMPORT_SET_LIB_OPTIONS libtarget libname libtype libversion)
if (${importtype} MATCHES "IMPORT")
set (importprefix "${CMAKE_STATIC_LIBRARY_PREFIX}")
endif ()
- if (${HDF_CFG_NAME} MATCHES "Debug")
+ if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer")
set (IMPORT_LIB_NAME ${LIB_DEBUG_NAME})
else ()
set (IMPORT_LIB_NAME ${LIB_RELEASE_NAME})
@@ -391,12 +393,12 @@ macro (HDF_DIR_PATHS package_prefix)
endif ()
#set the default debug suffix for all library targets
- if(NOT CMAKE_DEBUG_POSTFIX)
- if (WIN32)
- set (CMAKE_DEBUG_POSTFIX "_D")
- else ()
- set (CMAKE_DEBUG_POSTFIX "_debug")
- endif ()
+ if(NOT CMAKE_DEBUG_POSTFIX)
+ if (WIN32)
+ set (CMAKE_DEBUG_POSTFIX "_D")
+ else ()
+ set (CMAKE_DEBUG_POSTFIX "_debug")
+ endif ()
endif ()
SET_HDF_BUILD_TYPE()
diff --git a/config/gnu-warnings/developer-12 b/config/gnu-warnings/developer-12
new file mode 100644
index 0000000..0835d96
--- /dev/null
+++ b/config/gnu-warnings/developer-12
@@ -0,0 +1,4 @@
+# Enable GCC's static analyzer for GCC 12+
+# (Temporarily disabled as the analyzer currently adds significant
+# compile time overhead for a few test files like cache.c)
+# -fanalyzer