Fail to compile Linux kernel 5.14 with GCC15
Hello,
As mentioned in the title, I receive a compile error for arch/x86/realmode/rm/wakemain.c:./include/linux/stddef:11:9: error: cannot use keyword 'false' as enumeration constant
Note: 'false'is a keyword with' '-std=c23' onwards.
So I patched my buildroot linux/linux.mk to add:
ifeq ($(BR_TOOLCHAIN_GCC_AT_LEAST_15),y)LINUX_CFLAGS += -std=gnu17
endif
However the compiler error is still happening, any idea how to fix?
Best regards,
David.
Yahoo Mail: Search, organise, conquer
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hi David,
Quoted 11 lines · David Luca via buildroot
Hello,
As mentioned in the title, I receive a compile error forarch/x86/realmode/rm/wakemain.c:./include/linux/stddef:11:9: error: cannot use keyword 'false' as enumeration constant
Note: 'false'is a keyword with' '-std=c23' onwards.
So I patched my buildrootlinux/linux.mkto add:
ifeq ($(BR_TOOLCHAIN_GCC_AT_LEAST_15),y)LINUX_CFLAGS+= -std=gnu17
endif
However the compiler error is still happening, any idea how to fix?
Kernel 5.14 was not a LTS, you should consider updating your kernel. If not possible, you could probably backport fixes from 5.15, such as:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f28b14d235a810e4f6634832062b6e0ffc482b5a
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=518eadd15f7ecde6d301974388c6be03d5c57a0c
...
You can probably search relevant commits with:
git log -S std= linux-5.15.y
Quoted 2 lines
Best regards,
David.
Best regards,
Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello!
Quoted 9 lines · David Luca
Hello,
As mentioned in the title, I receive a compile error forarch/x86/realmode/rm/wakemain.c:./include/linux/stddef:11:9: error: cannot use keyword 'false' as enumeration constant
Note: 'false'is a keyword with' '-std=c23' onwards.
So I patched my buildrootlinux/linux.mkto add:
ifeq ($(BR_TOOLCHAIN_GCC_AT_LEAST_15),y)LINUX_CFLAGS+= -std=gnu17
endif
However the compiler error is still happening, any idea how to fix?
Linux 5.14 is supposed to be built with ‘-std=gnu89’. Its main Makefile provides this definition:
KBUILD_CFLAGS := -Wall -Wundef [...] -std=gnu89
The problem is that some of the sub-makefiles override the definition of KBUILD_CFLAGS and forget to add the language dialect option. This has been partially fixed in Linux commit b3bee1e7c3f2 ("x86/boot: Compile boot code with -std=gnu11 too"). The various definitions of this flag were eventually consolidated in ec4c28276c14 ("kbuild: Consolidate C dialect options"). Those two commits are way more recent than Linux 5.14, as they landed in 6.7 and 7.1 respectively.
The best solution is probably to follow Julien Olivain's advice and upgrade to a newer kernel. It that is not practical, downgrade to an older compiler. Otherwise you may try to fix the faulty makefiles by adding the language dialect option where needed. I gave this last option a try: dropping the attached patch in linux/5.14/ and using this defconfig:
BR2_x86_64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.14"
BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=yI could successfully build the kernel using the Bootlin toolchain “x86-64 glibc bleeding-edge 2025.08-1”, which is based on GCC 15.1.
Cheers,
Edgar Bonet
------------------------------------------------------------------ >8 -- From f582e779af5038aca4b79c05e438bc5edbfe143b Mon Sep 17 00:00:00 2001
From: Edgar Bonet <[email protected]>
Date: Fri, 13 Nov 2026 15:00:24 +0100
Subject: [PATCH] Specify the C standard in sub-makefiles too
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The main Makefile has the option ‘-std=gnu89’ in KBUILD_CFLAGS. However, this variable is overridden in some sub-makefiles, which leads to build failures with recent GCC versions. E.g.:
./include/linux/stddef.h:11:9:
error: cannot use keyword ‘false’ as enumeration constant
note: ‘false’ is a keyword with ‘-std=c23’ onwards
This backports and extends b3bee1e7c3f2 ("x86/boot: Compile boot code with -std=gnu11 too"), specifying the C standard used by Linux 5.14 instead of gnu11.
--- arch/x86/Makefile | 2 +- arch/x86/boot/compressed/Makefile | 2 +- drivers/firmware/efi/libstub/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/Makefile +1 -1
@@ -24,7 +24,7 @@ endif # How to compile the 16-bit code. Note we always compile for -march=i386; # that way we can complain to the user if the CPU is insufficient. -REALMODE_CFLAGS := -m16 -g -Os -DDISABLE_BRANCH_PROFILING \ +REALMODE_CFLAGS := -std=gnu89 -m16 -g -Os -DDISABLE_BRANCH_PROFILING \ -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
arch/x86/boot/compressed/Makefile +1 -1
@@ -28,7 +28,7 @@ KCOV_INSTRUMENT := n targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst -KBUILD_CFLAGS := -m$(BITS) -O2 +KBUILD_CFLAGS := -std=gnu89 -m$(BITS) -O2 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
drivers/firmware/efi/libstub/Makefile +1 -1
@@ -29,7 +29,7 @@ cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt -KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \ +KBUILD_CFLAGS := -std=gnu89 $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \ -include $(srctree)/include/linux/hidden.h \ -D__NO_FORTIFY \ -ffreestanding \
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot