Bug 2338348 - kernel failed to build with GCC 15: C23 bool/true/false keywords
Summary: kernel failed to build with GCC 15: C23 bool/true/false keywords
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: gcc-15-mass-prebuild
TreeView+ depends on / blocked
 
Reported: 2025-01-15 21:11 UTC by Dave Malcolm
Modified: 2026-07-24 14:54 UTC (History)
18 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Dave Malcolm 2025-01-15 21:11:35 UTC
I'm experimentally rebuilding rawhide with the not-yet-released GCC 15 to see if anything breaks, and to help write the porting guide.  See https://fedoraproject.org/wiki/F42-gcc-15-mass-prebuild

My test build with GCC 15 failed:
https://copr.fedorainfracloud.org/coprs/dmalcolm/gcc-15-smoketest-3.failed/build/8476572/

Looking at the failure logs e.g.
https://download.copr.fedorainfracloud.org/results/dmalcolm/gcc-15-smoketest-3.failed/fedora-rawhide-x86_64/08476572-kernel/builder-live.log.gz

I see:
In file included from ./include/uapi/linux/posix_types.h:5,
                 from ./include/uapi/linux/types.h:14,
                 from ./include/linux/types.h:6,
                 from ./include/linux/kasan-checks.h:5,
                 from ./include/asm-generic/rwonce.h:26,
                 from ./arch/x86/include/generated/asm/rwonce.h:1,
                 from ./include/linux/compiler.h:324,
                 from ./include/linux/build_bug.h:5,
                 from ./include/linux/init.h:5,
                 from ./include/linux/efi.h:15,
                 from drivers/firmware/efi/libstub/efi-stub-helper.c:12:
./include/linux/stddef.h:11:9: error: expected identifier before ‘false’
   11 |         false   = 0,
      |         ^~~~~
./include/linux/types.h:35:33: error: two or more data types in declaration specifiers
   35 | typedef _Bool                   bool;
      |                                 ^~~~
./include/linux/types.h:35:1: warning: useless type name in empty declaration
   35 | typedef _Bool                   bool;
      | ^~~~~~~

This is probably due to GCC 15 now defaulting to -std=gnu23, whereas GCC 14 defaulted to -std=gnu17, and "bool" is a reserved word in C23.  The code should ideally be ported to support C23 (but it could probably be worked around by manually adding -std=gnu17 to the C build flags)


Reproducible: Always

Comment 1 Dave Malcolm 2025-01-15 21:20:46 UTC
aarch64 build:
https://download.copr.fedorainfracloud.org/results/dmalcolm/gcc-15-smoketest-3.failed/fedora-rawhide-aarch64/08476572-kernel/builder-live.log.gz

failed with:

drivers/gpu/drm/panthor/panthor_fw.c: In function ‘panthor_fw_read_build_info’:
drivers/gpu/drm/panthor/panthor_fw.c:651:53: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
  651 |         const char git_sha_header[sizeof(header)] = "git_sha: ";
      |                                                     ^~~~~~~~~~~

Comment 2 Dave Malcolm 2025-01-15 21:23:53 UTC
Build on ppc64le succeeded:
https://download.copr.fedorainfracloud.org/results/dmalcolm/gcc-15-smoketest-3.failed/fedora-rawhide-ppc64le/08476572-kernel/builder-live.log.gz

Builds on x86_64 and s390x failed with "bool" keyword issues; x86_64 as per comment #0; s390x failing with:
In file included from ./include/uapi/linux/posix_types.h:5,
                 from ./include/uapi/linux/types.h:14,
                 from ./include/linux/types.h:6,
                 from ./include/linux/kasan-checks.h:5,
                 from ./include/asm-generic/rwonce.h:26,
                 from ./arch/s390/include/asm/rwonce.h:29,
                 from ./include/linux/compiler.h:324,
                 from ./include/linux/export.h:5,
                 from ./include/linux/linkage.h:7,
                 from ./include/linux/vmcore_info.h:5,
                 from ./include/linux/kexec.h:18,
                 from arch/s390/purgatory/purgatory.c:10:
./include/linux/stddef.h:11:9: error: expected identifier before ‘false’
   11 |         false   = 0,
      |         ^~~~~
./include/linux/types.h:35:33: error: two or more data types in declaration specifiers
   35 | typedef _Bool                   bool;
      |                                 ^~~~
./include/linux/types.h:35:1: warning: useless type name in empty declaration
   35 | typedef _Bool                   bool;
      | ^~~~~~~
https://download.copr.fedorainfracloud.org/results/dmalcolm/gcc-15-smoketest-3.failed/fedora-rawhide-s390x/08476572-kernel/builder-live.log.gz

Comment 3 Dave Malcolm 2025-01-15 21:25:09 UTC
FWIW I've updated the error message in more recent builds of GCC; see: https://gcc.gnu.org/gcc-15/porting_to.html#c23-new-keywords

Comment 4 Dave Malcolm 2025-02-11 17:34:26 UTC
Looks like this was addressed in https://src.fedoraproject.org/rpms/kernel/c/39f6da9eabe9fa880a8b720231eb3010e99e4f51 which has:

+KBUILD_CFLAGS += -std=gnu11

in arch/x86/boot/compressed/Makefile and a bunch of other changes that seem to be C23 related.

If so, presumably this can be closed out.

Comment 5 Jakub Jelinek 2025-02-11 17:42:36 UTC
That part is hopefully fixed, I've seen flying tons of patches about that.

But your comment has also
drivers/gpu/drm/panthor/panthor_fw.c: In function ‘panthor_fw_read_build_info’:
drivers/gpu/drm/panthor/panthor_fw.c:651:53: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
  651 |         const char git_sha_header[sizeof(header)] = "git_sha: ";
      |                                                     ^~~~~~~~~~~
part, that is a semi-new warning and dunno if kernel has been tweaked for that.
There is a possibility the warning will change, see e.g.
https://gcc.gnu.org/pipermail/gcc-patches/2024-December/thread.html#671714
https://gcc.gnu.org/pipermail/gcc-patches/2025-January/672738.html
https://gcc.gnu.org/pipermail/gcc-patches/2025-February/thread.html#675137
but it hasn't happened yet.

Comment 6 Justin M. Forbes 2025-02-12 20:00:45 UTC
We are building now, and have been for a bit. Of the 8 patches that were required to build after the toolchain update, 6 are now upstream.

https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3611/diffs?commit_id=da91c927eb1d424bd82d8023d4ce13ddae83289b Is the patch which deals with disabling -Werror=unterminated-string-initialization and I don't know if it will and upstream or not.

Comment 7 Charles Haithcock 2026-07-24 14:54:17 UTC
This report has not received an update in over 90 days. If this issue is still relevant to you, please do not hesitate to update this report with any relevant details on recent investigative steps or changes and we will absolutely work to understand how to best move forward. Otherwise, this bug report will need to be closed in 30 days. No worries, however; should you need still assistance after the report is closed, please do not hesitate to create a new bug report referencing this report and with any new details on the matter. 

NOTE: This is an automated mass update.


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