Open yurivict opened 1 month ago
@yurivict , thank you so much for supporting HDF5 on FreeBSD!
It seems that libszip
is a new port package.
Port Added: 2024-10-10 21:24:07
Last Update: 2024-10-10 21:20:23
Are you adding the new port because
HDF5 CMake does not find libaec
package automatically as an SZIP alternative?
How can I install the new libszip port on FreeBSD so that I can reproduce error?
I tried sudo·pkg·install·-y·libszip
but I got an error:
pkg: No packages available to install matching 'libszip' have been found in the repositories
Regards,
Are you adding the new port because HDF5 CMake does not find libaec package automatically as an SZIP alternative?
Yes.
I wasn't sure what libaec is, and added libszip. But libaec wasn't found by cmake silently.
How can I install the new libszip port on FreeBSD so that I can reproduce error? I tried sudo·pkg·install·-y·libszip but I got an error: pkg: No packages available to install matching 'libszip' have been found in the repositories
This is a very new port, and its packages aren't yet built.
In order to install it you need to run this command on the updated ports tree:
cd /usr/ports/archivers/libszip && make install clean
Than you, @yurivict , for answering my questions!
I installed the new port and could duplicate your error:
https://my.cdash.org/viewBuildError.php?buildid=2688292
Yes, I also noticed that libaec
can't be found silently by cmake.
Here are a few hacks for FreeBSD community.
For libszip package, run
$export LDFLAGS="-L/usr/local/lib -lszip"
For libaec package, run
$export LDFLAGS="-L/usr/local/lib -lsz"
$sudo ln -s /usr/local/cmake/libaec-config-version.cmake /usr/local/cmake/szip-config-version.cmake
$sudo ln -s /usr/local/cmake/libaec-config.cmake /usr/local/cmake/szip-config.cmake
Run the above before you run cmake
.
Yes, I also noticed that
libaec
can't be found silently by cmake.
This appears to be caused by https://github.com/HDFGroup/hdf5/pull/4567 (included in 1.14.5 via https://github.com/HDFGroup/hdf5/commit/95fa8f15e8039f2162edea37f79bf46570cc2597) which dropped support for libaec
. Also saw failure in Homebrew https://github.com/Homebrew/homebrew-core/pull/193283 (for us HDF5_ENABLE_SZIP_SUPPORT
gets disabled due to not being detected).
EDIT: Noting that restoring find_package(libaec CONFIG)
fixed detection, but build failed afterward at
CMake Error at src/CMakeLists.txt:1204 (get_target_property):
get_target_property() called with non-existent target
"/opt/homebrew/lib/libsz.dylib".
EDIT 2: Trying some workarounds but pkg-config file ends up broken:
Libs.private: -lzlib-static -llibname-NOTFOUND
Maybe the best solution is if hdf5 would either auto-detect libaec and libszip, or to detect each of them based on special cmake variables instructing cmake to look for one or the other library?
@cho-m , thank you for identifying the root cause related to libaec
.
Your comment helped me to find another hack for FreeBSD community:
cmake -DLIBAEC_PACKAGE_NAME:STRING=libaec ..
This can eliminate:
$sudo ln -s /usr/local/cmake/libaec-config-version.cmake /usr/local/cmake/szip-config-version.cmake
$sudo ln -s /usr/local/cmake/libaec-config.cmake /usr/local/cmake/szip-config.cmake
However, users will get a warning:
CMake Warning (dev) at /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:441 (message):
The package name passed to `find_package_handle_standard_args` (libaec)
does not match the name of the calling package (SZIP). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Yet, build and test succeeds:
https://my.cdash.org/viewTest.php?onlypassed&buildid=2689761
Personally would recommend re-adding find_package (libaec CONFIG)
.
I'm guessing this change was an untested breakage as CI doesn't run this combination. Especially so given CI runs on Ubuntu which doesn't have CMake files https://packages.ubuntu.com/jammy/amd64/libaec-dev/filelist
Build issue (failing to find libsz) should be reproducible with other Linux distros as most will not provide SZip (due to license, e.g. https://fedoraproject.org/wiki/Forbidden_items#szip) and libaec
is installed in standard manner with libaec-config.cmake
:
Only thing for Linux distros is that they use Autotools to build HDF5 so won't see problem in CMake.
Is my understanding correct that libaec provides a superset of functionality compared to libszip?
Is my understanding correct that libaec provides a superset of functionality compared to libszip?
The most commonly used API is drop-in compatible but libszip does expose a few more functions as part of its public API (various SZ_Decompress*
and SZ_Compress*
) so might not be considered a proper superset. HDF5 uses the common ones so either library should work.
Any hope to fix this and to make a release with the fix? We have the SZIP option broken in the FreeBSD port because of this problem.
In Homebrew, I've been trying out a patch. Opened PR #5010 which works for me with libaec
.
Note that libaec
uses a Windows-only directory layout for installing CMake config files (<prefix>/cmake
)^1 thus CMake requires help finding them, e.g. via libaec_DIR
. Would be better if they allowed installing into Unix compatible directory too. Can easily be moved, which is common approach used in Linux distros.
@cho-m , thank you for your hard effort fixing HDF5 CMake
for szip
.
You may find these also helpful for making your patch portable & usable for Windows vcpkg
users:
I don't know when libaec
will be official for Microsoft vcpkg
.
In the mean time, I think it's good to continue supporting szip
.
The package doesn't have to have .cmake or .pc files to be discoverable by cmake.
hdf5 can use cmake's find_library to discover libaec.
The package doesn't have to have .cmake or .pc files to be discoverable by cmake.
libaec
should have CMake files as part of default build, but in a poor location. Can fixup like e.g.
EDIT: I checked FreeBSD and they are available: https://github.com/freebsd/freebsd-ports/blob/main/science/libaec/pkg-plist
cmake/libaec-config-version.cmake
cmake/libaec-config.cmake
Yes, libaec's cmake scripts work on FreeBSD.
find_package(libaec REQUIRED)
should just be added in hdf5.
find_package(libaec REQUIRED)
should just be added in hdf5.
Problem looks like Windows support. I do think my changes are backwards compatible with whatever was previously running as I retained all fallbacks.
However, the previously running logic may already be broken on 1.14.5 for vcpkg. Don't have a setup readily available to test this.
You may find these also helpful for making your patch portable & usable for Windows
vcpkg
users:
Looks like this patch is related to root cause of regression. Seems like only Windows was tested and the patched-behavior was assumed to be the default.
Also noted this in https://github.com/HDFGroup/hdf5/pull/5010#issuecomment-2438820232.
Describe the bug
Expected behavior n/a
Platform (please complete the following information)
Additional context libszip is discovered by cmake, but then this error occurs.