Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Sam James <sam@gentoo.org>, masahiroy@kernel.org
Cc: Kostadin Shishmanov <kostadinshishmanov@protonmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	arnd@arndb.de, linux-kbuild@vger.kernel.org
Subject: Re: Build failure with GCC 15 (-std=gnu23)
Date: Mon, 18 Nov 2024 21:47:24 -0700	[thread overview]
Message-ID: <20241119044724.GA2246422@thelio-3990X> (raw)
In-Reply-To: <87r077j1fa.fsf@gentoo.org>

On Tue, Nov 19, 2024 at 04:24:41AM +0000, Sam James wrote:
> This is the conclusion I just reached, although I'm struggling to figure
> out a nice place to put it without sprinkling it all over the place. I'm
> inclined to wait until kbuild folks weigh in so I don't do a lot of
> (trivial, but tedious) work that needs changing.

Sure. Masahiro, do you have any thoughts here? You can see the beginning
of the thread at [1].

I think the diff below would be a good first patch in a series that adds
it to every other place that needs it. As you noticed, it probably makes
sense to add it to most places that have CLANG_FLAGS, as that is a good
indicator that KBUILD_CFLAGS is not being used properly in those spots.

> As a hack, I've injected it into CLANG_FLAGS locally for now as it
> happens to appear in all the right places ;)

:) exactly why I am quite familiar with this issue...

[1]: https://lore.kernel.org/4OAhbllK7x4QJGpZjkYjtBYNLd_2whHx9oFiuZcGwtVR4hIzvduultkgfAIRZI3vQpZylu7Gl929HaYFRGeMEalWCpeMzCIIhLxxRhq4U-Y=@protonmail.com/

Cheers,
Nathan

diff --git a/Makefile b/Makefile
index 68a8faff2543..33cc6bcf39b5 100644
--- a/Makefile
+++ b/Makefile
@@ -416,6 +416,8 @@ export KCONFIG_CONFIG
 # SHELL used by kbuild
 CONFIG_SHELL := sh
 
+CSTD_FLAG := -std=gnu11
+
 HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
 HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
 HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
@@ -437,7 +439,7 @@ HOSTRUSTC = rustc
 HOSTPKG_CONFIG	= pkg-config
 
 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-			 -O2 -fomit-frame-pointer -std=gnu11
+			 -O2 -fomit-frame-pointer $(CSTD_FLAG)
 KBUILD_USERCFLAGS  := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
 KBUILD_USERLDFLAGS := $(USERLDFLAGS)
 
@@ -545,7 +547,7 @@ LINUXINCLUDE    := \
 KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 
 KBUILD_CFLAGS :=
-KBUILD_CFLAGS += -std=gnu11
+KBUILD_CFLAGS += $(CSTD_FLAG)
 KBUILD_CFLAGS += -fshort-wchar
 KBUILD_CFLAGS += -funsigned-char
 KBUILD_CFLAGS += -fno-common
@@ -589,7 +591,7 @@ export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AW
 export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
 export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
 export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
-export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
+export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS CSTD_FLAG
 
 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 25a2cb6317f3..5f9d5c38ed9e 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -65,7 +65,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                -fno-strict-aliasing -fno-common \
                -Werror-implicit-function-declaration \
                -Wno-format-security \
-               -std=gnu11
+               $(CSTD_FLAG)
 VDSO_CFLAGS  += -O2
 # Some useful compiler-dependent flags from top-level Makefile
 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5b773b34768d..d5c851dd0653 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -47,7 +47,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	:= $(CSTD_FLAG) -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)

  reply	other threads:[~2024-11-19  4:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4OAhbllK7x4QJGpZjkYjtBYNLd_2whHx9oFiuZcGwtVR4hIzvduultkgfAIRZI3vQpZylu7Gl929HaYFRGeMEalWCpeMzCIIhLxxRhq4U-Y=@protonmail.com>
2024-11-18 20:56 ` Build failure with GCC 15 (-std=gnu23) Nathan Chancellor
2024-11-19  2:57   ` Sam James
2024-11-19  4:15     ` Nathan Chancellor
2024-11-19  4:24       ` Sam James
2024-11-19  4:47         ` Nathan Chancellor [this message]
2024-11-19 18:28           ` Masahiro Yamada
2025-01-21  0:16             ` Kees Cook
2025-01-21 21:53               ` Nathan Chancellor
2025-01-21 22:11                 ` Sam James
2025-01-21 22:51                   ` Nathan Chancellor
2024-11-19  6:53       ` Arnd Bergmann
2024-11-19 14:18         ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241119044724.GA2246422@thelio-3990X \
    --to=nathan@kernel.org \
    --cc=arnd@arndb.de \
    --cc=kostadinshishmanov@protonmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=sam@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox