public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
@ 2026-02-23 19:10 Nathan Chancellor
  2026-02-23 19:10 ` [PATCH 1/2] kbuild: Consolidate C dialect options Nathan Chancellor
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Nathan Chancellor @ 2026-02-23 19:10 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

Hi all,

The kernel enabled '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
enable -fms-extensions") in 6.19 to gain access to a Microsoft
(originally Plan 9) extension around including a tagged structure/union
anonymously in an other structure/union. Since then, Clang 23.0.0
(current main) has added a flag to enable only that extension, rather
than all Microsoft extensions, '-fms-anonymous-structs' [1]. Using this
narrower compiler option would have avoided the build error fixed by
commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
'-fms-extensions'"). While these errors are not expected to be common,
using the narrower option when available has no drawbacks because the
kernel only cares about this extension in '-fms-extensions', no others.
While this could result in build errors for folks using
'-fms-anonymous-structs' if a developer uses another extension in
'-fms-extensions' (either intentionally or unintentionally), flagging
these uses for further scrutiny seems worthwhile.

This series converts the build system to use that flag when it is
available. The first patch consolidates all of the C dialect flags into
a single variable to make future updates to the dialect flags less
painful, as updating the logic in every place that uses their custom
built C flags is getting cumbersome (and C23 is looming). The second
patch makes the actual switch.

I would like Nicolas to carry this in the Kbuild tree for 7.1, please
provide Acks as necessary.

[1]: https://github.com/llvm/llvm-project/commit/c391efe6fb67329d8e2fd231692cc6b0ea902956

---
Nathan Chancellor (2):
      kbuild: Consolidate C dialect options
      kbuild: Use '-fms-anonymous-structs' if it is available

 Makefile                              | 16 ++++++++++++----
 arch/arm64/kernel/vdso32/Makefile     |  3 +--
 arch/loongarch/vdso/Makefile          |  2 +-
 arch/parisc/boot/compressed/Makefile  |  2 +-
 arch/powerpc/boot/Makefile            |  3 +--
 arch/s390/Makefile                    |  3 +--
 arch/s390/purgatory/Makefile          |  3 +--
 arch/x86/Makefile                     |  6 +-----
 arch/x86/boot/compressed/Makefile     |  6 +-----
 drivers/firmware/efi/libstub/Makefile |  3 +--
 init/Kconfig                          |  5 +++++
 scripts/Makefile.warn                 |  5 -----
 12 files changed, 26 insertions(+), 31 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260223-fms-anonymous-structs-f6ade6c8b5a6

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/2] kbuild: Consolidate C dialect options
  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 ` Nathan Chancellor
  2026-02-27 16:36   ` Nicolas Schier
  2026-02-23 19:10 ` [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Nathan Chancellor
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Nathan Chancellor @ 2026-02-23 19:10 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

Introduce CC_FLAGS_DIALECT to make it easier to update the various
places in the tree that rely on the GNU C standard and Microsoft
extensions flags atomically. All remaining uses of '-std=gnu11' and
'-fms-extensions' are in the tools directory (which has its own build
system) and other standalone Makefiles. This will allow the kernel to
use a narrower option to enable the Microsoft anonymous tagged structure
extension in a simpler manner. Place the CC_FLAGS_DIALECT block after
the configuration include (so that a future change can move the
selection of the flag to Kconfig) but before the
arch/$(SRCARCH)/Makefile include (so that CC_FLAGS_DIALECT is available
for use in those Makefiles).

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 Makefile                              | 16 ++++++++++++----
 arch/arm64/kernel/vdso32/Makefile     |  3 +--
 arch/loongarch/vdso/Makefile          |  2 +-
 arch/parisc/boot/compressed/Makefile  |  2 +-
 arch/powerpc/boot/Makefile            |  3 +--
 arch/s390/Makefile                    |  3 +--
 arch/s390/purgatory/Makefile          |  3 +--
 arch/x86/Makefile                     |  6 +-----
 arch/x86/boot/compressed/Makefile     |  6 +-----
 drivers/firmware/efi/libstub/Makefile |  3 +--
 scripts/Makefile.warn                 |  5 -----
 11 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/Makefile b/Makefile
index e944c6e71e81..06ff3032a6bc 100644
--- a/Makefile
+++ b/Makefile
@@ -587,7 +587,6 @@ LINUXINCLUDE    := \
 KBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
 
 KBUILD_CFLAGS :=
-KBUILD_CFLAGS += -std=gnu11
 KBUILD_CFLAGS += -fshort-wchar
 KBUILD_CFLAGS += -funsigned-char
 KBUILD_CFLAGS += -fno-common
@@ -790,6 +789,18 @@ ifdef need-config
 include $(objtree)/include/config/auto.conf
 endif
 
+CC_FLAGS_DIALECT := -std=gnu11
+# Allow including a tagged struct or union anonymously in another struct/union.
+CC_FLAGS_DIALECT += -fms-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
+CC_FLAGS_DIALECT += -Wno-gnu
+CC_FLAGS_DIALECT += -Wno-microsoft-anon-tag
+endif
+export CC_FLAGS_DIALECT
+KBUILD_CFLAGS += $(CC_FLAGS_DIALECT)
+
 ifeq ($(KBUILD_EXTMOD),)
 # Objects we will link into vmlinux / subdirs we need to visit
 core-y		:=
@@ -1093,9 +1104,6 @@ NOSTDINC_FLAGS += -nostdinc
 # perform bounds checking.
 KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
 
-# Allow including a tagged struct or union anonymously in another struct/union.
-KBUILD_CFLAGS += -fms-extensions
-
 # disable invalid "can't wrap" optimizations for signed / pointers
 KBUILD_CFLAGS	+= -fno-strict-overflow
 
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 9d0efed91414..bea3675fa668 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -63,7 +63,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                $(filter -Werror,$(KBUILD_CPPFLAGS)) \
                -Werror-implicit-function-declaration \
                -Wno-format-security \
-               -std=gnu11 -fms-extensions
+               $(CC_FLAGS_DIALECT)
 VDSO_CFLAGS  += -O2
 # Some useful compiler-dependent flags from top-level Makefile
 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
@@ -71,7 +71,6 @@ VDSO_CFLAGS += -fno-strict-overflow
 VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes)
 VDSO_CFLAGS += -Werror=date-time
 VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types)
-VDSO_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag)
 
 # Compile as THUMB2 or ARM. Unwinding via frame-pointers in THUMB2 is
 # unreliable.
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index 520f1513f07d..904ef4a0d826 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -24,7 +24,7 @@ endif
 cflags-vdso := $(ccflags-vdso) \
 	-isystem $(shell $(CC) -print-file-name=include) \
 	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
-	-std=gnu11 -fms-extensions -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
+	$(CC_FLAGS_DIALECT) -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \
 	-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
 	$(call cc-option, -fno-asynchronous-unwind-tables) \
 	$(call cc-option, -fno-stack-protector)
diff --git a/arch/parisc/boot/compressed/Makefile b/arch/parisc/boot/compressed/Makefile
index f8481e4e9d21..14eefb5ed5d1 100644
--- a/arch/parisc/boot/compressed/Makefile
+++ b/arch/parisc/boot/compressed/Makefile
@@ -18,7 +18,7 @@ KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs -Os
 ifndef CONFIG_64BIT
 KBUILD_CFLAGS += -mfast-indirect-calls
 endif
-KBUILD_CFLAGS += -std=gnu11 -fms-extensions
+KBUILD_CFLAGS += $(CC_FLAGS_DIALECT)
 
 LDFLAGS_vmlinux := -X -e startup --as-needed -T
 $(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBGCC) FORCE
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index f1a4761ebd44..7ee0fa2d3371 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -70,7 +70,7 @@ BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
 BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
 BOOTCFLAGS	:= $(BOOTTARGETFLAGS) \
-		   -std=gnu11 -fms-extensions \
+		   $(CC_FLAGS_DIALECT) \
 		   -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -O2 \
 		   -msoft-float -mno-altivec -mno-vsx \
@@ -86,7 +86,6 @@ BOOTARFLAGS	:= -crD
 
 ifdef CONFIG_CC_IS_CLANG
 BOOTCFLAGS += $(CLANG_FLAGS)
-BOOTCFLAGS += -Wno-microsoft-anon-tag
 BOOTAFLAGS += $(CLANG_FLAGS)
 endif
 
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index d78ad6885ca2..c8d16aca1cdc 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -22,7 +22,7 @@ KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
 ifndef CONFIG_AS_IS_LLVM
 KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
 endif
-KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack -std=gnu11 -fms-extensions
+KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack $(CC_FLAGS_DIALECT)
 KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
 KBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR
 KBUILD_CFLAGS_DECOMPRESSOR += -Wno-pointer-sign
@@ -35,7 +35,6 @@ KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-membe
 KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
 KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
 KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
-KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag)
 
 UTS_MACHINE	:= s390x
 STACK_SIZE	:= $(if $(CONFIG_KASAN),65536,$(if $(CONFIG_KMSAN),65536,16384))
diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
index 61d240a37633..95a8ac45b67e 100644
--- a/arch/s390/purgatory/Makefile
+++ b/arch/s390/purgatory/Makefile
@@ -13,7 +13,7 @@ CFLAGS_sha256.o := -D__NO_FORTIFY
 $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE
 	$(call if_changed_rule,as_o_S)
 
-KBUILD_CFLAGS := -std=gnu11 -fms-extensions -fno-strict-aliasing -Wall -Wstrict-prototypes
+KBUILD_CFLAGS := $(CC_FLAGS_DIALECT) -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 += -Os -m64 -msoft-float -fno-common
@@ -21,7 +21,6 @@ KBUILD_CFLAGS += -fno-stack-protector
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 KBUILD_CFLAGS += -D__DISABLE_EXPORTS
 KBUILD_CFLAGS += $(CLANG_FLAGS)
-KBUILD_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag)
 KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
 KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5f881460a8b5..46fec0b08487 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -48,7 +48,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 -fms-extensions -m16 -g -Os \
+REALMODE_CFLAGS	:= $(CC_FLAGS_DIALECT) -m16 -g -Os \
 		   -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
 		   -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
 		   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
@@ -59,10 +59,6 @@ REALMODE_CFLAGS += -fno-stack-protector
 REALMODE_CFLAGS += -Wno-address-of-packed-member
 REALMODE_CFLAGS += $(cc_stack_align4)
 REALMODE_CFLAGS += $(CLANG_FLAGS)
-ifdef CONFIG_CC_IS_CLANG
-REALMODE_CFLAGS += -Wno-gnu
-REALMODE_CFLAGS += -Wno-microsoft-anon-tag
-endif
 export REALMODE_CFLAGS
 
 # BITS is used as extension for files which are available in a 32 bit
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 68f9d7a1683b..8924196927bf 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -25,7 +25,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 -fms-extensions
+KBUILD_CFLAGS += $(CC_FLAGS_DIALECT)
 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
 KBUILD_CFLAGS += -Wundef
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
@@ -36,10 +36,6 @@ KBUILD_CFLAGS += -mno-mmx -mno-sse
 KBUILD_CFLAGS += -ffreestanding -fshort-wchar
 KBUILD_CFLAGS += -fno-stack-protector
 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
-ifdef CONFIG_CC_IS_CLANG
-KBUILD_CFLAGS += -Wno-gnu
-KBUILD_CFLAGS += -Wno-microsoft-anon-tag
-endif
 KBUILD_CFLAGS += -Wno-pointer-sign
 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
 KBUILD_CFLAGS += -D__DISABLE_EXPORTS
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index e386ffd009b7..fbb8d4e33256 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -11,12 +11,11 @@ cflags-y			:= $(KBUILD_CFLAGS)
 
 cflags-$(CONFIG_X86_32)		:= -march=i386
 cflags-$(CONFIG_X86_64)		:= -mcmodel=small
-cflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ -std=gnu11 -fms-extensions \
+cflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ $(CC_FLAGS_DIALECT) \
 				   -fPIC -fno-strict-aliasing -mno-red-zone \
 				   -mno-mmx -mno-sse -fshort-wchar \
 				   -Wno-pointer-sign \
 				   $(call cc-disable-warning, address-of-packed-member) \
-				   $(if $(CONFIG_CC_IS_CLANG),-Wno-gnu -Wno-microsoft-anon-tag) \
 				   -fno-asynchronous-unwind-tables \
 				   $(CLANG_FLAGS)
 
diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn
index 5567da6c7dfe..e77ca875aea4 100644
--- a/scripts/Makefile.warn
+++ b/scripts/Makefile.warn
@@ -28,11 +28,6 @@ endif
 KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
 
 ifdef CONFIG_CC_IS_CLANG
-# The kernel builds with '-std=gnu11' and '-fms-extensions' so use of GNU and
-# Microsoft extensions is acceptable.
-KBUILD_CFLAGS += -Wno-gnu
-KBUILD_CFLAGS += -Wno-microsoft-anon-tag
-
 # Clang checks for overflow/truncation with '%p', while GCC does not:
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
 KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow-non-kprintf)

-- 
2.53.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
  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-23 19:10 ` Nathan Chancellor
  2026-02-23 22:33   ` Kees Cook
  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
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Nathan Chancellor @ 2026-02-23 19:10 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

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



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  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-23 19:10 ` [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Nathan Chancellor
@ 2026-02-23 19:38 ` Ard Biesheuvel
  2026-02-23 21:13   ` Helge Deller
  2026-03-05 23:43 ` H. Peter Anvin
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2026-02-23 19:38 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James Bottomley, Helge Deller, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H . Peter Anvin,
	Ilias Apalodimas, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Kees Cook, linux-kbuild, linux-kernel, linux-arm-kernel,
	loongarch, linux-parisc, linuxppc-dev, linux-s390, linux-efi,
	llvm



On Mon, 23 Feb 2026, at 20:10, Nathan Chancellor wrote:
> Hi all,
>
> The kernel enabled '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
> enable -fms-extensions") in 6.19 to gain access to a Microsoft
> (originally Plan 9) extension around including a tagged structure/union
> anonymously in an other structure/union. Since then, Clang 23.0.0
> (current main) has added a flag to enable only that extension, rather
> than all Microsoft extensions, '-fms-anonymous-structs' [1]. Using this
> narrower compiler option would have avoided the build error fixed by
> commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
> '-fms-extensions'"). While these errors are not expected to be common,
> using the narrower option when available has no drawbacks because the
> kernel only cares about this extension in '-fms-extensions', no others.
> While this could result in build errors for folks using
> '-fms-anonymous-structs' if a developer uses another extension in
> '-fms-extensions' (either intentionally or unintentionally), flagging
> these uses for further scrutiny seems worthwhile.
>
> This series converts the build system to use that flag when it is
> available. The first patch consolidates all of the C dialect flags into
> a single variable to make future updates to the dialect flags less
> painful, as updating the logic in every place that uses their custom
> built C flags is getting cumbersome (and C23 is looming). The second
> patch makes the actual switch.
>
> I would like Nicolas to carry this in the Kbuild tree for 7.1, please
> provide Acks as necessary.
>
> [1]: 
> https://github.com/llvm/llvm-project/commit/c391efe6fb67329d8e2fd231692cc6b0ea902956
>
> ---
> Nathan Chancellor (2):
>       kbuild: Consolidate C dialect options
>       kbuild: Use '-fms-anonymous-structs' if it is available
>

Acked-by: Ard Biesheuvel <ardb@kernel.org>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  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
  0 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2026-02-23 21:13 UTC (permalink / raw)
  To: Ard Biesheuvel, Nathan Chancellor, Nicolas Schier
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James Bottomley, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H . Peter Anvin,
	Ilias Apalodimas, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Kees Cook, linux-kbuild, linux-kernel, linux-arm-kernel,
	loongarch, linux-parisc, linuxppc-dev, linux-s390, linux-efi,
	llvm

On 2/23/26 20:38, Ard Biesheuvel wrote:
> 
> 
> On Mon, 23 Feb 2026, at 20:10, Nathan Chancellor wrote:
>> Hi all,
>>
>> The kernel enabled '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
>> enable -fms-extensions") in 6.19 to gain access to a Microsoft
>> (originally Plan 9) extension around including a tagged structure/union
>> anonymously in an other structure/union. Since then, Clang 23.0.0
>> (current main) has added a flag to enable only that extension, rather
>> than all Microsoft extensions, '-fms-anonymous-structs' [1]. Using this
>> narrower compiler option would have avoided the build error fixed by
>> commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
>> '-fms-extensions'"). While these errors are not expected to be common,
>> using the narrower option when available has no drawbacks because the
>> kernel only cares about this extension in '-fms-extensions', no others.
>> While this could result in build errors for folks using
>> '-fms-anonymous-structs' if a developer uses another extension in
>> '-fms-extensions' (either intentionally or unintentionally), flagging
>> these uses for further scrutiny seems worthwhile.
>>
>> This series converts the build system to use that flag when it is
>> available. The first patch consolidates all of the C dialect flags into
>> a single variable to make future updates to the dialect flags less
>> painful, as updating the logic in every place that uses their custom
>> built C flags is getting cumbersome (and C23 is looming). The second
>> patch makes the actual switch.
>>
>> I would like Nicolas to carry this in the Kbuild tree for 7.1, please
>> provide Acks as necessary.
>>
>> [1]:
>> https://github.com/llvm/llvm-project/commit/c391efe6fb67329d8e2fd231692cc6b0ea902956
>>
>> ---
>> Nathan Chancellor (2):
>>        kbuild: Consolidate C dialect options
>>        kbuild: Use '-fms-anonymous-structs' if it is available
>>
> 
> Acked-by: Ard Biesheuvel <ardb@kernel.org>

For the series:
Acked-by: Helge Deller <deller@gmx.de>  # parisc

Thanks!
Helge


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
  2026-02-23 19:10 ` [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Nathan Chancellor
@ 2026-02-23 22:33   ` Kees Cook
  2026-02-23 22:53     ` Nathan Chancellor
  2026-03-05 10:25   ` Nicolas Schier
  1 sibling, 1 reply; 16+ messages in thread
