From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gnulib] Force HAVE_FNMATCH=1
Date: Mon, 16 Nov 2026 14:49:31 +0100 [thread overview]
Message-ID: <20261116134931.2120338-1-tdevries@suse.de> (raw)
I ran "maint selftest" on msys2-ucrt64, and ran into the same failure in
skip_gfile_matching as fixed for macOS in commit 2e7f60647f1 ("[gdb/build] Use
gnulib fnmatch"): libiberty's fnmatch is used instead of gnulib's version.
This is not a regression, the test failed before the commit as well. But the
reason it fails is slightly different.
Before the commit, libiberty's fnmatch.h was included, and libiberty's fnmatch
was used.
After the commit, gnulib's fnmatch.h is used, but still libiberty's fnmatch is
used.
This happens because gnulib doesn't use the rpl_ prefix, which would have
forced the use of gnulib regardless of link order.
Without the rpl_ prefix, it comes down to link order, and libiberty wins out
there.
The reason why gnulib doesn't use the rpl_ prefix, is that while it's being
built, no system fnmatch is detected that needs overriding.
I tried out if I could fix this by changing the link order. I managed to get
this working by moving LIBSUPPORT and LIBGNU to the start of CLIBS:
...
CLIBS = $(LIBSUPPORT) $(LIBGNU) ...
...
I like this fix because it clearly gives precedence to gnulib. But changing
linking order is notoriously fragile, so instead I'm proposing a minimal fix.
Fix this by making the gnulib build aware of libiberty's fnmatch, by
initializing autoconf variable ac_cv_func_fnmatch to yes.
Tested on x86_64-linux, aarch64-macos and msys2-ucrt64 by rebuilding and
running the selftests.
---
gnulib/configure | 30 ++++++++++++++++++------------
gnulib/configure.ac | 6 ++++++
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/gnulib/configure b/gnulib/configure
index de2f5c4cec1..caf934607de 100755
--- a/gnulib/configure
+++ b/gnulib/configure
@@ -4105,6 +4105,12 @@ fi
+# Gnulib is built in isolation, but in practice it's always used in
+# combination with libiberty, which does contain an fnmatch. Let gnulib know
+# this. This ensures that if gnulib provides a copy, it will name it
+# rpl_fnmatch, avoiding name clashes with the version from libiberty.
+: ${ac_cv_func_fnmatch=yes}
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -13811,8 +13817,8 @@ rm -f core conftest.err conftest.$ac_objext \
LIBS=$save_LIBS
test $gl_pthread_api = yes && break
done
- echo "$as_me:13814: gl_pthread_api=$gl_pthread_api" >&5
- echo "$as_me:13815: LIBPTHREAD=$LIBPTHREAD" >&5
+ echo "$as_me:13820: gl_pthread_api=$gl_pthread_api" >&5
+ echo "$as_me:13821: LIBPTHREAD=$LIBPTHREAD" >&5
gl_pthread_in_glibc=no
# On Linux with glibc >= 2.34, libc contains the fully functional
@@ -13837,7 +13843,7 @@ rm -f conftest*
;;
esac
- echo "$as_me:13840: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5
+ echo "$as_me:13846: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
# since it is defined as a macro on OSF/1.)
@@ -13991,7 +13997,7 @@ fi
fi
fi
- echo "$as_me:13994: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5
+ echo "$as_me:14000: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5
$as_echo_n "checking whether POSIX threads API is available... " >&6; }
@@ -17068,8 +17074,8 @@ rm -f core conftest.err conftest.$ac_objext \
LIBS=$save_LIBS
test $gl_pthread_api = yes && break
done
- echo "$as_me:17071: gl_pthread_api=$gl_pthread_api" >&5
- echo "$as_me:17072: LIBPTHREAD=$LIBPTHREAD" >&5
+ echo "$as_me:17077: gl_pthread_api=$gl_pthread_api" >&5
+ echo "$as_me:17078: LIBPTHREAD=$LIBPTHREAD" >&5
gl_pthread_in_glibc=no
# On Linux with glibc >= 2.34, libc contains the fully functional
@@ -17094,7 +17100,7 @@ rm -f conftest*
;;
esac
- echo "$as_me:17097: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5
+ echo "$as_me:17103: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
# since it is defined as a macro on OSF/1.)
@@ -17248,7 +17254,7 @@ fi
fi
fi
- echo "$as_me:17251: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5
+ echo "$as_me:17257: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5
$as_echo_n "checking whether POSIX threads API is available... " >&6; }
@@ -17474,8 +17480,8 @@ rm -f core conftest.err conftest.$ac_objext \
LIBS=$save_LIBS
test $gl_pthread_api = yes && break
done
- echo "$as_me:17477: gl_pthread_api=$gl_pthread_api" >&5
- echo "$as_me:17478: LIBPTHREAD=$LIBPTHREAD" >&5
+ echo "$as_me:17483: gl_pthread_api=$gl_pthread_api" >&5
+ echo "$as_me:17484: LIBPTHREAD=$LIBPTHREAD" >&5
gl_pthread_in_glibc=no
# On Linux with glibc >= 2.34, libc contains the fully functional
@@ -17500,7 +17506,7 @@ rm -f conftest*
;;
esac
- echo "$as_me:17503: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5
+ echo "$as_me:17509: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&5
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
# since it is defined as a macro on OSF/1.)
@@ -17654,7 +17660,7 @@ fi
fi
fi
- echo "$as_me:17657: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5
+ echo "$as_me:17663: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads API is available" >&5
$as_echo_n "checking whether POSIX threads API is available... " >&6; }
diff --git a/gnulib/configure.ac b/gnulib/configure.ac
index 0675e0c850a..dceac194e5e 100644
--- a/gnulib/configure.ac
+++ b/gnulib/configure.ac
@@ -25,6 +25,12 @@ AC_CONFIG_MACRO_DIRS([import/m4])
AC_CONFIG_MACRO_DIRS([../config])
AM_MAINTAINER_MODE
+# Gnulib is built in isolation, but in practice it's always used in
+# combination with libiberty, which does contain an fnmatch. Let gnulib know
+# this. This ensures that if gnulib provides a copy, it will name it
+# rpl_fnmatch, avoiding name clashes with the version from libiberty.
+: ${ac_cv_func_fnmatch=yes}
+
AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
# Needs to run before gl_EARLY so it can override AC_SYS_LARGEFILE included
base-commit: 5678a7bfceb3a6ea18bcde1ae68f7e96c43c998b
--
2.51.0
next reply other threads:[~2026-11-16 13:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 13:49 Tom de Vries [this message]
2026-11-22 11:35 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116134931.2120338-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox