From: Nathan Chancellor <nathan@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>, Nicolas Schier <nsc@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Helge Deller <deller@gmx.de>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Kees Cook <kees@kernel.org>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev,
linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-s390@vger.kernel.org, linux-efi@vger.kernel.org,
llvm@lists.linux.dev
Subject: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
Date: Mon, 23 Feb 2026 12:10:29 -0700 [thread overview]
Message-ID: <20260223-fms-anonymous-structs-v1-2-8ee406d3c36c@kernel.org> (raw)
In-Reply-To: <20260223-fms-anonymous-structs-v1-0-8ee406d3c36c@kernel.org>
Clang recently added '-fms-anonymous-structs' [1] to specifically enable
the Microsoft tagged anonymous structure / union extension, for which
the kernel added '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
enable -fms-extensions"). Switch to this more narrow option if it is
available, which would have helped avoid the issue addressed by
commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
'-fms-extensions'"). GCC has talked about adding a similar flag [2] as
well but potentially naming it differently.
Move the selection of the flag to Kconfig to make it easier to use
cc-option (as CC_FLAGS_DIALECT may be used in arch Makefiles, which may
be too early for cc-option in Kbuild) and customize based on compiler
flag names.
Link: https://github.com/llvm/llvm-project/commit/c391efe6fb67329d8e2fd231692cc6b0ea902956 [1]
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123623 [2]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Makefile | 2 +-
init/Kconfig | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 06ff3032a6bc..1d5c0ab9ed5c 100644
--- a/Makefile
+++ b/Makefile
@@ -791,7 +791,7 @@ endif
CC_FLAGS_DIALECT := -std=gnu11
# Allow including a tagged struct or union anonymously in another struct/union.
-CC_FLAGS_DIALECT += -fms-extensions
+CC_FLAGS_DIALECT += $(CONFIG_CC_MS_EXTENSIONS)
# Clang enables warnings about GNU and Microsoft extensions by default, disable
# them because this is expected with the above options.
ifdef CONFIG_CC_IS_CLANG
diff --git a/init/Kconfig b/init/Kconfig
index c25869cf59c1..c4282d049463 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -960,6 +960,11 @@ config CC_IMPLICIT_FALLTHROUGH
default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5)
default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough)
+config CC_MS_EXTENSIONS
+ string
+ default "-fms-anonymous-structs" if $(cc-option,-fms-anonymous-structs)
+ default "-fms-extensions"
+
# Currently, disable gcc-10+ array-bounds globally.
# It's still broken in gcc-13, so no upper bound yet.
config GCC10_NO_ARRAY_BOUNDS
--
2.53.0
next prev parent reply other threads:[~2026-02-23 19:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 19:10 [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available Nathan Chancellor
2026-02-23 19:10 ` [PATCH 1/2] kbuild: Consolidate C dialect options Nathan Chancellor
2026-02-27 16:36 ` Nicolas Schier
2026-02-23 19:10 ` Nathan Chancellor [this message]
2026-02-23 22:33 ` [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Kees Cook
2026-02-23 22:53 ` Nathan Chancellor
2026-02-23 23:02 ` Kees Cook
2026-02-24 20:55 ` Nathan Chancellor
2026-03-05 10:25 ` Nicolas Schier
2026-02-23 19:38 ` [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available Ard Biesheuvel
2026-02-23 21:13 ` Helge Deller
2026-03-05 23:43 ` H. Peter Anvin
2026-03-06 23:17 ` Nathan Chancellor
2026-03-06 23:31 ` H. Peter Anvin
2026-03-09 6:49 ` Nicolas Schier
2026-03-12 12:08 ` Nicolas Schier
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=20260223-fms-anonymous-structs-v1-2-8ee406d3c36c@kernel.org \
--to=nathan@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=agordeev@linux.ibm.com \
--cc=ardb@kernel.org \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=chleroy@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=deller@gmx.de \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=llvm@lists.linux.dev \
--cc=loongarch@lists.linux.dev \
--cc=maddy@linux.ibm.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=mpe@ellerman.id.au \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=npiggin@gmail.com \
--cc=nsc@kernel.org \
--cc=svens@linux.ibm.com \
--cc=tglx@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
--cc=x86@kernel.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