Skip to content

GH-132983: Use a standard autoconf version check for zstd #133479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 22 additions & 139 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 5 additions & 23 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5386,32 +5386,14 @@ PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [
])
])

have_libzstd=no
AC_DEFUN([TEST_ZSTD_VERSION],[
AC_MSG_CHECKING([if libzstd is new enough])

dnl TODO(emmatyping): check if we can set a C define for the minimum version
dnl to re-use here and in the header compile check

dnl This is checked when both a package is found and we do fallback searches
dnl If you update the minimum version here, you should update the compile
dnl check in Modules/_zstd/_zstdmodule.h
AC_RUN_IFELSE([AC_LANG_PROGRAM([@%:@include "zstd.h"], [
#if ZSTD_VERSION_NUMBER < 10405
exit(1);
#endif
])], [py__zstd_too_old=no], [py__zstd_too_old=yes])
dnl Important to record that we have libzstd
have_libzstd=yes
])

PKG_CHECK_MODULES([LIBZSTD], [libzstd], [TEST_ZSTD_VERSION()], [
dnl zstd 1.4.5 added ZDICT_finalizeDictionary
PKG_CHECK_MODULES([LIBZSTD], [libzstd >= 1.4.5], [have_libzstd=yes], [
WITH_SAVE_ENV([
CPPFLAGS="$CPPFLAGS $LIBZSTD_CFLAGS"
LIBS="$LIBS $LIBZSTD_LIBS"
AC_CHECK_HEADERS([zstd.h zdict.h], [
AC_CHECK_LIB([zstd], [ZDICT_finalizeDictionary],
[TEST_ZSTD_VERSION()], [have_libzstd=no])
PY_CHECK_LIB([zstd], [ZDICT_finalizeDictionary],
[have_libzstd=yes], [have_libzstd=no])
], [have_libzstd=no])
AS_VAR_IF([have_libzstd], [yes], [
LIBZSTD_CFLAGS=${LIBZSTD_CFLAGS-""}
Expand Down Expand Up @@ -8072,7 +8054,7 @@ PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes],
[$BZIP2_CFLAGS], [$BZIP2_LIBS])
PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes],
[$LIBLZMA_CFLAGS], [$LIBLZMA_LIBS])
PY_STDLIB_MOD([_zstd], [test "$py__zstd_too_old" = no], [test "$have_libzstd" = yes],
PY_STDLIB_MOD([_zstd], [], [test "$have_libzstd" = yes],
[$LIBZSTD_CFLAGS], [$LIBZSTD_LIBS])

dnl OpenSSL bindings
Expand Down
Loading