[PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide
Tom Tromey
tom@tromey.com
Thu Nov 19 20:35:39 GMT 2026
>>>>> "Nick" == Nick Alcock <nix@esperi.org.uk> writes:
Nick> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
Nick> a new AC_CHECK_FUNCS of memrchr in every project that transitively
Nick> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
Nick> on FreeBSD 15).
Not really your issue but this would all be a lot simpler if libiberty
made a config.h-style header with its own namespaced names, and then
included this and checked these names from the include/ headers.
That way changes to libiberty wouldn't have to propagate through all the
possible users.
gdb kinds of works around this deficiency with libiberty.m4 but really
that's a failure of encapsulation.
Nick> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
Nick> here, I'd be interested in anything better. (The need to use %top in
Nick> binutils/arlex.l is slightly worrying. It's not in POSIX, but
Nick> we need something like it or we can't include config.h before the
Nick> system headers it must precede. (Including config.h in libiberty.h
Nick> won't work for the same reason.)
In gdb we switched to pre-including the "defs.h" file from the compiler
command line, which I guess avoids stuff like this. Though at the same
time I don't think we had this precise problem so I wonder what's up
with that.
The gdb and sim bits here are fine but it sounds like this patch is
going to be handled a different way in libiberty?
thanks,
Tom
More information about the Binutils
mailing list