2064: Use system libblake if available#2083
Conversation
Signed-off-by: Sourav Moitra <sourav.moitr@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a configuration option to toggle between using an embedded version of the blake3 library and a system-provided one. The build system and test scripts have been updated to support this conditional compilation. Feedback was provided regarding the detection logic for the system libblake3 in configure.ac, specifically noting that the current implementation may fail in non-standard environments because it doesn't correctly propagate flags from pkg-config and uses a misleading error message.
| AM_COND_IF([HAVE_EMBEDDED_BLAKE3], [], [ | ||
| AC_SEARCH_LIBS(blake3_hasher_init, [blake3], [AC_DEFINE([HAVE_BLAKE3], 1, [Define if libblake3 is available])], [AC_MSG_ERROR([*** libblake3 headers not found])]) | ||
| PKG_CHECK_MODULES([BLAKE3], [libblake3]) | ||
| ]) |
There was a problem hiding this comment.
The detection logic for system libblake3 has a few issues:
- The error message in
AC_SEARCH_LIBSis misleading; it mentions 'headers not found' while checking for the library. AC_SEARCH_LIBSis called beforePKG_CHECK_MODULES. If the library is in a non-standard path,AC_SEARCH_LIBSwill fail beforepkg-configcan provide the correct paths.- The flags from
PKG_CHECK_MODULES(BLAKE3_CFLAGSandBLAKE3_LIBS) are not propagated to the build system, which may cause compilation or linking failures in environments with non-standard installation paths.
Consider using PKG_CHECK_MODULES as the primary check and falling back to AC_SEARCH_LIBS only if the .pc file is missing.
AM_COND_IF([HAVE_EMBEDDED_BLAKE3], [], [
PKG_CHECK_MODULES([BLAKE3], [libblake3], [
AC_DEFINE([HAVE_BLAKE3], 1, [Define if libblake3 is available])
CFLAGS="$CFLAGS $BLAKE3_CFLAGS"
LIBS="$LIBS $BLAKE3_LIBS"
], [
AC_SEARCH_LIBS(blake3_hasher_init, [blake3], [AC_DEFINE([HAVE_BLAKE3], 1, [Define if libblake3 is available])], [AC_MSG_ERROR([*** libblake3 not found])])
])
])
|
Ephemeral COPR build failed. @containers/packit-build please check. |
Use system libblake if available.
Fixes: #2064