* [PATCH v2] configure: Support --with-zstd=PATH
@ 2026-09-28 5:30 Torbjörn SVENSSON
2026-09-29 2:00 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Torbjörn SVENSSON @ 2026-09-28 5:30 UTC (permalink / raw)
To: binutils, gdb-patches; +Cc: Torbjörn SVENSSON
Hi,
V1 can be found here:
https://sourceware.org/pipermail/binutils/2026-September/151687.html
Changes since v1:
- Added missed changes in binutils/Makefile.am and binutils/Makefile.in
- Added support for dynamic version of zstd in path
Ok for trunk?
Kind regards,
Torbjörn
--
Allow --with-zstd to specify an installation prefix. Use the headers
and static library under that prefix, and reject it if it does not
provide zstd 1.4.0 or newer.
Regenerate the affected configure scripts.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
bfd/configure | 90 +++++++++++++++++++++++++++++++++++++++-----
binutils/Makefile.am | 14 +++----
binutils/Makefile.in | 16 ++++----
binutils/configure | 90 +++++++++++++++++++++++++++++++++++++++-----
config/zstd.m4 | 63 ++++++++++++++++++++++++++-----
gas/configure | 90 +++++++++++++++++++++++++++++++++++++++-----
gdb/configure | 90 +++++++++++++++++++++++++++++++++++++++-----
gold/configure | 90 +++++++++++++++++++++++++++++++++++++++-----
ld/configure | 90 +++++++++++++++++++++++++++++++++++++++-----
9 files changed, 555 insertions(+), 78 deletions(-)
diff --git a/bfd/configure b/bfd/configure
index a4326160c57..53ec433c0fb 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -1540,8 +1540,8 @@ 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[=PATH] support zstd compressed debug sections, optionally
+ using zstd installed under PATH (default=auto)
Some influential environment variables:
CC C compiler command
@@ -15423,7 +15423,11 @@ else
fi
-if test "$with_zstd" != no; then :
+case $with_zstd in #(
+ no) :
+ ;; #(
+ yes|auto) :
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5
@@ -15508,17 +15512,21 @@ fi
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
+ 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
+ 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
@@ -15531,8 +15539,72 @@ $as_echo "#define HAVE_ZSTD 1" >>confdefs.h
fi
+ ;; #(
+ *) :
+
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd >= 1.4.0 in $with_zstd" >&5
+$as_echo_n "checking for zstd >= 1.4.0 in $with_zstd... " >&6; }
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+
+int
+main ()
+{
+
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ have_zstd=yes
+else
+ have_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_zstd" >&5
+$as_echo "$have_zstd" >&6; }
+
+ if test "$have_zstd" = yes; then :
+
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+
+else
+
+ as_fn_error $? "zstd >= 1.4.0 was not found under $with_zstd" "$LINENO" 5
fi
+ ;; #(
+ *) :
+ ;;
+esac
+
+
+
save_CFLAGS="$CFLAGS"
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..14b28d0df20 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -1540,8 +1540,8 @@ 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[=PATH] support zstd compressed debug sections, optionally
+ using zstd installed under PATH (default=auto)
--with-msgpack Enable msgpack support (auto/yes/no)
Some influential environment variables:
@@ -15873,7 +15873,11 @@ else
fi
-if test "$with_zstd" != no; then :
+case $with_zstd in #(
+ no) :
+ ;; #(
+ yes|auto) :
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5
@@ -15958,17 +15962,21 @@ fi
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
+ 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
+ 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
@@ -15981,8 +15989,72 @@ $as_echo "#define HAVE_ZSTD 1" >>confdefs.h
fi
+ ;; #(
+ *) :
+
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd >= 1.4.0 in $with_zstd" >&5
+$as_echo_n "checking for zstd >= 1.4.0 in $with_zstd... " >&6; }
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+
+int
+main ()
+{
+
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ have_zstd=yes
+else
+ have_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_zstd" >&5
+$as_echo "$have_zstd" >&6; }
+
+ if test "$have_zstd" = yes; then :
+
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+
+else
+
+ as_fn_error $? "zstd >= 1.4.0 was not found under $with_zstd" "$LINENO" 5
fi
+ ;; #(
+ *) :
+ ;;
+esac
+
+
+
diff --git a/config/zstd.m4 b/config/zstd.m4
index eb34c0f36d7..49595283e81 100644
--- a/config/zstd.m4
+++ b/config/zstd.m4
@@ -8,16 +8,61 @@ dnl the same distribution terms as the rest of that program.
dnl Enable features using the zstd library.
AC_DEFUN([AC_ZSTD], [
AC_ARG_WITH(zstd,
- [AS_HELP_STRING([--with-zstd], [support zstd compressed debug sections (default=auto)])],
+ [AS_HELP_STRING([--with-zstd@<:@=PATH@:>@],
+ [support zstd compressed debug sections, optionally using zstd installed under PATH (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])
- fi
- ])
+AS_CASE([$with_zstd],
+ [no], [],
+ [yes|auto], [
+ PKG_CHECK_MODULES([ZSTD], [libzstd >= 1.4.0], [
+ AC_DEFINE(HAVE_ZSTD, 1, [Define to 1 if zstd is enabled.])
+ ], [
+ AS_IF([test "$with_zstd" = yes], [
+ AC_MSG_ERROR(
+ [--with-zstd was given, but pkgconfig/libzstd.pc is not found])
+ ])
+ ])
+ ],
+ [*], [
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ AC_MSG_CHECKING([for zstd >= 1.4.0 in $with_zstd])
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+ ]],
+ [[
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+ ]])],
+ [have_zstd=yes],
+ [have_zstd=no])
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ AC_MSG_RESULT([$have_zstd])
+
+ AS_IF([test "$have_zstd" = yes], [
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+ AC_DEFINE(HAVE_ZSTD, 1, [Define to 1 if zstd is enabled.])
+ ], [
+ AC_MSG_ERROR([zstd >= 1.4.0 was not found under $with_zstd])
+ ])
])
+
+AC_SUBST([ZSTD_CFLAGS])
+AC_SUBST([ZSTD_LIBS])
])
diff --git a/gas/configure b/gas/configure
index 8afaf2729ed..d971e0c52a5 100755
--- a/gas/configure
+++ b/gas/configure
@@ -1531,8 +1531,8 @@ 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[=PATH] support zstd compressed debug sections, optionally
+ using zstd installed under PATH (default=auto)
Some influential environment variables:
CC C compiler command
@@ -16150,7 +16150,11 @@ else
fi
-if test "$with_zstd" != no; then :
+case $with_zstd in #(
+ no) :
+ ;; #(
+ yes|auto) :
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5
@@ -16235,17 +16239,21 @@ fi
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
+ 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
+ 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
@@ -16258,8 +16266,72 @@ $as_echo "#define HAVE_ZSTD 1" >>confdefs.h
fi
+ ;; #(
+ *) :
+
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd >= 1.4.0 in $with_zstd" >&5
+$as_echo_n "checking for zstd >= 1.4.0 in $with_zstd... " >&6; }
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+
+int
+main ()
+{
+
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ have_zstd=yes
+else
+ have_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_zstd" >&5
+$as_echo "$have_zstd" >&6; }
+
+ if test "$have_zstd" = yes; then :
+
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+
+else
+
+ as_fn_error $? "zstd >= 1.4.0 was not found under $with_zstd" "$LINENO" 5
fi
+ ;; #(
+ *) :
+ ;;
+esac
+
+
+
# Support for VMS timestamps via cross compile
diff --git a/gdb/configure b/gdb/configure
index 810e9ed7a37..04f9e5d6209 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -1721,8 +1721,8 @@ 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[=PATH] support zstd compressed debug sections, optionally
+ using zstd installed under PATH (default=auto)
--with-iconv-bin=PATH specify where to find the iconv program
--with-system-readline use installed readline library
--with-jit-reader-dir=PATH
@@ -26723,7 +26723,11 @@ else
fi
-if test "$with_zstd" != no; then :
+case $with_zstd in #(
+ no) :
+ ;; #(
+ yes|auto) :
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5
@@ -26808,17 +26812,21 @@ fi
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
+ 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
+ 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
@@ -26831,8 +26839,72 @@ $as_echo "#define HAVE_ZSTD 1" >>confdefs.h
fi
+ ;; #(
+ *) :
+
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd >= 1.4.0 in $with_zstd" >&5
+$as_echo_n "checking for zstd >= 1.4.0 in $with_zstd... " >&6; }
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+
+int
+main ()
+{
+
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ have_zstd=yes
+else
+ have_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_zstd" >&5
+$as_echo "$have_zstd" >&6; }
+
+ if test "$have_zstd" = yes; then :
+
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+
+else
+
+ as_fn_error $? "zstd >= 1.4.0 was not found under $with_zstd" "$LINENO" 5
fi
+ ;; #(
+ *) :
+ ;;
+esac
+
+
+
diff --git a/gold/configure b/gold/configure
index a81a04f0531..fb21757c723 100755
--- a/gold/configure
+++ b/gold/configure
@@ -1555,8 +1555,8 @@ 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[=PATH] support zstd compressed debug sections, optionally
+ using zstd installed under PATH (default=auto)
Some influential environment variables:
CC C compiler command
@@ -9997,7 +9997,11 @@ else
fi
-if test "$with_zstd" != no; then :
+case $with_zstd in #(
+ no) :
+ ;; #(
+ yes|auto) :
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5
@@ -10082,17 +10086,21 @@ fi
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
+ 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
+ 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
@@ -10105,8 +10113,72 @@ $as_echo "#define HAVE_ZSTD 1" >>confdefs.h
fi
+ ;; #(
+ *) :
+
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd >= 1.4.0 in $with_zstd" >&5
+$as_echo_n "checking for zstd >= 1.4.0 in $with_zstd... " >&6; }
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+
+int
+main ()
+{
+
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ have_zstd=yes
+else
+ have_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_zstd" >&5
+$as_echo "$have_zstd" >&6; }
+
+ if test "$have_zstd" = yes; then :
+
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+
+else
+
+ as_fn_error $? "zstd >= 1.4.0 was not found under $with_zstd" "$LINENO" 5
fi
+ ;; #(
+ *) :
+ ;;
+esac
+
+
+
if test "$pkg_cv_ZSTD_LIBS" != ""; then
HAVE_ZSTD_TRUE=
diff --git a/ld/configure b/ld/configure
index 4d755384c41..10628a69b73 100755
--- a/ld/configure
+++ b/ld/configure
@@ -1598,8 +1598,8 @@ 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[=PATH] support zstd compressed debug sections, optionally
+ using zstd installed under PATH (default=auto)
Some influential environment variables:
CC C compiler command
@@ -19088,7 +19088,11 @@ else
fi
-if test "$with_zstd" != no; then :
+case $with_zstd in #(
+ no) :
+ ;; #(
+ yes|auto) :
+
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd >= 1.4.0" >&5
@@ -19173,17 +19177,21 @@ fi
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
+ 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
+ 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
@@ -19196,8 +19204,72 @@ $as_echo "#define HAVE_ZSTD 1" >>confdefs.h
fi
+ ;; #(
+ *) :
+
+ ZSTD_CFLAGS="-I$with_zstd/include"
+ ZSTD_LIBS="-L$with_zstd/lib -lzstd"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd >= 1.4.0 in $with_zstd" >&5
+$as_echo_n "checking for zstd >= 1.4.0 in $with_zstd... " >&6; }
+
+ zstd_save_CPPFLAGS=$CPPFLAGS
+ zstd_save_LIBS=$LIBS
+ CPPFLAGS="$CPPFLAGS $ZSTD_CFLAGS"
+ LIBS="$ZSTD_LIBS $LIBS"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10400
+# error zstd 1.4.0 or later is required
+#endif
+
+int
+main ()
+{
+
+ (void) ZSTD_compress(0, 0, 0, 0, 1);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ have_zstd=yes
+else
+ have_zstd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ CPPFLAGS=$zstd_save_CPPFLAGS
+ LIBS=$zstd_save_LIBS
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_zstd" >&5
+$as_echo "$have_zstd" >&6; }
+
+ if test "$have_zstd" = yes; then :
+
+ pkg_cv_ZSTD_CFLAGS=$ZSTD_CFLAGS
+ pkg_cv_ZSTD_LIBS=$ZSTD_LIBS
+
+$as_echo "#define HAVE_ZSTD 1" >>confdefs.h
+
+
+else
+
+ as_fn_error $? "zstd >= 1.4.0 was not found under $with_zstd" "$LINENO" 5
fi
+ ;; #(
+ *) :
+ ;;
+esac
+
+
+
# target-specific stuff:
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] configure: Support --with-zstd=PATH
2026-09-28 5:30 [PATCH v2] configure: Support --with-zstd=PATH Torbjörn SVENSSON
@ 2026-09-29 2:00 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2026-09-29 2:00 UTC (permalink / raw)
To: Torbjörn SVENSSON, binutils, gdb-patches
On 2026-09-28 01:30, Torbjörn SVENSSON wrote:
> Hi,
>
> V1 can be found here:
> https://sourceware.org/pipermail/binutils/2026-September/151687.html
>
> Changes since v1:
> - Added missed changes in binutils/Makefile.am and binutils/Makefile.in
> - Added support for dynamic version of zstd in path
>
>
> Ok for trunk?
>
> Kind regards,
> Torbjörn
>
> --
>
> Allow --with-zstd to specify an installation prefix. Use the headers
> and static library under that prefix, and reject it if it does not
> provide zstd 1.4.0 or newer.
>
> Regenerate the affected configure scripts.
>
> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Can you explain why using pkg-config wouldn't work for your use case?
In your other message, you mentioned that gcc also accepted a
--with-zstd=path, but it actually accepts more:
--with-zstd=PATH specify prefix directory for installed zstd library.
Equivalent to --with-zstd-include=PATH/include plus
--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
This is open-coded in gcc/configure.ac:
# 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])])
For consistency across the toolchain, would you consider moving this gcc
code to gcc/config/zstd.m4, and then sync gcc's zstd.m4 over to
binutils-gdb?
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-29 2:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 5:30 [PATCH v2] configure: Support --with-zstd=PATH Torbjörn SVENSSON
2026-09-29 2:00 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox