Skip to content

2064: Use system libblake if available#2083

Open
xw19 wants to merge 1 commit intocontainers:mainfrom
xw19:issue/2064
Open

2064: Use system libblake if available#2083
xw19 wants to merge 1 commit intocontainers:mainfrom
xw19:issue/2064

Conversation

@xw19
Copy link
Copy Markdown
Contributor

@xw19 xw19 commented May 1, 2026

Use system libblake if available.

Fixes: #2064

Signed-off-by: Sourav Moitra <sourav.moitr@gmail.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread configure.ac
Comment on lines +107 to +110
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])
])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The detection logic for system libblake3 has a few issues:

  1. The error message in AC_SEARCH_LIBS is misleading; it mentions 'headers not found' while checking for the library.
  2. AC_SEARCH_LIBS is called before PKG_CHECK_MODULES. If the library is in a non-standard path, AC_SEARCH_LIBS will fail before pkg-config can provide the correct paths.
  3. The flags from PKG_CHECK_MODULES (BLAKE3_CFLAGS and BLAKE3_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])])
  ])
])

@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

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.

Use the system's libblake3 if available

1 participant