* [PATCH v3] configure: Sync zstd detection with GCC
2026-09-29 2:00 ` Simon Marchi
@ 2026-10-20 17:40 ` Torbjörn SVENSSON
2026-10-21 6:56 ` Alan Modra
0 siblings, 1 reply; 7+ messages in thread
From: Torbjörn SVENSSON @ 2026-10-20 17:40 UTC (permalink / raw)
To: binutils, gdb-patches; +Cc: simark, Torbjörn SVENSSON
Hi,
I've now update the GCC version of zstd.m4 to contain a unified
implementation to detect zstd support.
Please let me know if there is something I've missed.
V1 can be found here:
https://sourceware.org/pipermail/binutils/2026-September/151687.html
V2 can be found here:
https://sourceware.org/pipermail/binutils/2026-September/151690.html
Changes since v1:
- Added missed changes in binutils/Makefile.am and binutils/Makefile.in
- Added support for dynamic version of zstd in path
Changes since v2:
- Updated the GCC version of config/zstd.m4 and synced back those
changes to this tree.
- Fixed gold/configure.ac to use $zstd_enabled.
Ok for trunk?
Kind regards,
Torbjörn
--
Sync config/zstd.m4 with GCC to support compiler-based detection and
configurable zstd search paths.
Add ZSTD_LIBS to binutils link commands for tools using zstd through
BFD. Base gold's zstd test conditional on the final detection result
rather than pkg-config flags.
Regenerate the affected configure scripts and binutils Makefile.in.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
bfd/configure | 240 +++++++++++++++++++++++++++++++++++++++----
binutils/Makefile.am | 14 +--
binutils/Makefile.in | 16 +--
binutils/configure | 236 +++++++++++++++++++++++++++++++++++++++---
config/zstd.m4 | 134 +++++++++++++++++++++---
gas/configure | 240 +++++++++++++++++++++++++++++++++++++++----
gdb/configure | 236 +++++++++++++++++++++++++++++++++++++++---
gold/configure | 238 ++++++++++++++++++++++++++++++++++++++----
gold/configure.ac | 2 +-
ld/configure | 236 +++++++++++++++++++++++++++++++++++++++---
10 files changed, 1457 insertions(+), 135 deletions(-)
diff --git a/bfd/configure b/bfd/configure
index a4326160c57..fd8db630cf6 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -653,11 +653,11 @@ TDEFINES
SHARED_LIBADD
SHARED_LDFLAGS
LIBM
-ZSTD_LIBS
-ZSTD_CFLAGS
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
+ZSTD_LIBS
+ZSTD_CFLAGS
zlibinc
zlibdir
EXEEXT_FOR_BUILD
@@ -855,6 +855,8 @@ with_libintl_prefix
with_libintl_type
with_system_zlib
with_zstd
+with_zstd_include
+with_zstd_lib
'
ac_precious_vars='build_alias
host_alias
@@ -1540,8 +1542,15 @@ Optional Packages:
--without-libintl-prefix don't search for libintl in includedir and libdir
--with-libintl-type=TYPE type of library to search for (auto/static/shared)
--with-system-zlib use installed libz
- --with-zstd support zstd compressed debug sections
- (default=auto)
+ --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
@@ -11527,7 +11536,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11530 "configure"
+#line 11539 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11633,7 +11642,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11636 "configure"
+#line 11645 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15415,15 +15424,47 @@ $as_echo "no" >&6; }
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
-if test "$with_zstd" != no; then :
+# 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
@@ -15507,31 +15548,192 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
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
-$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+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. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+ ;
+ return 0;
+}
+_ACEOF
+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
+ 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_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
diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index edcbc67bde4..0582d9fb826 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -251,7 +251,7 @@ dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
-LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS)
size_SOURCES = size.c $(BULIBS)
@@ -271,7 +271,7 @@ nm_new_SOURCES = nm.c demanguse.c $(BULIBS)
objdump_SOURCES = objdump.c dwarf.c prdbg.c demanguse.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
EXTRA_objdump_SOURCES = od-elf32_avr.c od-macho.c od-xcoff.c od-pe.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS) $(LIBSFRAME)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS) $(DEBUGINFOD_LIBS) $(LIBSFRAME)
objdump.@OBJEXT@:objdump.c
if am__fastdepCC
@@ -290,11 +290,11 @@ cxxfilt_SOURCES = cxxfilt.c $(BULIBS)
ar_SOURCES = arparse.y arlex.l not-ranlib.c arsup.c rename.c binemul.c \
emul_$(EMULATION).c $(BULIBS)
EXTRA_ar_SOURCES = $(CFILES)
-ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL)
+ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS)
ranlib_SOURCES = arparse.y arlex.l is-ranlib.c arsup.c rename.c binemul.c \
emul_$(EMULATION).c $(BULIBS)
-ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL)
+ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS)
addr2line_SOURCES = addr2line.c $(BULIBS)
@@ -485,7 +485,7 @@ srconv_SOURCES = srconv.c coffgrok.c $(BULIBS)
srconv.@OBJEXT@: sysroff.c
dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS)
-dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL)
+dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS)
dlltool.@OBJEXT@:
if am__fastdepCC
@@ -518,11 +518,11 @@ sysdump.@OBJEXT@: sysroff.c
windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \
winduni.c resres.c $(BULIBS)
-windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV)
+windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS)
windmc_SOURCES = windmc.c mcparse.y mclex.c \
winduni.c $(BULIBS)
-windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV)
+windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS)
dllwrap_SOURCES = dllwrap.c version.c
dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL)
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index fff4565e302..69f6a1e128c 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -282,7 +282,7 @@ am__dirstamp = $(am__leading_dot)dirstamp
testsuite_gentestdlls_OBJECTS = testsuite/gentestdlls.$(OBJEXT)
testsuite_gentestdlls_LDADD = $(LDADD)
testsuite_gentestdlls_DEPENDENCIES = $(BFDLIB) $(LIBIBERTY) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_windmc_OBJECTS = windmc.$(OBJEXT) mcparse.$(OBJEXT) mclex.$(OBJEXT) \
winduni.$(OBJEXT) $(am__objects_1)
windmc_OBJECTS = $(am_windmc_OBJECTS)
@@ -794,7 +794,7 @@ elfedit_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
-LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS)
size_SOURCES = size.c $(BULIBS)
objcopy_SOURCES = not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
strings_SOURCES = strings.c $(BULIBS)
@@ -806,31 +806,31 @@ strip_new_SOURCES = is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
nm_new_SOURCES = nm.c demanguse.c $(BULIBS)
objdump_SOURCES = objdump.c dwarf.c prdbg.c demanguse.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS)
EXTRA_objdump_SOURCES = od-elf32_avr.c od-macho.c od-xcoff.c od-pe.c
-objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS) $(LIBSFRAME)
+objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(ZSTD_LIBS) $(DEBUGINFOD_LIBS) $(LIBSFRAME)
cxxfilt_SOURCES = cxxfilt.c $(BULIBS)
ar_SOURCES = arparse.y arlex.l not-ranlib.c arsup.c rename.c binemul.c \
emul_$(EMULATION).c $(BULIBS)
EXTRA_ar_SOURCES = $(CFILES)
-ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL)
+ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS)
ranlib_SOURCES = arparse.y arlex.l is-ranlib.c arsup.c rename.c binemul.c \
emul_$(EMULATION).c $(BULIBS)
-ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL)
+ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS)
addr2line_SOURCES = addr2line.c $(BULIBS)
srconv_SOURCES = srconv.c coffgrok.c $(BULIBS)
dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS)
-dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL)
+dlltool_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(ZSTD_LIBS)
coffdump_SOURCES = coffdump.c coffgrok.c $(BULIBS)
sysdump_SOURCES = sysdump.c $(BULIBS)
windres_SOURCES = windres.c resrc.c rescoff.c resbin.c rcparse.y rclex.c \
winduni.c resres.c $(BULIBS)
-windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV)
+windres_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS)
windmc_SOURCES = windmc.c mcparse.y mclex.c \
winduni.c $(BULIBS)
-windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV)
+windmc_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) $(LIBICONV) $(ZSTD_LIBS)
dllwrap_SOURCES = dllwrap.c version.c
dllwrap_LDADD = $(LIBIBERTY) $(LIBINTL)
EXTRA_DIST = arparse.c arparse.h arlex.c sysinfo.c sysinfo.h \
diff --git a/binutils/configure b/binutils/configure
index ea19d09749f..853bf8e7fd2 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -846,6 +846,8 @@ with_libintl_type
enable_maintainer_mode
with_system_zlib
with_zstd
+with_zstd_include
+with_zstd_lib
with_msgpack
'
ac_precious_vars='build_alias
@@ -1540,8 +1542,15 @@ Optional Packages:
--without-libintl-prefix don't search for libintl in includedir and libdir
--with-libintl-type=TYPE type of library to search for (auto/static/shared)
--with-system-zlib use installed libz
- --with-zstd support zstd compressed debug sections
- (default=auto)
+ --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
--with-msgpack Enable msgpack support (auto/yes/no)
Some influential environment variables:
@@ -11455,7 +11464,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11458 "configure"
+#line 11467 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11561,7 +11570,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11564 "configure"
+#line 11573 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15865,15 +15874,47 @@ 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
-if test "$with_zstd" != no; then :
+# 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
@@ -15957,31 +15998,192 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
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
-$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+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. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+ ;
+ return 0;
+}
+_ACEOF
+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
+ 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_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
diff --git a/config/zstd.m4 b/config/zstd.m4
index eb34c0f36d7..28788782d3b 100644
--- a/config/zstd.m4
+++ b/config/zstd.m4
@@ -5,19 +5,129 @@ dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
-dnl Enable features using the zstd library.
+dnl Set up and check zstd support.
AC_DEFUN([AC_ZSTD], [
+AC_SUBST(ZSTD_CFLAGS)
+AC_SUBST(ZSTD_LIBS)
AC_ARG_WITH(zstd,
- [AS_HELP_STRING([--with-zstd], [support zstd compressed debug sections (default=auto)])],
- [], [with_zstd=auto])
-
-AS_IF([test "$with_zstd" != no],
- [PKG_CHECK_MODULES(ZSTD, [libzstd >= 1.4.0], [
- AC_DEFINE(HAVE_ZSTD, 1, [Define to 1 if zstd is enabled.])
- ], [
- if test "$with_zstd" = yes; then
- AC_MSG_ERROR([--with-zstd was given, but pkgconfig/libzstd.pc is not found])
+ [AS_HELP_STRING([--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=$withval], [with_zstd=auto])
+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])])
+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_CHECK_MODULES([ZSTD], [libzstd >= 1.4.0], [
+ zstd_pkg_config=yes
+ ], [:])
+fi
+
+if test "$zstd_enabled" = yes; then
+ saved_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ AC_LANG_PUSH([C])
+ 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"
+
+ AC_SEARCH_LIBS([ZSTD_compress], [zstd],
+ [zstd_lib_usable=yes],
+ [zstd_lib_usable=no])
+ 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"
+
+ AC_CACHE_CHECK([for zstd.h], [ac_cv_zstd_h],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <zstd.h>
+ #if ZSTD_VERSION_NUMBER < 10400
+ #error "need zstd 1.4.0 or better"
+ #endif
+ ]], [[]])],
+ [ac_cv_zstd_h=yes],
+ [ac_cv_zstd_h=no])])
+ if test "$zstd_pkg_config" = yes \
+ && { test "$zstd_lib_usable" != yes || test "$ac_cv_zstd_h" != yes; }; then
+ AC_MSG_NOTICE([pkg-config zstd is unusable; trying compiler search])
+ zstd_pkg_config=no
+ ZSTD_CFLAGS=
+ ZSTD_LIBS=
+ else
+ break
+ fi
+ done
+ AC_LANG_POP([C])
+ if test "$zstd_lib_usable" = yes && test "$ac_cv_zstd_h" = yes; then
+ AC_DEFINE(HAVE_ZSTD, 1, [Define if zstd is available.])
+ elif test "$with_zstd" != auto; then
+ AC_MSG_ERROR([Unable to find a usable zstd library and zstd.h. See
+ config.log for details.])
+ 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
])
diff --git a/gas/configure b/gas/configure
index 8afaf2729ed..0edbdd4ec04 100755
--- a/gas/configure
+++ b/gas/configure
@@ -634,11 +634,11 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
-ZSTD_LIBS
-ZSTD_CFLAGS
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
+ZSTD_LIBS
+ZSTD_CFLAGS
zlibinc
zlibdir
LIBM
@@ -838,6 +838,8 @@ with_libintl_type
enable_maintainer_mode
with_system_zlib
with_zstd
+with_zstd_include
+with_zstd_lib
'
ac_precious_vars='build_alias
host_alias
@@ -1531,8 +1533,15 @@ Optional Packages:
--without-libintl-prefix don't search for libintl in includedir and libdir
--with-libintl-type=TYPE type of library to search for (auto/static/shared)
--with-system-zlib use installed libz
- --with-zstd support zstd compressed debug sections
- (default=auto)
+ --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
@@ -11152,7 +11161,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11155 "configure"
+#line 11164 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11258,7 +11267,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11261 "configure"
+#line 11270 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16142,15 +16151,47 @@ $as_echo "no" >&6; }
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
-if test "$with_zstd" != no; then :
+# 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
@@ -16234,31 +16275,192 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
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
-$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+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. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+ ;
+ return 0;
+}
+_ACEOF
+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
+ 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_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
diff --git a/gdb/configure b/gdb/configure
index 810e9ed7a37..78b79b7c3b2 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -946,6 +946,8 @@ with_pkgversion
with_bugurl
with_system_zlib
with_zstd
+with_zstd_include
+with_zstd_lib
with_iconv_bin
with_system_readline
with_jit_reader_dir
@@ -1721,8 +1723,15 @@ Optional Packages:
--with-pkgversion=PKG Use PKG in the version string in place of "GDB"
--with-bugurl=URL Direct users to URL to report a bug
--with-system-zlib use installed libz
- --with-zstd support zstd compressed debug sections
- (default=auto)
+ --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
--with-iconv-bin=PATH specify where to find the iconv program
--with-system-readline use installed readline library
--with-jit-reader-dir=PATH
@@ -11877,7 +11886,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11880 "configure"
+#line 11889 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11983,7 +11992,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11986 "configure"
+#line 11995 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -26715,15 +26724,47 @@ 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
-if test "$with_zstd" != no; then :
+# 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
@@ -26807,31 +26848,192 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
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
-$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+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. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+ ;
+ return 0;
+}
+_ACEOF
+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
+ 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_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
diff --git a/gold/configure b/gold/configure
index a81a04f0531..e159551e389 100755
--- a/gold/configure
+++ b/gold/configure
@@ -644,11 +644,11 @@ ax_pthread_config
SED
HAVE_ZSTD_FALSE
HAVE_ZSTD_TRUE
-ZSTD_LIBS
-ZSTD_CFLAGS
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
+ZSTD_LIBS
+ZSTD_CFLAGS
zlibinc
zlibdir
LIBOBJS
@@ -873,6 +873,8 @@ with_gold_ldflags
with_gold_ldadd
with_system_zlib
with_zstd
+with_zstd_include
+with_zstd_lib
enable_threads
enable_jansson
enable_maintainer_mode
@@ -1555,8 +1557,15 @@ Optional Packages:
--with-gold-ldflags=FLAGS additional link flags for gold
--with-gold-ldadd=LIBS additional libraries for gold
--with-system-zlib use installed libz
- --with-zstd support zstd compressed debug sections
- (default=auto)
+ --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
@@ -9989,15 +9998,47 @@ $as_echo "no" >&6; }
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
-if test "$with_zstd" != no; then :
+# 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
@@ -10081,34 +10122,195 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
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
-$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+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. */
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+ ;
+ return 0;
+}
+_ACEOF
+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
+ 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_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 "$pkg_cv_ZSTD_LIBS" != ""; then
+ if test "$zstd_enabled" = yes; then
HAVE_ZSTD_TRUE=
HAVE_ZSTD_FALSE='#'
else
diff --git a/gold/configure.ac b/gold/configure.ac
index fe6ace01693..89348b660be 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -566,7 +566,7 @@ fi
# Link in zlib/zstd if we can. This allows us to write compressed sections.
AM_ZLIB
AC_ZSTD
-AM_CONDITIONAL(HAVE_ZSTD, test "$pkg_cv_ZSTD_LIBS" != "")
+AM_CONDITIONAL(HAVE_ZSTD, test "$zstd_enabled" = yes)
AC_ARG_ENABLE([threads],
[[ --enable-threads[=ARG] multi-threaded linking [ARG={auto,yes,no}]]],
diff --git a/ld/configure b/ld/configure
index 4d755384c41..5f5c8d311dc 100755
--- a/ld/configure
+++ b/ld/configure
@@ -877,6 +877,8 @@ with_libintl_type
with_xxhash
with_system_zlib
with_zstd
+with_zstd_include
+with_zstd_lib
'
ac_precious_vars='build_alias
host_alias
@@ -1598,8 +1600,15 @@ Optional Packages:
--with-xxhash use inlined libxxhash for hashing (faster)
(auto/yes/no)
--with-system-zlib use installed libz
- --with-zstd support zstd compressed debug sections
- (default=auto)
+ --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
@@ -11894,7 +11903,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11897 "configure"
+#line 11906 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12000,7 +12009,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12003 "configure"
+#line 12012 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19080,15 +19089,47 @@ 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
-if test "$with_zstd" != no; then :
+# 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
@@ -19172,31 +19213,192 @@ fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
-
- if test "$with_zstd" = yes; then
- as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
- fi
-
+ :
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
-$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+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. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_compress ();
+int
+main ()
+{
+return ZSTD_compress ();
+ ;
+ return 0;
+}
+_ACEOF
+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
+ 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_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
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread