[PATCH] Cygwin: Only compute BFD_LIBS if building dumper

Jon Turney <[email protected]> Fri, 29 May 2026 14:01:40 +0100
Newsgroups gmane.os.cygwin.patches
Message-ID <[email protected]>
Don't bother trying to determine the flags needed to link the BFD
library if we're not even building dumper.

(AC_NO_EXECUTABLES doesn't do what the name would simply suggest: It
silently checks if a trivial program can link, and turns itself off if
that suceeds.

Tests which rely on linking are only made to fail by AC_NO_EXECUTABLES
if that trivial link has failed (which OK, were probably going to fail
anyway, but now you get the error 'link tests are not allowed after
AC_NO_EXECUTABLES', which is perhaps slightly more informative when you
are cross-compiling with a bootstrap compiler).)

Anyhow, if we're using a compiler which can't link executables, these
instances of AC_CHECK_LIB will definitely fail.  But we can't possibly
build dumper in that situation, so we'll be configuring with
--disable-dumper, and doing those checks serves no purpose.
---
 winsup/configure.ac | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/winsup/configure.ac b/winsup/configure.ac
index ac96968e4..ad63cbf95 100644
--- a/winsup/configure.ac
+++ b/winsup/configure.ac
@@ -153,12 +153,14 @@ AC_ARG_ENABLE([dumper],
 
 AM_CONDITIONAL(BUILD_DUMPER, [test "x$build_dumper" = "xyes"])
 
-# libbfd.a doesn't have a pkgconfig file, so we guess what it's dependencies
-# are, based on what's present in the build environment
-BFD_LIBS="-lintl -liconv -liberty -lz"
-AC_CHECK_LIB([sframe], [sframe_decode], [BFD_LIBS="${BFD_LIBS} -lsframe"])
-AC_CHECK_LIB([zstd], [ZSTD_isError], [BFD_LIBS="${BFD_LIBS} -lzstd"])
-AC_SUBST([BFD_LIBS])
+if test "x$build_dumper" != "xno"; then
+  # libbfd.a doesn't have a pkgconfig file, so we guess what it's dependencies
+  # are, based on what's present in the build environment
+  BFD_LIBS="-lintl -liconv -liberty -lz"
+  AC_CHECK_LIB([sframe], [sframe_decode], [BFD_LIBS="${BFD_LIBS} -lsframe"])
+  AC_CHECK_LIB([zstd], [ZSTD_isError], [BFD_LIBS="${BFD_LIBS} -lzstd"])
+  AC_SUBST([BFD_LIBS])
+fi
 
 AC_CONFIG_FILES([
     Makefile
-- 
2.51.0