Recent fixes have been backported to < v5.18 to fix build issues with
GCC 5.15. They all force -std=gnu11 in the CFLAGS, "because [the kernel]
requests the gnu11 standard via '-std=' in the main Makefile".
This is true for >= 5.18 versions, but not before. This switch to
-std=gnu11 has been done in commit e8c07082a810 ("Kbuild: move to
-std=gnu11").
For a question of uniformity, force -std=gnu89, similar to what is done
in the main Makefile.
Note: the fixes tags below refers to upstream commits, but this fix is
only for kernels not having commit e8c07082a810 ("Kbuild: move to
-std=gnu11").
Fixes: 7cbb015e2d3d ("parisc: fix building with gcc-15")
Fixes: 3b8b80e99376 ("s390: Add '-std=gnu11' to decompressor and purgatory CFLAGS")
Fixes: b3bee1e7c3f2 ("x86/boot: Compile boot code with -std=gnu11 too")
Fixes: ee2ab467bddf ("x86/boot: Use '-std=gnu11' to fix build with GCC 15")
Fixes: 8ba14d9f490a ("efi: libstub: Use '-std=gnu11' to fix build with GCC 15")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Note:
  An alternative is to backport commit e8c07082a810 ("Kbuild: move to
  -std=gnu11"), but I guess we might not want to do that for stable, as
  it might introduce new warnings.
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 arch/parisc/boot/compressed/Makefile  | 2 +-
 arch/s390/Makefile                    | 2 +-
 arch/s390/purgatory/Makefile          | 2 +-
 arch/x86/Makefile                     | 2 +-
 arch/x86/boot/compressed/Makefile     | 2 +-
 drivers/firmware/efi/libstub/Makefile | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/parisc/boot/compressed/Makefile b/arch/parisc/boot/compressed/Makefile
index 839a13a59f53..3eba999a2eb7 100644
--- a/arch/parisc/boot/compressed/Makefile
+++ b/arch/parisc/boot/compressed/Makefile
@@ -22,7 +22,7 @@ KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs -Os
 ifndef CONFIG_64BIT
 KBUILD_CFLAGS += -mfast-indirect-calls
 endif
-KBUILD_CFLAGS += -std=gnu11
+KBUILD_CFLAGS += -std=gnu89
 
 OBJECTS += $(obj)/head.o $(obj)/real2.o $(obj)/firmware.o $(obj)/misc.o $(obj)/piggy.o
 
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index c8071eb82e2e..40265863ed36 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -23,7 +23,7 @@ endif
 aflags_dwarf	:= -Wa,-gdwarf-2
 KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
 KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
-KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -std=gnu11
+KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -std=gnu89
 KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
 KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
 KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
index 677cbb654024..414ba87e038b 100644
--- a/arch/s390/purgatory/Makefile
+++ b/arch/s390/purgatory/Makefile
@@ -21,7 +21,7 @@ UBSAN_SANITIZE := n
 KASAN_SANITIZE := n
 KCSAN_SANITIZE := n
 
-KBUILD_CFLAGS := -std=gnu11 -fno-strict-aliasing -Wall -Wstrict-prototypes
+KBUILD_CFLAGS := -std=gnu89 -fno-strict-aliasing -Wall -Wstrict-prototypes
 KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
 KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
 KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float -fno-common
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index d5ee0b920dc0..16267e85c5ad 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -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	:= -std=gnu11 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
+REALMODE_CFLAGS	:= -std=gnu89 -m16 -g -Os -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
 		   -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)
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index f82b2cb24360..f54fa1579dcd 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -33,7 +33,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
 # avoid errors with '-march=i386', and future flags may depend on the target to
 # be valid.
 KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS)
-KBUILD_CFLAGS += -std=gnu11
+KBUILD_CFLAGS += -std=gnu89
 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
 KBUILD_CFLAGS += -Wundef
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index f1a4f0154540..1195c9fb84de 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -7,7 +7,7 @@
 #
 cflags-$(CONFIG_X86_32)		:= -march=i386
 cflags-$(CONFIG_X86_64)		:= -mcmodel=small
-cflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ -std=gnu11 \
+cflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ -std=gnu89 \
 				   -fPIC -fno-strict-aliasing -mno-red-zone \
 				   -mno-mmx -mno-sse -fshort-wchar \
 				   -Wno-pointer-sign \
-- 
2.51.0On Fri, Oct 17, 2025 at 06:24:01PM +0200, Matthieu Baerts (NGI0) wrote:
> Recent fixes have been backported to < v5.18 to fix build issues with
> GCC 5.15. They all force -std=gnu11 in the CFLAGS, "because [the kernel]
> requests the gnu11 standard via '-std=' in the main Makefile".
> 
> This is true for >= 5.18 versions, but not before. This switch to
> -std=gnu11 has been done in commit e8c07082a810 ("Kbuild: move to
> -std=gnu11").
> 
> For a question of uniformity, force -std=gnu89, similar to what is done
> in the main Makefile.
> 
> Note: the fixes tags below refers to upstream commits, but this fix is
> only for kernels not having commit e8c07082a810 ("Kbuild: move to
> -std=gnu11").
> 
> Fixes: 7cbb015e2d3d ("parisc: fix building with gcc-15")
> Fixes: 3b8b80e99376 ("s390: Add '-std=gnu11' to decompressor and purgatory CFLAGS")
> Fixes: b3bee1e7c3f2 ("x86/boot: Compile boot code with -std=gnu11 too")
> Fixes: ee2ab467bddf ("x86/boot: Use '-std=gnu11' to fix build with GCC 15")
> Fixes: 8ba14d9f490a ("efi: libstub: Use '-std=gnu11' to fix build with GCC 15")
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> Note:
>   An alternative is to backport commit e8c07082a810 ("Kbuild: move to
>   -std=gnu11"), but I guess we might not want to do that for stable, as
>   it might introduce new warnings.
I would rather do that, as that would allow us to make things align up
and be easier to support over the next two years that this kernel needs
to be alive for.  How much work would that entail?
thanks,
greg k-h
                
            Hi Greg,
On 20/10/2025 15:30, Greg Kroah-Hartman wrote:
> On Fri, Oct 17, 2025 at 06:24:01PM +0200, Matthieu Baerts (NGI0) wrote:
>> Recent fixes have been backported to < v5.18 to fix build issues with
>> GCC 5.15. They all force -std=gnu11 in the CFLAGS, "because [the kernel]
>> requests the gnu11 standard via '-std=' in the main Makefile".
>>
>> This is true for >= 5.18 versions, but not before. This switch to
>> -std=gnu11 has been done in commit e8c07082a810 ("Kbuild: move to
>> -std=gnu11").
>>
>> For a question of uniformity, force -std=gnu89, similar to what is done
>> in the main Makefile.
>>
>> Note: the fixes tags below refers to upstream commits, but this fix is
>> only for kernels not having commit e8c07082a810 ("Kbuild: move to
>> -std=gnu11").
>>
>> Fixes: 7cbb015e2d3d ("parisc: fix building with gcc-15")
>> Fixes: 3b8b80e99376 ("s390: Add '-std=gnu11' to decompressor and purgatory CFLAGS")
>> Fixes: b3bee1e7c3f2 ("x86/boot: Compile boot code with -std=gnu11 too")
>> Fixes: ee2ab467bddf ("x86/boot: Use '-std=gnu11' to fix build with GCC 15")
>> Fixes: 8ba14d9f490a ("efi: libstub: Use '-std=gnu11' to fix build with GCC 15")
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
>> ---
>> Note:
>>   An alternative is to backport commit e8c07082a810 ("Kbuild: move to
>>   -std=gnu11"), but I guess we might not want to do that for stable, as
>>   it might introduce new warnings.
> 
> I would rather do that, as that would allow us to make things align up
> and be easier to support over the next two years that this kernel needs
> to be alive for.  How much work would that entail?
Good question. I'm not an expert in this area, but I just did a quick
test: I backported commit e8c07082a810 ("Kbuild: move to -std=gnu11")
and its parent commit 4d94f910e79a ("Kbuild: use
-Wdeclaration-after-statement"). A build with 'make allyesconfig' and
GCC 5.15 looks OK to me, no warnings.
But when looking a bit around, I noticed these patches have already been
suggested to be backported to v5.15 in 2023, but they got removed --
except the doc update, see patch 3/3 -- because they were causing build
issues with GCC 8 and 12, see:
 https://lore.kernel.org/a2fbbaa2-51d2-4a8c-b032-5331e72cd116@linaro.org
I didn't try to reproduce the issues, but maybe we can re-add them to
the v5.15 queue, and ask the CIs to test that?
Note that even if we do that, the first patch will still be needed to
have GCC 15 support in v5.15.
Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
                
            © 2016 - 2025 Red Hat, Inc.