From: Kees Cook @ 2026-02-23 22:33 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild,
	linux-kernel, linux-arm-kernel, loongarch, linux-parisc,
	linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, Feb 23, 2026 at 12:10:29PM -0700, Nathan Chancellor wrote:
> 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

Series looks good to me. One style question, why go the round-trip with
Kconfig instead of doing it all with a fallback in the Makefile:

CC_FLAGS_DIALECT += $(call cc-option,-fms-anonymous-structs,-fms-extensions)


-- 
Kees Cook


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
  2026-02-23 22:33   ` Kees Cook
@ 2026-02-23 22:53     ` Nathan Chancellor
  2026-02-23 23:02       ` Kees Cook
  0 siblings, 1 reply; 16+ messages in thread
From: Nathan Chancellor @ 2026-02-23 22:53 UTC (permalink / raw)
  To: Kees Cook
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild,
	linux-kernel, linux-arm-kernel, loongarch, linux-parisc,
	linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, Feb 23, 2026 at 02:33:35PM -0800, Kees Cook wrote:
> Series looks good to me. One style question, why go the round-trip with
> Kconfig instead of doing it all with a fallback in the Makefile:
> 
> CC_FLAGS_DIALECT += $(call cc-option,-fms-anonymous-structs,-fms-extensions)

I might be misunderstanding how Kbuild works but
arch/$(SRCARCH)/Makefile may have logic for selecting CROSS_COMPILE,
which can impact the selection of $(CC), so I cannot use cc-option prior
to its inclusion but I need CC_FLAGS_DIALECT to be included before
arch/$(SRCARCH)/Makefile in the main build so that they can be used
within it, which is only possible after Kconfig has run. This is
probably worth more flushing out in the code or a comment since it is
subtle.

Cheers,
Nathan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
  2026-02-23 22:53     ` Nathan Chancellor
@ 2026-02-23 23:02       ` Kees Cook
  2026-02-24 20:55         ` Nathan Chancellor
  0 siblings, 1 reply; 16+ messages in thread
From: Kees Cook @ 2026-02-23 23:02 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild,
	linux-kernel, linux-arm-kernel, loongarch, linux-parisc,
	linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, Feb 23, 2026 at 03:53:11PM -0700, Nathan Chancellor wrote:
> On Mon, Feb 23, 2026 at 02:33:35PM -0800, Kees Cook wrote:
> > Series looks good to me. One style question, why go the round-trip with
> > Kconfig instead of doing it all with a fallback in the Makefile:
> > 
> > CC_FLAGS_DIALECT += $(call cc-option,-fms-anonymous-structs,-fms-extensions)
> 
> I might be misunderstanding how Kbuild works but
> arch/$(SRCARCH)/Makefile may have logic for selecting CROSS_COMPILE,
> which can impact the selection of $(CC), so I cannot use cc-option prior
> to its inclusion but I need CC_FLAGS_DIALECT to be included before
> arch/$(SRCARCH)/Makefile in the main build so that they can be used
> within it, which is only possible after Kconfig has run. This is
> probably worth more flushing out in the code or a comment since it is
> subtle.

Will Kconfig see a different CC than Makefile? Regardless, I trust your
judgement here! I actually rather prefer having it exposed via Kconfig.
:)

Reviewed-by: Kees Cook <kees@kernel.org>

-Kees

-- 
Kees Cook


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
  2026-02-23 23:02       ` Kees Cook
@ 2026-02-24 20:55         ` Nathan Chancellor
  0 siblings, 0 replies; 16+ messages in thread
From: Nathan Chancellor @ 2026-02-24 20:55 UTC (permalink / raw)
  To: Kees Cook
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild,
	linux-kernel, linux-arm-kernel, loongarch, linux-parisc,
	linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, Feb 23, 2026 at 03:02:32PM -0800, Kees Cook wrote:
> On Mon, Feb 23, 2026 at 03:53:11PM -0700, Nathan Chancellor wrote:
> > On Mon, Feb 23, 2026 at 02:33:35PM -0800, Kees Cook wrote:
> > > Series looks good to me. One style question, why go the round-trip with
> > > Kconfig instead of doing it all with a fallback in the Makefile:
> > > 
> > > CC_FLAGS_DIALECT += $(call cc-option,-fms-anonymous-structs,-fms-extensions)
> > 
> > I might be misunderstanding how Kbuild works but
> > arch/$(SRCARCH)/Makefile may have logic for selecting CROSS_COMPILE,
> > which can impact the selection of $(CC), so I cannot use cc-option prior
> > to its inclusion but I need CC_FLAGS_DIALECT to be included before
> > arch/$(SRCARCH)/Makefile in the main build so that they can be used
> > within it, which is only possible after Kconfig has run. This is
> > probably worth more flushing out in the code or a comment since it is
> > subtle.
> 
> Will Kconfig see a different CC than Makefile? Regardless, I trust your

It shouldn't, as arch/$(SRCARCH)/Makefile is included before invoking
Kconfig; if the compiler changes, Kconfig will run again before
building.

> judgement here! I actually rather prefer having it exposed via Kconfig.
> :)
> 
> Reviewed-by: Kees Cook <kees@kernel.org>

Thanks!
Nathan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/2] kbuild: Consolidate C dialect options
  2026-02-23 19:10 ` [PATCH 1/2] kbuild: Consolidate C dialect options Nathan Chancellor
@ 2026-02-27 16:36   ` Nicolas Schier
  0 siblings, 0 replies; 16+ messages in thread
From: Nicolas Schier @ 2026-02-27 16:36 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, Feb 23, 2026 at 12:10:28PM -0700, Nathan Chancellor wrote:
> Introduce CC_FLAGS_DIALECT to make it easier to update the various
> places in the tree that rely on the GNU C standard and Microsoft
> extensions flags atomically. All remaining uses of '-std=gnu11' and
> '-fms-extensions' are in the tools directory (which has its own build
> system) and other standalone Makefiles. This will allow the kernel to
> use a narrower option to enable the Microsoft anonymous tagged structure
> extension in a simpler manner. Place the CC_FLAGS_DIALECT block after
> the configuration include (so that a future change can move the
> selection of the flag to Kconfig) but before the
> arch/$(SRCARCH)/Makefile include (so that CC_FLAGS_DIALECT is available
> for use in those Makefiles).
> 
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  Makefile                              | 16 ++++++++++++----
>  arch/arm64/kernel/vdso32/Makefile     |  3 +--
>  arch/loongarch/vdso/Makefile          |  2 +-
>  arch/parisc/boot/compressed/Makefile  |  2 +-
>  arch/powerpc/boot/Makefile            |  3 +--
>  arch/s390/Makefile                    |  3 +--
>  arch/s390/purgatory/Makefile          |  3 +--
>  arch/x86/Makefile                     |  6 +-----
>  arch/x86/boot/compressed/Makefile     |  6 +-----
>  drivers/firmware/efi/libstub/Makefile |  3 +--
>  scripts/Makefile.warn                 |  5 -----
>  11 files changed, 21 insertions(+), 31 deletions(-)
> 

Reviewed-by: Nicolas Schier <nsc@kernel.org>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available
  2026-02-23 19:10 ` [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Nathan Chancellor
  2026-02-23 22:33   ` Kees Cook
@ 2026-03-05 10:25   ` Nicolas Schier
  1 sibling, 0 replies; 16+ messages in thread
From: Nicolas Schier @ 2026-03-05 10:25 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, 23 Feb 2026 12:10:29 -0700, Nathan Chancellor <nathan@kernel.org> wrote:
> 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.
> 
> [...]

Reviewed-by: Nicolas Schier <nsc@kernel.org>

-- 
Nicolas



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  2026-02-23 19:10 [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available Nathan Chancellor
                   ` (2 preceding siblings ...)
  2026-02-23 19:38 ` [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available Ard Biesheuvel
@ 2026-03-05 23:43 ` H. Peter Anvin
  2026-03-06 23:17   ` Nathan Chancellor
  2026-03-09  6:49 ` Nicolas Schier
  2026-03-12 12:08 ` Nicolas Schier
  5 siblings, 1 reply; 16+ messages in thread
From: H. Peter Anvin @ 2026-03-05 23:43 UTC (permalink / raw)
  To: Nathan Chancellor, Nicolas Schier
  Cc: Linus Torvalds, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	Ard Biesheuvel, Ilias Apalodimas, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Kees Cook, linux-kbuild, linux-kernel,
	linux-arm-kernel, loongarch, linux-parisc, linuxppc-dev,
	linux-s390, linux-efi, llvm

On 2026-02-23 11:10, Nathan Chancellor wrote:
> Hi all,
> 
> The kernel enabled '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
> enable -fms-extensions") in 6.19 to gain access to a Microsoft
> (originally Plan 9) extension around including a tagged structure/union
> anonymously in an other structure/union. Since then, Clang 23.0.0
> (current main) has added a flag to enable only that extension, rather
> than all Microsoft extensions, '-fms-anonymous-structs' [1]. Using this
> narrower compiler option would have avoided the build error fixed by
> commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
> '-fms-extensions'"). While these errors are not expected to be common,
> using the narrower option when available has no drawbacks because the
> kernel only cares about this extension in '-fms-extensions', no others.
> While this could result in build errors for folks using
> '-fms-anonymous-structs' if a developer uses another extension in
> '-fms-extensions' (either intentionally or unintentionally), flagging
> these uses for further scrutiny seems worthwhile.
> 
> This series converts the build system to use that flag when it is
> available. The first patch consolidates all of the C dialect flags into
> a single variable to make future updates to the dialect flags less
> painful, as updating the logic in every place that uses their custom
> built C flags is getting cumbersome (and C23 is looming). The second
> patch makes the actual switch.
> 
> I would like Nicolas to carry this in the Kbuild tree for 7.1, please
> provide Acks as necessary.
> 
> [1]: https://github.com/llvm/llvm-project/commit/c391efe6fb67329d8e2fd231692cc6b0ea902956
> 

Question: does clang allow this with __extension__, or only if the option is
on the command line?  It would be desirable in the long run if both clang and
gcc would allow this with __extension__, as that would be required to use it
in uapi headers (at least without some doable-but-nontrivial preprocessing,
which might be worthwhile to do anyway...)

	-hpa



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  2026-03-05 23:43 ` H. Peter Anvin
@ 2026-03-06 23:17   ` Nathan Chancellor
  2026-03-06 23:31     ` H. Peter Anvin
  0 siblings, 1 reply; 16+ messages in thread
From: Nathan Chancellor @ 2026-03-06 23:17 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	Ard Biesheuvel, Ilias Apalodimas, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Kees Cook, linux-kbuild, linux-kernel,
	linux-arm-kernel, loongarch, linux-parisc, linuxppc-dev,
	linux-s390, linux-efi, llvm

On Thu, Mar 05, 2026 at 03:43:29PM -0800, H. Peter Anvin wrote:
> Question: does clang allow this with __extension__, or only if the option is
> on the command line?  It would be desirable in the long run if both clang and

It looks like only on the command line:

  https://godbolt.org/z/zrE766obe

> gcc would allow this with __extension__, as that would be required to use it
> in uapi headers (at least without some doable-but-nontrivial preprocessing,
> which might be worthwhile to do anyway...)

I agree that would be desirable but wouldn't that change how
__extension__ works? As far as I can tell from reading GCC's
documentation [1], __extension__ just supresses warnings from -pedantic
and such, it does not actually enable a used extension if it conflicts
with whatever -std= value is passed?

[1]: https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html

Cheers,
Nathan


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  2026-03-06 23:17   ` Nathan Chancellor
@ 2026-03-06 23:31     ` H. Peter Anvin
  0 siblings, 0 replies; 16+ messages in thread
From: H. Peter Anvin @ 2026-03-06 23:31 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	Ard Biesheuvel, Ilias Apalodimas, Nick Desaulniers, Bill Wendling,
	Justin Stitt, Kees Cook, linux-kbuild, linux-kernel,
	linux-arm-kernel, loongarch, linux-parisc, linuxppc-dev,
	linux-s390, linux-efi, llvm

On 2026-03-06 15:17, Nathan Chancellor wrote:
> On Thu, Mar 05, 2026 at 03:43:29PM -0800, H. Peter Anvin wrote:
>> Question: does clang allow this with __extension__, or only if the option is
>> on the command line?  It would be desirable in the long run if both clang and
> 
> It looks like only on the command line:
> 
>   https://godbolt.org/z/zrE766obe
> 
>> gcc would allow this with __extension__, as that would be required to use it
>> in uapi headers (at least without some doable-but-nontrivial preprocessing,
>> which might be worthwhile to do anyway...)
> 
> I agree that would be desirable but wouldn't that change how
> __extension__ works? As far as I can tell from reading GCC's
> documentation [1], __extension__ just supresses warnings from -pedantic
> and such, it does not actually enable a used extension if it conflicts
> with whatever -std= value is passed?
> 
> [1]: https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
> 

Maybe it does, but it's explicit purpose is to allow code to be compiled with
a -std= setting lower than the system libraries.

I was a little surprised to see that -std=c90 doesn't actually enforce C90
compatibility; even with -Wall -Wextra it requires -pedantic to issue
warnings; the same seems to apply to -std=c99 for at least some features that
were included in gnu* standards like anonymous structures and unions.

The latter is probably a particular indication about the desirability of this,
since the extension we are talking about is a relatively obvious extension of
the anonymous struct/union construct!

