Bug 2417601 - glibc-2.42.9000-13.fc44: -Werror=discarded-qualifiers breaks libbpf build (tools/bpf/resolve_btfids)
Summary: glibc-2.42.9000-13.fc44: -Werror=discarded-qualifiers breaks libbpf build (to...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Carlos O'Donell
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-11-27 18:51 UTC by Mikhail
Modified: 2025-11-28 00:57 UTC (History)
14 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-11-27 20:49:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
good - build.log (253.36 KB, text/plain)
2025-11-27 18:51 UTC, Mikhail
no flags Details
bad - build.log (52.44 KB, text/plain)
2025-11-27 18:51 UTC, Mikhail
no flags Details

Description Mikhail 2025-11-27 18:51:23 UTC
Created attachment 2116411 [details]
good - build.log

The kernel fails to build with glibc-2.42.9000-13.fc44:

  libbpf.c:8250:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  libbpf.c:11579:31: error: ...
  libbpf.c:12167:35: error: ...

Regression window:
  glibc-2.42.9000-12.fc44 → builds fine (good-build.log attached)
  glibc-2.42.9000-13.fc44 → fails (bad-build.log attached)

Reproduction:
  make clean
  make -j32 bzImage

The new warning was added as part of hardening changes in glibc-2.42.9000-13.
These assignments from strstr()/strchr() return values to non-const pointers
are intentional and safe in libbpf.

Possible quick fixes:
  • Disable -Werror=discarded-qualifiers in glibc spec for rawhide
  • Add HOSTCFLAGS_libbpf.o += -Wno-error=discarded-qualifiers in kernel Makefile
  • Fix libbpf upstream (long-term)

This blocks all kernel builds on rawhide at the moment.

Comment 1 Mikhail 2025-11-27 18:51:48 UTC
Created attachment 2116412 [details]
bad - build.log

Comment 2 Florian Weimer 2025-11-27 20:49:46 UTC
Sorry, the build log is not very informative because it does not show the actual compiler flags being used. Furthermore, the -O flag is not specified on the make invocation, so the compiler diagnostics are reported at random places in the build log:

  CC      /home/mikhail/packaging-work/git/linux/tools/bpf/resolve_btfids/libbpf/staticobjs/ringbuf.o
  HDRINST usr/include/linux/affs_hardblocks.h
  HDRINST usr/include/linux/agpgart.h
libbpf.c: In function ‘kallsyms_cb’:
libbpf.c:8250:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
 8250 |         res = strstr(sym_name, ".llvm.");
      |             ^
  HDRINST usr/include/linux/aio_abi.h
  CC      /home/mikhail/packaging-work/git/linux/tools/bpf/resolve_btfids/libbpf/staticobjs/strset.o
libbpf.c: In function ‘avail_kallsyms_cb’:
libbpf.c:11579:31: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
11579 |                 if (!(sym_sfx = strstr(sym_name, ".llvm.")))
      |                               ^
  HDRINST usr/include/linux/amt.h
libbpf.c: In function ‘resolve_full_path’:
libbpf.c:12167:35: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
12167 |                         next_path = strchr(s, ':');
      |                                   ^
  HDRINST usr/include/linux/am437x-vpfe.h
  AR      /home/mikhail/packaging-work/git/linux/tools/objtool/libsubcmd/libsubcmd.a

If you use the GCC 15 default, you build with -std=gnu23, which means C23. Based on the errors above, your code does not follow the C23 standard. That the code was previously accepted without a diagnostic by GCC/glibc was a toolchain bug.

I acknowledge that C23 does not meet developer expectations regarding source level compatibility. I am going to start a discussion with the GCC and GNU C Library developers on this topic.

Comment 3 Florian Weimer 2025-11-27 20:56:37 UTC
Upstream discussion:

Refining _DEFAULT_SOURCE and _GNU_SOURCE
<https://inbox.sourceware.org/libc-alpha/lhuo6on8aav.fsf@oldenburg.str.redhat.com/>


Note You need to log in before you can comment on or make changes to this bug.