Skip to content

Add workflows to test filter libraries installed in various ways#238

Draft
jhendersonHDF wants to merge 1 commit intoHDFGroup:masterfrom
jhendersonHDF:add_testing_workflows
Draft

Add workflows to test filter libraries installed in various ways#238
jhendersonHDF wants to merge 1 commit intoHDFGroup:masterfrom
jhendersonHDF:add_testing_workflows

Conversation

@jhendersonHDF
Copy link
Contributor

Add GitHub workflows to test building inline with HDF5 and with an already-installed HDF5 using filter libraries installed from both package managers and from CMake's FetchContent

Updated the ZSTD build process with newer files to fix a build issue due to an old CMake macro definition

Fixed the Blosc, Blosc2, LZ4 and ZSTD CMake logic so system-installed libraries can be found with find_package()

Updated h5repack testing to make added filters required instead of optional so that testing issues aren't masked over

Fixed the Bitgroom and Bitround testing after making those filters required in h5repack testing

Synced CMake files with HDF5 develop to fix various issues

@jhendersonHDF
Copy link
Contributor Author

Leaving this as a draft currently as this testing won't pass until some changes are merged into HDF5 develop

echo "zlib_external=OFF" >> "$GITHUB_OUTPUT"
fi

# TODO: Re-enable ZSTD testing after CMake logic issue is fixed
Copy link
Contributor Author

@jhendersonHDF jhendersonHDF Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZSTD currently has a CMake logic issue preventing building with FetchContent

SET_HDF_BUILD_TYPE()
endif ()
BASIC_SETTINGS (${BITGROOM_PACKAGE_NAME})
BASIC_SETTINGS (H5${BITGROOM_PACKAGE_NAME})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the hdf5_plugins package name to "h5pl" instead of "pl" because a CMake-built installation of hdf5_plugins couldn't be located otherwise. After doing that, the BASIC_SETTINGS macro needed updating to remove the "H5" that gets added to variable names everywhere, so now it has to be placed here in front of each filter's package name. This will be problematic if a non-default package name is ever specified for a filter, but that's already the case as the CMake variables below are already expected to be in the form "H5".

set (UPPER_BUILD_TYPE "")
endif ()
get_filename_component (_LIBRARY_PATH ${HDF5_INCLUDE_DIR} DIRECTORY)
set (HDF5_LIBRARY_PATH "${_LIBRARY_PATH}/lib")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern found in several other files was just syncing with the main HDFPluginMacros.cmake file to fix an issue with HDF5_LIBRARY_PATH not being set and causing problems later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file and several identical ones were updated to sync with changes in HDF5 develop to fix various issues, including test error output being hidden.

if (NOT DISABLE_H5PL_ENCODER)
#UD BITGROOM
ADD_H5_UD_TEST (ud_convert 0 h5repack_layout.h5 -v -f UD=32022,1,5,3,4,0,0,0 -l CHUNK=4x8)
ADD_H5_UD_TEST (ud_convert 0 h5repack_layout.h5 --enable-error-stack -v -f UD=32022,0,5,3,4,0,0,0 -l CHUNK=4x8)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated h5repack testing of several filters to make the filters required rather than optional. Otherwise, issues with the filters (especially with Bitgroom, Bitround and LZF) would be hidden during testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Bitgroom and Bitround testing was incorrect here. These filters remove themselves from the filter pipeline if the data isn't float data, which none of the data in the h5repack input file h5repack_layout.h5 is. But since they were previously added as optional filters, and since they were accidentally not in the plugin paths during testing, the testing skipped over the set_local() callbacks for these filters. So, the resulting file had the filters still applied even though they should have actually been removed from the pipeline. Testing of Bitgroom and Bitround should probably be updated to use float data.

find_package (BLOSC) # Legacy find
if (BLOSC_FOUND)
set (H5PL_LINK_LIBS ${H5PL_LINK_LIBS} ${BLOSC_LIBRARIES})
if (BLOSC_FOUND)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is needed to fix building against a system-installed Blosc.

if (BLOSC2_FOUND)
set (H5PL_LINK_LIBS ${H5PL_LINK_LIBS} ${BLOSC2_LIBRARIES})
find_package (BLOSC2 NAMES ${BLOSC2_PACKAGE_NAME}${HDF_PACKAGE_EXT})
if (BLOSC2_FOUND)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is needed to fix building against a system-installed Blosc2.

# Currently installs and tests against the following filters:
# - Blosc2
# - JPEG
# - ZFP (Temporarily disabled until H5Z-ZFP CMake is fixed)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZFP currently has a CMake logic issue preventing building in this way

set (HDF5_NAMESPACE "hdf5::" CACHE STRING "Name space of HDF5 library" FORCE)

set (BLOSC2_PACKAGE_NAME "blosc2" CACHE STRING "Name of BLOSC2 package" FORCE)
set (BLOSC2_PACKAGE_NAME "Blosc2" CACHE STRING "Name of BLOSC2 package" FORCE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the Blosc2 package name so system-installed Blosc2 can be located

#if (CMAKE_C_COMPILER_ID MATCHES "Intel[Ll][Ll][Vv][Mm]")
# FILTER_OPTION (BLOSC2)
#else
if (NOT CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_ID MATCHES "Apple[Cc]lang")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This no longer appears to be needed

find_package (LZ4) # Legacy find
if (LZ4_FOUND)
set (H5PL_LINK_LIBS ${H5PL_LINK_LIBS} ${LZ4_LIBRARIES})
if (LZ4_FOUND)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is needed so system-installed LZ4 can be built against

set_tests_properties (H5LZF_UD-${testname} PROPERTIES DEPENDS H5LZF_UD-${testname}-clearall-objects)
if ("H5LZF_UD-${testname}" STREQUAL "H5LZF_UD-ud_convert")
# LZF filter currently returns a failure during testing
set_tests_properties (H5LZF_UD-${testname} PROPERTIES DISABLED TRUE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LZF has had some issue with h5repack testing, but it was previously masked when LZF was added as an optional filter.

message (STATUS "ZSTD C libs: static:${ZSTD_static_FOUND}")
if (NOT ZSTD_FOUND)
find_package (ZSTD NAMES ${ZSTD_PACKAGE_NAME})
if (ZSTD_FOUND)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is needed so system-installed ZSTD can be built against

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ZSTD build process needed updating since it was out of date and failing. The build process should eventually be updated not to patch the source, but it's necessary for now.

# Make subproject to use 'BUILD_TESTING=OFF' setting.
set (BUILD_TESTING OFF CACHE INTERNAL "Build Unit Testing" FORCE)

set (ZSTD_BUILD_PROGRAMS OFF)
Copy link
Contributor

@brtnfld brtnfld Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you do the same as you did in H5BLOSCMacros.cmake:

set (ZSTD_BUILD_PROGRAMS OFF CACHE BOOL "Disable ZSTD programs" FORCE)
set (ZSTD_BUILD_CONTRIB OFF CACHE BOOL "Disable ZSTD contrib" FORCE)
set (ZSTD_BUILD_TESTS OFF CACHE BOOL "Disable ZSTD tests" FORCE)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, the way that Blosc(2) vendors zstd makes these not useful to try and pass down (the vendored versions don't appear to use CMake), but we're also somewhat limited in passing them down with FetchContent anyway since the vendored libraries are "one level down".

runs-on: windows-latest
steps:
- name: Get sources for HDF5
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in HDF5, we should remove # v. since it becomes stale once Dependabot updates it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependabot put the #v there and it updates it, so it never goes stale. I don't see why we should remove it. Sure maybe if there will be no future updates, but it doesn't hurt anything.

-DENABLE_BSHUF=ON \
..
# NOTE: Currently a serial build has to be forced, as Blosc and Blosc2
# appear to have a parallel building dependency issue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this happens: When FetchContent brings in both c-blosc and c-blosc2 simultaneously into the same global CMake scope, they both attempt to build their own vendored copies of underlying compression libraries (like zlib, lz4, zstd, snappy). They end up defining identical target names (e.g., zlib_static) or trying to write intermediate files to the exact same paths in CMAKE_BINARY_DIR/internal-complibs. This creates severe race conditions during a parallel build and clobbers the dependency graph.
The Fix: FetchContent is dangerous when multiple dependencies vendor the same sub-dependencies without namespacing them. To fix the parallel build:
Turn on the flags in c-blosc and c-blosc2 that force them to use externally provided libraries (e.g., -DPREFER_EXTERNAL_LZ4=ON, -DPREFER_EXTERNAL_ZSTD=ON), and let HDF5 provide those dependencies.
Alternatively: Use ExternalProject_Add instead of FetchContent for these plugins so their configure and build steps are completely isolated in their own sandboxes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has happened in the same way when only when building one of Blosc or Blosc2 rather than both, they'll have their own separate build directories, PREFER_EXTERNAL_ZLIB and others can't be passed down normally due to the way the options are declared in Blosc/Blosc2 and ExternalProject_Add isn't really a great fix because it will involve much more complicated logic and patching. The vendored zlib is the only one that appears to be causing problems; more investigation is needed.

if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
list (LENGTH TEST_STREAM test_len)
file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_ERROR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_ERROR is just standard text. The list() command evaluates standard strings by treating semicolons (;) as delimiters. If the error file outputs Missing file; aborting, CMake sees a list of 2 items. If there are no semicolons, it sees 1 item. It functionally works to check if the file is empty (test_len GREATER 0), but it is an abuse of the list API.

The Fix: Use string length or just a standard string comparison:
string(LENGTH "${TEST_ERROR}" test_len)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure maybe it's a little odd to use a list function here but it's all strings at the end of the day so I don't really see it as an abuse of the API since all we care about is whether the file was empty. There are many more places this would need fixed, including several in HDF5.

Add GitHub workflows to test building inline with HDF5 and with
an already-installed HDF5 using filter libraries installed from
both package managers and from CMake's FetchContent

Updated the ZSTD build process with newer files to fix a build
issue due to an old CMake macro definition

Fixed the Blosc, Blosc2, LZ4 and ZSTD CMake logic so
system-installed libraries can be found with find_package()

Updated h5repack testing to make added filters required instead
of optional so that testing issues aren't masked over

Fixed the Bitgroom and Bitround testing after making those filters
required in h5repack testing

Synced CMake files with HDF5 develop to fix various issues
@jhendersonHDF jhendersonHDF force-pushed the add_testing_workflows branch from afe9f30 to c2cacd7 Compare March 11, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants