[2.46 PATCHES] Fix build under glibc 2.43

H.J. Lu hjl.tools@gmail.com
Mon May 4 21:59:26 GMT 2026


<features.h> from glibc 2.43 has

/* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
#ifdef _GNU_SOURCE
# undef  _ISOC95_SOURCE
# define _ISOC95_SOURCE 1
# undef  _ISOC99_SOURCE
# define _ISOC99_SOURCE 1
# undef  _ISOC11_SOURCE
# define _ISOC11_SOURCE 1
# undef  _ISOC23_SOURCE
# define _ISOC23_SOURCE 1

which triggers

/export/gnu/import/git/gitlab/x86-binutils-release/gprof/source.c: In
function ‘annotate_source’:
/export/gnu/import/git/gitlab/x86-binutils-release/gprof/source.c:126:21:
error: assignment discards ‘const’ qualifier from pointer target type
[-Werror=discarded-qualifiers]
  126 |           name_only = strrchr (sf->name, '/');
      |                     ^
cc1: all warnings being treated as errors

since <string.h> has

# if __GLIBC_USE (ISOC23) && defined __glibc_const_generic && !defined _LIBC
#  define strrchr(S, C)                                         \
  __glibc_const_generic (S, const char *, strrchr (S, C))
# endif
#endif

Backport the following patches from master branch:

bfbfc5338fe Fix discarded-qualifiers problems in ldlang.c
f4e1e879c3b ld: Fix calls to strchr that discard or use wrong const qualifiers
23cffbed18e binutils: fix C23 -Wdiscarded-qualifiers errors
742891031fb Fix the strrchr error for DOS based filesystem
2c40bfc752b gprof: Fix strchr discarded qualifier call

to fix the binutils 2.46 build under glibc 2.43.

Any comments?

H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fix-the-strrchr-error-for-DOS-based-filesystem.patch
Type: text/x-patch
Size: 2385 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260505/c72c6dfc/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-ld-Fix-calls-to-strchr-that-discard-or-use-wrong-con.patch
Type: text/x-patch
Size: 5874 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260505/c72c6dfc/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Fix-discarded-qualifiers-problems-in-ldlang.c.patch
Type: text/x-patch
Size: 3025 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260505/c72c6dfc/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gprof-Fix-strchr-discarded-qualifier-call.patch
Type: text/x-patch
Size: 973 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260505/c72c6dfc/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-binutils-fix-C23-Wdiscarded-qualifiers-errors.patch
Type: text/x-patch
Size: 3779 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260505/c72c6dfc/attachment-0009.bin>


More information about the Binutils mailing list