[PATCH] Fix libiberty.h inclusion on non-glibc hosts tree-wide

Nick Alcock nix@esperi.org.uk
Wed Nov 18 11:50:35 GMT 2026


On 18 Nov 2026, Iain Sandoe spake thusly:

> @sam, @pietro … any ideas most welcome.
>
>> On 18 Nov 2026, at 12:24, Jan Beulich <jbeulich@suse.com> wrote:
>> 
>> On 18.11.2026 01:49, Nick Alcock wrote:
>>> In 2025, Iain Sandoe added memrchr support to libiberty.h. This requires
>>> a new AC_CHECK_FUNCS of memrchr in every project that transitively
>>> includes it, or builds on non-glibc, non-Linux hosts will fail (observed
>>> on FreeBSD 15).
>
> In a way, it’s a nit surprising to find a *BSD having an issue (since it was a
> BSD derivative that prompted adding this)…but that’s life :)

I'm only surprised it took so long to uncover. Surely I can't be the
only person testing on FreeBSD...

>>> Iain Sandoe Cc:ed: Iain, if you disagree with my rather nasty approach
>>> here, I'd be interested in anything better. (The need to use %top in
>>> binutils/arlex.l is slightly worrying.  It's not in POSIX, but
>>> we need something like it or we can't include config.h before the
>>> system headers it must precede.  (Including config.h in libiberty.h
>>> won't work for the same reason.)
>> 
>> What does this mean compatibility-wise? I.e. when did relevant tools (no
>> idea which one it would be on the BSDs) start supporting %top?
>
> I have no better idea - unless there’s a way to down-scope the addition to
> GCC-local.

Or at least move the prototype there, or put it behind some sort of
guard (it's a shame there isn't a CHECKED_* to go with HAVE_* for things
like this, so you could skip the prototype unless the configure check
was done: if it wasn't done, odds are that subproject won't call the
function anyway.)


More information about the Binutils mailing list