It is an incredibly useful thing in ABI headers, because it lets you avoid the
"copy/macro this entire structure definition into another."

	-hpa







^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  2026-02-23 19:10 [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available Nathan Chancellor
                   ` (3 preceding siblings ...)
  2026-03-05 23:43 ` H. Peter Anvin
@ 2026-03-09  6:49 ` Nicolas Schier
  2026-03-12 12:08 ` Nicolas Schier
  5 siblings, 0 replies; 16+ messages in thread
From: Nicolas Schier @ 2026-03-09  6:49 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, 23 Feb 2026 12:10:27 -0700, Nathan Chancellor wrote:
> The kernel enabled '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
> enable -fms-extensions") in 6.19 to gain access to a Microsoft
> (originally Plan 9) extension around including a tagged structure/union
> anonymously in an other structure/union. Since then, Clang 23.0.0
> (current main) has added a flag to enable only that extension, rather
> than all Microsoft extensions, '-fms-anonymous-structs' [1]. Using this
> narrower compiler option would have avoided the build error fixed by
> commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
> '-fms-extensions'"). While these errors are not expected to be common,
> using the narrower option when available has no drawbacks because the
> kernel only cares about this extension in '-fms-extensions', no others.
> While this could result in build errors for folks using
> '-fms-anonymous-structs' if a developer uses another extension in
> '-fms-extensions' (either intentionally or unintentionally), flagging
> these uses for further scrutiny seems worthwhile.
> 
> [...]

Applied to kbuild/linux.git (kbuild-next-unstable), thanks!

[1/2] kbuild: Consolidate C dialect options
      https://git.kernel.org/kbuild/c/f3fead1c
[2/2] kbuild: Use '-fms-anonymous-structs' if it is available
      https://git.kernel.org/kbuild/c/c14d8386

Acks and review trailers are still welcome!

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers). Patches applied to the
kbuild-next-unstable branch are accepted pending wider testing in
linux-next and any post-commit review; they will generally be moved
to the kbuild-next branch in about a week if no issues are found.

Best regards,
-- 
Nicolas



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available
  2026-02-23 19:10 [PATCH 0/2] kbuild: Switch from '-fms-extensions' to '-fms-anonymous-structs' when available Nathan Chancellor
                   ` (4 preceding siblings ...)
  2026-03-09  6:49 ` Nicolas Schier
@ 2026-03-12 12:08 ` Nicolas Schier
  5 siblings, 0 replies; 16+ messages in thread
From: Nicolas Schier @ 2026-03-12 12:08 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Nicolas Schier, Linus Torvalds, Catalin Marinas, Will Deacon,
	Huacai Chen, WANG Xuerui, James E.J. Bottomley, Helge Deller,
	Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy (CS GROUP), Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ard Biesheuvel, Ilias Apalodimas,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Kees Cook,
	linux-kbuild, linux-kernel, linux-arm-kernel, loongarch,
	linux-parisc, linuxppc-dev, linux-s390, linux-efi, llvm

On Mon, 23 Feb 2026 12:10:27 -0700, Nathan Chancellor wrote:
> The kernel enabled '-fms-extensions' in commit c4781dc3d1cf ("Kbuild:
> enable -fms-extensions") in 6.19 to gain access to a Microsoft
> (originally Plan 9) extension around including a tagged structure/union
> anonymously in an other structure/union. Since then, Clang 23.0.0
> (current main) has added a flag to enable only that extension, rather
> than all Microsoft extensions, '-fms-anonymous-structs' [1]. Using this
> narrower compiler option would have avoided the build error fixed by
> commit a6773e6932cb ("jfs: Rename _inline to avoid conflict with clang's
> '-fms-extensions'"). While these errors are not expected to be common,
> using the narrower option when available has no drawbacks because the
> kernel only cares about this extension in '-fms-extensions', no others.
> While this could result in build errors for folks using
> '-fms-anonymous-structs' if a developer uses another extension in
> '-fms-extensions' (either intentionally or unintentionally), flagging
> these uses for further scrutiny seems worthwhile.
> 
> [...]

Applied to kbuild/kbuild-next.git (kbuild-next), thanks!

[1/2] kbuild: Consolidate C dialect options
      https://git.kernel.org/kbuild/c/ec4c2827
[2/2] kbuild: Use '-fms-anonymous-structs' if it is available
      https://git.kernel.org/kbuild/c/0d3fccf6

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers).

Acks from arch maintainers are still welcome!

Best regards,
-- 
Nicolas



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-03-12 12:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Nathan Chancellor
2026-02-23 22:33   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox