https://gcc.gnu.org/g:d28635fae64a32c3f4859aa427960119ed29651c
commit r17-5387-gd28635fae64a32c3f4859aa427960119ed29651c Author: Torbjörn SVENSSON <[email protected]> Date: Tue Sep 29 14:31:11 2026 +0200 libbacktrace: Use shared zstd detection Replace the local zstd library check with AC_ZSTD. libbacktrace/ChangeLog: * aclocal.m4: Include pkg.m4 and zstd.m4. * configure: Regenerate. * configure.ac: Use AC_ZSTD for zstd detection. * Makefile.am: Use the detected zstd flags. * Makefile.in: Regenerate. Signed-off-by: Torbjörn SVENSSON <[email protected]> Diff: --- libbacktrace/Makefile.am | 7 +- libbacktrace/Makefile.in | 26 ++- libbacktrace/aclocal.m4 | 2 + libbacktrace/configure | 455 ++++++++++++++++++++++++++++++++++++++++++++-- libbacktrace/configure.ac | 5 +- 5 files changed, 464 insertions(+), 31 deletions(-) diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index af0ef151cd95..aa87e31a0746 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -415,14 +415,15 @@ ztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) BUILDTESTS += ztest_alloc zstdtest_SOURCES = zstdtest.c testlib.c -zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\" +zstdtest_CFLAGS = \ + $(libbacktrace_TEST_CFLAGS) $(ZSTD_CFLAGS) -DSRCDIR=\"$(srcdir)\" zstdtest_LDFLAGS = $(libbacktrace_testing_ldflags) zstdtest_LDADD = libbacktrace.la zstdtest_alloc_LDADD = libbacktrace_alloc.la if HAVE_ZSTD -zstdtest_LDADD += -lzstd -zstdtest_alloc_LDADD += -lzstd +zstdtest_LDADD += $(ZSTD_LIBS) +zstdtest_alloc_LDADD += $(ZSTD_LIBS) endif zstdtest_LDADD += $(CLOCK_GETTIME_LINK) zstdtest_alloc_LDADD += $(CLOCK_GETTIME_LINK) diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index 076603e9d9f7..39df59909163 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -147,8 +147,8 @@ TESTS = $(am__append_6) $(MAKETESTS) $(am__EXEEXT_18) @HAVE_ELF_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_17 = -lz @HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_18 = ztest ztest_alloc zstdtest \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest_alloc -@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_19 = -lzstd -@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_20 = -lzstd +@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_19 = $(ZSTD_LIBS) +@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__append_20 = $(ZSTD_LIBS) @NATIVE_TRUE@am__append_21 = edtest edtest_alloc @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_22 = ttest ttest_alloc @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_23 = \ @@ -179,12 +179,14 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \ $(top_srcdir)/../config/lead-dot.m4 \ $(top_srcdir)/../config/multi.m4 \ $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/pkg.m4 \ $(top_srcdir)/../config/stdint.m4 \ $(top_srcdir)/../config/unwind_ipinfo.m4 \ $(top_srcdir)/../config/warnings.m4 \ - $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ - $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ - $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/../config/zstd.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ + $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ @@ -551,8 +553,9 @@ xztest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest-zstdtest.$(OBJEXT) \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ zstdtest-testlib.$(OBJEXT) zstdtest_OBJECTS = $(am_zstdtest_OBJECTS) +@HAVE_ELF_TRUE@@HAVE_ZSTD_TRUE@@NATIVE_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) @HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_DEPENDENCIES = libbacktrace.la \ -@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1) \ +@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_2) \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1) zstdtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(zstdtest_CFLAGS) \ @@ -565,7 +568,7 @@ zstdtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ zstdtest_alloc_OBJECTS = $(am_zstdtest_alloc_OBJECTS) @HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_alloc_DEPENDENCIES = \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ libbacktrace_alloc.la \ -@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1) \ +@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_2) \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__DEPENDENCIES_1) zstdtest_alloc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ @@ -946,6 +949,9 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIC_FLAG = @PIC_FLAG@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ RANLIB = @RANLIB@ READELF = @READELF@ @@ -957,6 +963,8 @@ VERSION = @VERSION@ VIEW_FILE = @VIEW_FILE@ WARN_FLAGS = @WARN_FLAGS@ XZ = @XZ@ +ZSTD_CFLAGS = @ZSTD_CFLAGS@ +ZSTD_LIBS = @ZSTD_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -1195,7 +1203,9 @@ libbacktrace_testing_ldflags = -no-install @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_CFLAGS = $(ztest_CFLAGS) @HAVE_ELF_TRUE@@NATIVE_TRUE@ztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) @HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_SOURCES = zstdtest.c testlib.c -@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\" +@HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_CFLAGS = \ +@HAVE_ELF_TRUE@@NATIVE_TRUE@ $(libbacktrace_TEST_CFLAGS) $(ZSTD_CFLAGS) -DSRCDIR=\"$(srcdir)\" + @HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_LDFLAGS = $(libbacktrace_testing_ldflags) @HAVE_ELF_TRUE@@NATIVE_TRUE@zstdtest_LDADD = libbacktrace.la \ @HAVE_ELF_TRUE@@NATIVE_TRUE@ $(am__append_19) \ diff --git a/libbacktrace/aclocal.m4 b/libbacktrace/aclocal.m4 index df92f64c55b9..950d707f6258 100644 --- a/libbacktrace/aclocal.m4 +++ b/libbacktrace/aclocal.m4 @@ -859,9 +859,11 @@ m4_include([../config/gcc-plugin.m4]) m4_include([../config/lead-dot.m4]) m4_include([../config/multi.m4]) m4_include([../config/override.m4]) +m4_include([../config/pkg.m4]) m4_include([../config/stdint.m4]) m4_include([../config/unwind_ipinfo.m4]) m4_include([../config/warnings.m4]) +m4_include([../config/zstd.m4]) m4_include([../libtool.m4]) m4_include([../ltoptions.m4]) m4_include([../ltsugar.m4]) diff --git a/libbacktrace/configure b/libbacktrace/configure index 71d57475cf23..c527c7d0017d 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -657,6 +657,11 @@ HAVE_COMPRESSED_DEBUG_ZSTD_FALSE HAVE_COMPRESSED_DEBUG_ZSTD_TRUE HAVE_ZSTD_FALSE HAVE_ZSTD_TRUE +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG +ZSTD_LIBS +ZSTD_CFLAGS HAVE_COMPRESSED_DEBUG_ZLIB_GABI_FALSE HAVE_COMPRESSED_DEBUG_ZLIB_GABI_TRUE HAVE_COMPRESSED_DEBUG_ZLIB_GNU_FALSE @@ -819,6 +824,9 @@ enable_werror with_system_libunwind enable_host_pie enable_host_shared +with_zstd +with_zstd_include +with_zstd_lib ' ac_precious_vars='build_alias host_alias @@ -829,6 +837,11 @@ LDFLAGS LIBS CPPFLAGS CPP +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +ZSTD_CFLAGS +ZSTD_LIBS OBJCOPY DSYMUTIL NM' @@ -1480,6 +1493,15 @@ Optional Packages: both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-system-libunwind use installed libunwind + --with-zstd=VALUE VALUE may be 'auto' (try pkg-config, then compiler + search; default), 'yes' (require zstd), 'no' + (disable it), or a PATH for the installation prefix. + When VALUE is a PATH, this is equivalent to + --with-zstd-include=PATH/include and + --with-zstd-lib=PATH/lib + --with-zstd-include=PATH + specify directory for installed zstd include files + --with-zstd-lib=PATH specify directory for the installed zstd library Some influential environment variables: CC C compiler command @@ -1490,6 +1512,13 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor + PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path + ZSTD_CFLAGS C compiler flags for ZSTD, overriding pkg-config + ZSTD_LIBS linker flags for ZSTD, overriding pkg-config OBJCOPY location of objcopy DSYMUTIL location of dsymutil NM location of nm @@ -12026,7 +12055,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12029 "configure" +#line 12058 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12132,7 +12161,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12135 "configure" +#line 12164 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14423,13 +14452,315 @@ else fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZSTD_compress in -lzstd" >&5 -$as_echo_n "checking for ZSTD_compress in -lzstd... " >&6; } -if ${ac_cv_lib_zstd_ZSTD_compress+:} false; then : + + + + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lzstd $LIBS" + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi + + + + +# Check whether --with-zstd was given. +if test "${with_zstd+set}" = set; then : + withval=$with_zstd; with_zstd=$withval +else + with_zstd=auto +fi + + +# Check whether --with-zstd-include was given. +if test "${with_zstd_include+set}" = set; then : + withval=$with_zstd_include; +fi + + +# Check whether --with-zstd-lib was given. +if test "${with_zstd_lib+set}" = set; then : + withval=$with_zstd_lib; +fi + +zstd_enabled=no +zstd_pkg_config=no +zstd_use_pkg_config=no +zstd_include_dir= +zstd_library_dir= +case "x$with_zstd" in + xno) + ;; + xyes|xauto) + zstd_enabled=yes + zstd_use_pkg_config=yes + ;; + *) + zstd_enabled=yes + zstd_include_dir=$with_zstd/include + zstd_library_dir=$with_zstd/lib + ;; +esac + +if test "$zstd_use_pkg_config" = yes; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5 +$as_echo_n "checking for libzstd >= 1.4.0... " >&6; } + +if test -n "$ZSTD_CFLAGS"; then + pkg_cv_ZSTD_CFLAGS="$ZSTD_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd >= 1.4.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libzstd >= 1.4.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_ZSTD_CFLAGS=`$PKG_CONFIG --cflags "libzstd >= 1.4.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$ZSTD_LIBS"; then + pkg_cv_ZSTD_LIBS="$ZSTD_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd >= 1.4.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libzstd >= 1.4.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_ZSTD_LIBS=`$PKG_CONFIG --libs "libzstd >= 1.4.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + +if test $pkg_failed = no; then + pkg_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $pkg_cv_ZSTD_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + pkg_failed=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$pkg_save_LDFLAGS +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + ZSTD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd >= 1.4.0" 2>&1` + else + ZSTD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd >= 1.4.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$ZSTD_PKG_ERRORS" >&5 + + : +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + : +else + ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS + ZSTD_LIBS=$pkg_cv_ZSTD_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + zstd_pkg_config=yes + +fi +fi + +if test "$zstd_enabled" = yes; then + saved_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + while :; do + if test "x$with_zstd_include" != x; then + if test "$zstd_pkg_config" = yes; then + ZSTD_CFLAGS="-I$with_zstd_include $ZSTD_CFLAGS" + else + zstd_include_dir=$with_zstd_include + fi + fi + if test "x$with_zstd_lib" != x; then + zstd_library_dir=$with_zstd_lib + fi + if test "$zstd_pkg_config" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= + if test "x$zstd_include_dir" != x \ + && test "x$zstd_include_dir" != xno; then + ZSTD_CFLAGS=-I$zstd_include_dir + fi + fi + if test "x$zstd_library_dir" != x \ + && test "x$zstd_library_dir" != xno; then + ZSTD_LIBS="-L$zstd_library_dir $ZSTD_LIBS" + fi + + CFLAGS="$saved_CFLAGS $ZSTD_CFLAGS" + + # Check for a usable zstd library and header. Ignore cached results + # that may have been obtained with different search flags. + unset ac_cv_search_ZSTD_compress ac_cv_zstd_h + zstd_lib_usable=no + LIBS="$ZSTD_LIBS $save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -14448,24 +14779,114 @@ return ZSTD_compress (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_zstd_ZSTD_compress=yes -else - ac_cv_lib_zstd_ZSTD_compress=no +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + zstd_lib_usable=yes +else + zstd_lib_usable=no +fi + + if test "$zstd_lib_usable" = yes \ + && test "$ac_cv_search_ZSTD_compress" != "none required"; then + # Add the library only if AC_SEARCH_LIBS needed additional flags. + ZSTD_LIBS="$ac_cv_search_ZSTD_compress $ZSTD_LIBS" + fi + LIBS="$save_LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${ac_cv_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include <zstd.h> + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes +else + ac_cv_zstd_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zstd_ZSTD_compress" >&5 -$as_echo "$ac_cv_lib_zstd_ZSTD_compress" >&6; } -if test "x$ac_cv_lib_zstd_ZSTD_compress" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_zstd_h" >&5 +$as_echo "$ac_cv_zstd_h" >&6; } + if test "$zstd_pkg_config" = yes \ + && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: pkg-config zstd is unusable; trying compiler search" >&5 +$as_echo "$as_me: pkg-config zstd is unusable; trying compiler search" >&6;} + zstd_pkg_config=no + ZSTD_CFLAGS= + ZSTD_LIBS= + else + break + fi + done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then $as_echo "#define HAVE_ZSTD 1" >>confdefs.h + elif test "$with_zstd" != auto; then + as_fn_error $? "Unable to find a usable zstd library and zstd.h. See + config.log for details." "$LINENO" 5 + else + # In auto mode, an unusable installation simply disables zstd. + zstd_enabled=no + fi + + CFLAGS="$saved_CFLAGS" +fi +if test "$zstd_enabled" != yes; then + ZSTD_CFLAGS= + ZSTD_LIBS= fi - if test "$ac_cv_lib_zstd_ZSTD_compress" = yes; then + if test "$zstd_enabled" = yes; then HAVE_ZSTD_TRUE= HAVE_ZSTD_FALSE='#' else diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 91830fe6f2f9..ec9fd349f8a5 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -545,9 +545,8 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(,)], LDFLAGS=$LDFLAGS_hold]) AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GABI, test "$libgo_cv_ld_compress_zlib_gabi" = yes) -AC_CHECK_LIB([zstd], [ZSTD_compress], - [AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])]) -AM_CONDITIONAL(HAVE_ZSTD, test "$ac_cv_lib_zstd_ZSTD_compress" = yes) +AC_ZSTD +AM_CONDITIONAL(HAVE_ZSTD, test "$zstd_enabled" = yes) dnl Test whether the linker supports --compress-debug-sections=zstd option. AC_CACHE_CHECK([whether --compress-debug-sections=zstd is supported],
