Skip to content

Commit

Permalink
Bring the H5detect removal change from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins committed Oct 9, 2023
1 parent 7b18845 commit 56ce2db
Show file tree
Hide file tree
Showing 19 changed files with 878 additions and 1,524 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1225,10 +1225,4 @@ endif ()
#-----------------------------------------------------------------------------
configure_file (${HDF_RESOURCES_DIR}/H5pubconf.h.in ${HDF5_SRC_BINARY_DIR}/H5pubconf.h @ONLY)

#-----------------------------------------------------------------------------
# Options for use by cross compiling and toolchains
#-----------------------------------------------------------------------------
option (HDF5_USE_PREGEN "Use pre-generated Files" OFF)
option (HDF5_BATCH_H5DETECT "Use a batch command for running h5detect" OFF)

include (CMakeInstallation.cmake)
20 changes: 0 additions & 20 deletions bin/batch/knl_H5detect.sl.in.cmake

This file was deleted.

7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ AC_CONFIG_COMMANDS([pubconf], [
sed '/^#/d' < src/libhdf5.settings > libhdf5.settings.TMP
cp libhdf5.settings.TMP src/libhdf5.settings
rm -f libhdf5.settings.TMP
echo "Post process src/H5build_settings.c"
sed '/^# /d' < src/H5build_settings.c > H5build_settings.TMP
cp H5build_settings.TMP src/H5build_settings.c
rm -f H5build_settings.TMP
])

