https://gcc.gnu.org/g:54d465833fee79901ae93952e8e2298d01396b63
commit r17-5386-g54d465833fee79901ae93952e8e2298d01396b63 Author: Torbjörn SVENSSON <[email protected]> Date: Tue Sep 29 11:58:49 2026 +0200 gcc: Use shared zstd detection Replace GCC's local zstd checks with AC_ZSTD. Keep defining HAVE_ZSTD_H for GCC when zstd support is enabled. gcc/ChangeLog: * aclocal.m4: Add includes for pkg.m4 and zstd.m4. * configure: Regenerate. * configure.ac: Use AC_ZSTD and define HAVE_ZSTD_H when enabled. * Makefile.in: Use @ZSTD_CFLAGS@ and @ZSTD_LIBS@. Signed-off-by: Torbjörn SVENSSON <[email protected]> Diff: --- gcc/Makefile.in | 4 +- gcc/aclocal.m4 | 2 + gcc/configure | 510 +++++++++++++++++++++++++++++++++++++++++++------------ gcc/configure.ac | 80 +-------- 4 files changed, 406 insertions(+), 190 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 83cb4884eb13..f2a015d729df 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1185,8 +1185,8 @@ GDCFLAGS = @GDCFLAGS@ # Libs needed (at present) just for jcf-dump. LDEXP_LIB = @LDEXP_LIB@ -ZSTD_INC = @ZSTD_CPPFLAGS@ -ZSTD_LIB = @ZSTD_LDFLAGS@ @ZSTD_LIB@ +ZSTD_INC = @ZSTD_CFLAGS@ +ZSTD_LIB = @ZSTD_LIBS@ # Likewise, for use in the tools that must run on this machine # even if we are cross-building GCC. diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4 index e44fc5fb2ab6..b0c66709415b 100644 --- a/gcc/aclocal.m4 +++ b/gcc/aclocal.m4 @@ -89,8 +89,10 @@ m4_include([../config/nls.m4]) m4_include([../config/override.m4]) m4_include([../config/picflag.m4]) m4_include([../config/po.m4]) +m4_include([../config/pkg.m4]) m4_include([../config/progtest.m4]) m4_include([../config/stdint.m4]) m4_include([../config/warnings.m4]) m4_include([../config/zlib.m4]) +m4_include([../config/zstd.m4]) m4_include([acinclude.m4]) diff --git a/gcc/configure b/gcc/configure index 456c1d1aba76..69efa53e31e0 100755 --- a/gcc/configure +++ b/gcc/configure @@ -811,10 +811,11 @@ manext LIBICONV_DEP LTLIBICONV LIBICONV -ZSTD_LDFLAGS -ZSTD_CPPFLAGS -ZSTD_LIB -ZSTD_INCLUDE +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG +ZSTD_LIBS +ZSTD_CFLAGS DL_LIB LDEXP_LIB EXTRA_GCC_LIBS @@ -1088,6 +1089,11 @@ CXXFLAGS CCC CXXCPP CPP +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +ZSTD_CFLAGS +ZSTD_LIBS GMPLIBS GMPINC ISLLIBS @@ -1905,8 +1911,11 @@ Optional Packages: Multi-libs configuration string (RISC-V only) --with-picolibc Support for picolibc, including command line options and spec rules - --with-zstd=PATH specify prefix directory for installed zstd library. - Equivalent to --with-zstd-include=PATH/include plus + --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 @@ -1962,6 +1971,13 @@ Some influential environment variables: CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor 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 GMPLIBS How to link GMP GMPINC How to find GMP include files ISLLIBS How to link isl @@ -2799,6 +2815,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_cxx_check_header_preproc +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_cxx_check_func LINENO FUNC VAR # ------------------------------------ # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -2912,52 +2974,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_cxx_check_decl -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - # ac_fn_c_check_header_preproc LINENO HEADER VAR # ---------------------------------------------- # Tests whether HEADER is present, setting the cache variable VAR accordingly. @@ -10344,18 +10360,135 @@ $as_echo "#define HAVE_AFUNIX_H 1" >>confdefs.h fi # Look for the ZSTD package. -ZSTD_INCLUDE= -ZSTD_LIB= -ZSTD_CPPFLAGS= -ZSTD_LDFLAGS= + + + + + +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 + 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; + withval=$with_zstd; with_zstd=$withval +else + with_zstd=auto fi @@ -10370,42 +10503,167 @@ 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 - x) ;; xno) - ZSTD_INCLUDE= - ZSTD_LIB= ;; - *) ZSTD_INCLUDE=$with_zstd/include - ZSTD_LIB=$with_zstd/lib - ;; + 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 "x$with_zstd" != xno; then -if test "x$with_zstd_include" != x; then - ZSTD_INCLUDE=$with_zstd_include +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_cxx_try_link "$LINENO"; then : + +else + pkg_failed=yes fi -if test "x$with_zstd_lib" != x; then - ZSTD_LIB=$with_zstd_lib +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$pkg_save_LDFLAGS fi -if test "x$ZSTD_INCLUDE" != x \ - && test "x$ZSTD_INCLUDE" != xno; then - ZSTD_CPPFLAGS=-I$ZSTD_INCLUDE + + + +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 -if test "x$ZSTD_LIB" != x \ - && test "x$ZSTD_LIB" != xno; then - ZSTD_LDFLAGS=-L$ZSTD_LIB fi -saved_CXXFLAGS="$CXXFLAGS" -saved_LDFLAGS="$LDFLAGS" -CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS" -LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS" +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 -# LTO can use zstd compression algorithm -save_LIBS="$LIBS" -LIBS= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 + 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 @@ -10436,7 +10694,7 @@ for ac_lib in '' zstd; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_cxx_try_link "$LINENO"; then : + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_ZSTD_compress=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -10458,28 +10716,31 @@ $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 - gcc_cv_header_zstd_h=no + zstd_lib_usable=no fi -ZSTD_LIB="$LIBS" -LIBS="$save_LIBS" - + 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 "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 $as_echo_n "checking for zstd.h... " >&6; } -if ${gcc_cv_header_zstd_h+:} false; then : +if ${ac_cv_zstd_h+:} false; then : $as_echo_n "(cached) " >&6 else - # We require version 1.3.0 or later. This is the first version that has -# ZSTD_getFrameContentSize. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <zstd.h> -#if ZSTD_VERSION_NUMBER < 10300 -#error "need zstd 1.3.0 or better" -#endif + + #include <zstd.h> + #if ZSTD_VERSION_NUMBER < 10400 + #error "need zstd 1.4.0 or better" + #endif + int main () { @@ -10488,26 +10749,55 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - gcc_cv_header_zstd_h=yes +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_zstd_h=yes else - gcc_cv_header_zstd_h=no + 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_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=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_header_zstd_h" >&5 -$as_echo "$gcc_cv_header_zstd_h" >&6; } -if test $gcc_cv_header_zstd_h = yes; then + if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then -$as_echo "#define HAVE_ZSTD_H 1" >>confdefs.h +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h -elif test "x$with_zstd" != x; then - as_fn_error $? "Unable to find zstd.h. See config.log for details." "$LINENO" 5 + 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 -CXXFLAGS="$saved_CXXFLAGS" -LDFLAGS="$saved_LDFLAGS" +if test "$zstd_enabled" = yes; then + +$as_echo "#define HAVE_ZSTD_H 1" >>confdefs.h + fi @@ -21777,7 +22067,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21780 "configure" +#line 22070 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -21883,7 +22173,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21886 "configure" +#line 22176 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 395e793a96c7..ad789cb860c2 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1487,86 +1487,10 @@ if test $gcc_cv_header_afunix_h = yes; then fi # Look for the ZSTD package. -ZSTD_INCLUDE= -ZSTD_LIB= -AC_SUBST(ZSTD_INCLUDE) -AC_SUBST(ZSTD_LIB) -ZSTD_CPPFLAGS= -ZSTD_LDFLAGS= -AC_SUBST(ZSTD_CPPFLAGS) -AC_SUBST(ZSTD_LDFLAGS) -AC_ARG_WITH(zstd, - [AS_HELP_STRING([--with-zstd=PATH], - [specify prefix directory for installed zstd library. - Equivalent to --with-zstd-include=PATH/include - plus --with-zstd-lib=PATH/lib])]) -AC_ARG_WITH(zstd-include, - [AS_HELP_STRING([--with-zstd-include=PATH], - [specify directory for installed zstd include files])]) -AC_ARG_WITH(zstd-lib, - [AS_HELP_STRING([--with-zstd-lib=PATH], - [specify directory for the installed zstd library])]) -case "x$with_zstd" in - x) ;; - xno) - ZSTD_INCLUDE= - ZSTD_LIB= - ;; - *) ZSTD_INCLUDE=$with_zstd/include - ZSTD_LIB=$with_zstd/lib - ;; -esac - -if test "x$with_zstd" != xno; then -if test "x$with_zstd_include" != x; then - ZSTD_INCLUDE=$with_zstd_include -fi -if test "x$with_zstd_lib" != x; then - ZSTD_LIB=$with_zstd_lib -fi -if test "x$ZSTD_INCLUDE" != x \ - && test "x$ZSTD_INCLUDE" != xno; then - ZSTD_CPPFLAGS=-I$ZSTD_INCLUDE -fi -if test "x$ZSTD_LIB" != x \ - && test "x$ZSTD_LIB" != xno; then - ZSTD_LDFLAGS=-L$ZSTD_LIB -fi - -saved_CXXFLAGS="$CXXFLAGS" -saved_LDFLAGS="$LDFLAGS" -CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS" -LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS" - -# LTO can use zstd compression algorithm -save_LIBS="$LIBS" -LIBS= -AC_SEARCH_LIBS(ZSTD_compress, zstd,, gcc_cv_header_zstd_h=no) -ZSTD_LIB="$LIBS" -LIBS="$save_LIBS" -AC_SUBST(ZSTD_LIB) - -AC_MSG_CHECKING(for zstd.h) -AC_CACHE_VAL(gcc_cv_header_zstd_h, -# We require version 1.3.0 or later. This is the first version that has -# ZSTD_getFrameContentSize. -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( -[[#include <zstd.h> -#if ZSTD_VERSION_NUMBER < 10300 -#error "need zstd 1.3.0 or better" -#endif]])], - [gcc_cv_header_zstd_h=yes], - [gcc_cv_header_zstd_h=no])]) -AC_MSG_RESULT($gcc_cv_header_zstd_h) -if test $gcc_cv_header_zstd_h = yes; then +AC_ZSTD +if test "$zstd_enabled" = yes; then AC_DEFINE(HAVE_ZSTD_H, 1, [Define if you have a working <zstd.h> header file.]) -elif test "x$with_zstd" != x; then - as_fn_error $? "Unable to find zstd.h. See config.log for details." "$LINENO" 5 -fi - -CXXFLAGS="$saved_CXXFLAGS" -LDFLAGS="$saved_LDFLAGS" fi dnl Disabled until we have a complete test for buggy enum bitfields.
