binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
binutils

gnulib: Force HAVE_FNMATCH=1 to prioritize gnulib's fnmatch

Ensures gnulib's fnmatch function is used over libiberty's by setting HAVE_FNMATCH=1.

This commit forces the HAVE_FNMATCH=1 configuration option within gnulib’s build process. This change ensures that gnulib’s implementation of fnmatch is consistently used, prioritizing it over the one provided by libiberty. This resolves issues where link order might otherwise cause libiberty’s version to be chosen, leading to unexpected behavior in file matching tests, as observed in msys2-ucrt64 and macOS environments.

In Details

This change addresses a link-order dependency issue within gnulib's build when used by binutils (specifically affecting tests in maint selftest). On certain platforms, the build system previously failed to detect the availability of a system fnmatch function correctly, leading gnulib to not use its own rpl_fnmatch wrapper. This resulted in libiberty's fnmatch being linked in by default due to its common placement in CLIBS. The fix overrides this by explicitly setting ac_cv_func_fnmatch=yes in gnulib's configure script, forcing gnulib to recognize fnmatch as available and thus…

For Context
gnulib
A GNU project providing portable library routines for use in GNU software, aiming to reduce code duplication and improve portability.
fnmatch
A function that compares a filename string against a pattern string, supporting shell-style wildcards. It is commonly used for file matching operations.
libiberty
A collection of library routines originally developed for GCC but now often used independently by various GNU projects. It includes utility functions like fnmatch.
HAVE_FNMATCH
A preprocessor macro used in build systems to indicate whether the fnmatch function is available and should be used.
Link order
The sequence in which object files and libraries are specified to the linker. The linker resolves symbols based on this order, potentially leading to one definition overriding another.
Filed Under: binutilsgnulibfnmatchbuild system