## It's possible to configure for a host other than the one on which
Expand Down Expand Up @@ -3908,9 +3912,11 @@ AC_ARG_ENABLE([embedded-libinfo],

if test "${enable_embedded_libinfo}" = "yes"; then
AC_MSG_RESULT([yes])
BUILD_SETTINGS_FILE="src/H5build_settings.autotools.c.in"
AC_DEFINE([HAVE_EMBEDDED_LIBINFO], [1],
[Define if library information should be embedded in the executables])
else
BUILD_SETTINGS_FILE="src/H5build_settings.off.c.in"
AC_MSG_RESULT([no])
fi

Expand Down Expand Up @@ -4047,6 +4053,7 @@ AC_CONFIG_FILES([Makefile
doxygen/Doxyfile
src/Makefile
src/libhdf5.settings
src/H5build_settings.c:${BUILD_SETTINGS_FILE}
test/Makefile
test/H5srcdir_str.h
test/test_abort_fail.sh
Expand Down
9 changes: 0 additions & 9 deletions release_docs/INSTALL_CMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1030,15 +1030,6 @@ References:
https://stackoverflow.com/questions/54539682/how-to-set-up-cmake-to-cross-compile-with-clang-for-arm-embedded-on-windows?rq=1
https://developer.android.com/ndk/guides/cmake

Predefine H5Tinit.c file
-------------------------------
The one file that needs to be pre-generated is the H5Tinit.c file. The variables
indicated in the error log (see above) are the variables that need to match the target system.

The HDF5 CMake variables;
HDF5_USE_PREGEN: set this to true
HDF5_USE_PREGEN_DIR: set this path to the preset H5Tinit.c file


========================================================================
X: Using CMakePresets.json for compiling
Expand Down
19 changes: 0 additions & 19 deletions release_docs/README_HPC
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Section II: Obtain HDF5 source
Section III: Using ctest command to build and test
Section IV: Cross compiling
Section V: Manual alternatives
Section VI: Other cross compiling options

************************************************************************

Expand Down Expand Up @@ -184,21 +183,3 @@ or
for parallel builds.

Tests on machines using LSF will typically use "bsub ctestS.lsf", etc.

========================================================================
VI. Other cross compiling options
========================================================================
Settings for two other cross-compiling options are also in the config/toolchain
files which do not seem to be necessary with the Cray PrgEnv-* modules

1. HDF5_USE_PREGEN. This option, along with the HDF5_USE_PREGEN_DIR CMake
variable would allow the use of an appropriate H5Tinit.c file with type
information generated on a compute node to be used when cross compiling
for those compute nodes. The use of the variables in lines 110 and 111
of HDF5options.cmake file seem to preclude needing this option with the
available Cray modules and CMake option.

2. HDF5_BATCH_H5DETECT and associated CMake variables. This option when
properly configured will run H5detect in a batch job on a compute node
at the beginning of the CMake build process. It was also found to be
unnecessary with the available Cray modules and CMake options.
18 changes: 18 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ New Features

Configuration:
-------------
- Removed CMake cross-compiling variables

* HDF5_USE_PREGEN
* HDF5_BATCH_H5DETECT

These were used to work around H5detect and H5make_libsettings and
are no longer required.

- Running H5make_libsettings is no longer required for cross-compiling

The functionality of H5make_libsettings is now handled via template files,
so H5make_libsettings has been removed.

- Running H5detect is no longer required for cross-compiling

The functionality of H5detect is now exercised at library startup,
so H5detect has been removed.

- Thread-safety + static library disabled on Windows w/ CMake

The thread-safety feature requires hooks in DllMain(), which is only
Expand Down
175 changes: 8 additions & 167 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project (HDF5_SRC C)
#-----------------------------------------------------------------------------
set (H5_SOURCES
${HDF5_SRC_DIR}/H5.c
${HDF5_SRC_BINARY_DIR}/H5build_settings.c
${HDF5_SRC_DIR}/H5checksum.c
${HDF5_SRC_DIR}/H5dbg.c
${HDF5_SRC_DIR}/H5mpi.c
Expand Down Expand Up @@ -616,6 +617,7 @@ set (H5T_SOURCES
${HDF5_SRC_DIR}/H5Tfields.c
${HDF5_SRC_DIR}/H5Tfixed.c
${HDF5_SRC_DIR}/H5Tfloat.c
${HDF5_SRC_DIR}/H5Tinit_float.c
${HDF5_SRC_DIR}/H5Tnative.c
${HDF5_SRC_DIR}/H5Toffset.c
${HDF5_SRC_DIR}/H5Toh.c
Expand Down Expand Up @@ -1013,14 +1015,9 @@ if (HDF5_GENERATE_HEADERS)
endif ()

#-----------------------------------------------------------------------------
# Setup the H5detect utility which generates H5Tinit with platform
# specific type checks inside
# Generate the H5build_settings.c file
#-----------------------------------------------------------------------------
if (HDF5_USE_PREGEN)
set (HDF5_GENERATED_SOURCE_DIR ${HDF5_USE_PREGEN_DIR})
else ()
set (HDF5_GENERATED_SOURCE_DIR ${HDF5_SRC_BINARY_DIR})
endif ()
configure_file (${HDF5_SOURCE_DIR}/src/H5build_settings.cmake.c.in ${HDF5_SRC_BINARY_DIR}/H5build_settings.c @ONLY)

if (BUILD_SHARED_LIBS)
file (MAKE_DIRECTORY "${HDF5_SRC_BINARY_DIR}/shared")
Expand Down Expand Up @@ -1055,159 +1052,11 @@ if (LOCAL_BATCH_TEST)
endif ()
endif ()

#### make the H5detect program
set (lib_prog_deps)
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
target_include_directories (H5detect PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
TARGET_C_PROPERTIES (H5detect STATIC)
target_link_libraries (H5detect
PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib>
)
target_compile_options(H5detect
PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>"
)
set (lib_prog_deps ${lib_prog_deps} H5detect)

# check if a pregenerated H5Tinit.c file is present
if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c")
# execute the H5detect program
if (HDF5_BATCH_H5DETECT)
configure_file (
${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake
${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} ESCAPE_QUOTES @ONLY
)
add_custom_command (
OUTPUT gen_SRCS.stamp1
BYPRODUCTS H5Tinit.c
COMMAND ${HDF5_BATCH_CMD}
ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT}
COMMAND ${CMAKE_COMMAND}
ARGS -E echo "Executed batch command to create H5Tinit.c"
COMMAND ${CMAKE_COMMAND}
ARGS -E touch gen_SRCS.stamp1
DEPENDS H5detect
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
)
add_custom_target (gen_H5Tinit
COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake
)
else ()
add_custom_command (
OUTPUT gen_SRCS.stamp1
BYPRODUCTS H5Tinit.c
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5detect>
ARGS H5Tinit.c
COMMAND ${CMAKE_COMMAND}
ARGS -E touch gen_SRCS.stamp1
DEPENDS H5detect
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
COMMENT "Create H5Tinit.c"
)
if (BUILD_SHARED_LIBS)
add_custom_command (
OUTPUT shared/shared_gen_SRCS.stamp1
BYPRODUCTS shared/H5Tinit.c
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c
COMMAND ${CMAKE_COMMAND}
ARGS -E touch shared/shared_gen_SRCS.stamp1
DEPENDS H5detect gen_SRCS.stamp1
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
COMMENT "Copy H5Tinit.c to shared folder"
)
endif ()
endif ()
else ()
add_custom_command (
OUTPUT gen_SRCS.stamp1
COMMAND ${CMAKE_COMMAND}
ARGS -E touch gen_SRCS.stamp1
DEPENDS H5Tinit.c
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
COMMENT "Touch existing H5Tinit.c"
)
set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE)
if (BUILD_SHARED_LIBS)
add_custom_command (
OUTPUT shared/shared_gen_SRCS.stamp1
BYPRODUCTS shared/H5Tinit.c
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c
COMMAND ${CMAKE_COMMAND}
ARGS -E touch shared/shared_gen_SRCS.stamp1
DEPENDS H5Tinit.c gen_SRCS.stamp1
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
COMMENT "Copy existing H5Tinit.c to shared folder"
)
endif ()
endif ()

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c)
endif ()

# make the H5make_libsettings program
add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
TARGET_C_PROPERTIES (H5make_libsettings STATIC)
target_link_libraries (H5make_libsettings
PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib>
)
target_compile_options(H5make_libsettings
PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>"
)
set (lib_prog_deps ${lib_prog_deps} H5make_libsettings)

#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_SRC_LIBSETTINGS_FORMAT H5make_libsettings)
endif ()

# execute the H5make_libsettings program
add_custom_command (
OUTPUT gen_SRCS.stamp2
BYPRODUCTS H5lib_settings.c
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5make_libsettings>
ARGS H5lib_settings.c
COMMAND ${CMAKE_COMMAND}
ARGS -E touch gen_SRCS.stamp2
DEPENDS H5make_libsettings
WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR}
COMMENT "Create H5lib_settings.c"
)
set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE)
if (BUILD_SHARED_LIBS)
add_custom_command (
OUTPUT shared/shared_gen_SRCS.stamp2
BYPRODUCTS shared/H5lib_settings.c
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different H5lib_settings.c shared/H5lib_settings.c
COMMAND ${CMAKE_COMMAND}
ARGS -E touch shared/shared_gen_SRCS.stamp2
DEPENDS H5make_libsettings gen_SRCS.stamp2
WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR}
COMMENT "Copy H5lib_settings.c to shared folder"
)
endif ()

#-----------------------------------------------------------------------------
# Add H5Tinit source to build - generated by H5detect/CMake at configure time
# Set up library builds
#-----------------------------------------------------------------------------
if (BUILD_STATIC_LIBS)
set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c)
add_custom_target (gen_${HDF5_LIB_TARGET} ALL
DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2
COMMENT "Generation target files"
)

add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} H5build_settings.c ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
target_include_directories (${HDF5_LIB_TARGET}
PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>;$<BUILD_INTERFACE:${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR}>"
Expand Down Expand Up @@ -1235,19 +1084,12 @@ if (BUILD_STATIC_LIBS)
set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0)
set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries)
add_dependencies (${HDF5_LIB_TARGET} gen_${HDF5_LIB_TARGET})

set (install_targets ${HDF5_LIB_TARGET})
endif ()

if (BUILD_SHARED_LIBS)
set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c)
add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL
DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2
COMMENT "Shared generation target files"
)

add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} H5build_settings.c ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
target_include_directories (${HDF5_LIBSH_TARGET}
PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
PUBLIC "$<$<BOOL:${HDF5_ENABLE_HDFS}>:${HDFS_INCLUDE_DIR}>"
Expand All @@ -1274,7 +1116,6 @@ if (BUILD_SHARED_LIBS)
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB")
set_target_properties (${HDF5_LIBSH_TARGET} PROPERTIES FOLDER libraries)
add_dependencies (${HDF5_LIBSH_TARGET} gen_${HDF5_LIBSH_TARGET})

set (install_targets ${install_targets} ${HDF5_LIBSH_TARGET})
endif ()
Expand Down Expand Up @@ -1416,7 +1257,7 @@ if (DOXYGEN_FOUND)
# Replace variables inside @@ with the current values
add_custom_target (hdf5lib_doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${HDF5_BINARY_DIR}/Doxyfile
DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c
DEPENDS ${HDF5_SRC_BINARY_DIR}/H5build_settings.c
WORKING_DIRECTORY ${HDF5_SRC_DIR}
COMMENT "Generating HDF5 library Source API documentation with Doxygen"
VERBATIM )
Expand Down
13 changes: 7 additions & 6 deletions src/H5.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,9 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
"Setting it to 2 or higher will suppress the warning messages totally.\n");
/* Mention the versions we are referring to */
fprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum,
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
/* Show library settings if available */
fprintf(stderr, "%s", H5libhdf5_settings);
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
/* Show library build settings if available */
fprintf(stderr, "%s", H5build_settings);

/* Bail out now. */
HDfputs("Bye...\n", stderr);
Expand All @@ -920,9 +920,10 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
version_mismatch_warning, disable_version_check);
/* Mention the versions we are referring to */
fprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum,
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
/* Show library settings if available */
fprintf(stderr, "%s", H5libhdf5_settings);
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
/* Show library build settings if available */
fprintf(stderr, "%s", H5build_settings);

break;
default:
/* 2 or higher: continue silently */
Expand Down
Loading

0 comments on commit 56ce2db

Please sign in to comment.