From nobody Fri Apr 17 08:43:50 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FCCC36EA9A; Mon, 23 Feb 2026 19:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771873865; cv=none; b=gQRBjBYywt2YcSPw+C3DiO1WrzuQnuMbiTfyaVmoGNRNhMzydHdvT6LJ6USz7Ec7xBo/vFi8k3Sd4SuKi/ULmjI4Fw1eo56nMPtP5eHu4N6SwCHOSFXBzOneT2vyOUYo10iIZYkwcjE96+pE/B81BtJtS0UT1XPDqtSDDmzAZac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771873865; c=relaxed/simple; bh=JkTF5bcI/LJDdihvClbdqAW2KYqXqhfJYTnKJqYjBBk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d+92+JdjMJew28qaeIOK+4KgcIwnyMYH6lH8g4wXZY8d6+h0hzwNGU/qndJ45Br3wA5Xwi3QsWwEBYoz2er/mVpuE4FjeVCe7EDH0OCDs1/OdiT5ED+nKokOiL7Mz6YTyNlK5Wa23lqm++loV7Rzy1rJ5EXQ1FdfwCB/IifwgSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GN8C1JhZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GN8C1JhZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B742DC116C6; Mon, 23 Feb 2026 19:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771873865; bh=JkTF5bcI/LJDdihvClbdqAW2KYqXqhfJYTnKJqYjBBk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GN8C1JhZvRhhpBPCfAA96a162Ot08dT2IYkPKN6S544ZNG0yHykfVFWnC3JeUts7C OOBW1bvYDFQgFVmNff8jfugMpquKLPZgcCo8UIMLh3Hw9w/f55cHJgjRT5Ew15xt2p Ey6Rs1BTLVqBkq0PuTFMfq1rdUW9nTfeCblLoa7tb93nPCWIIwsP9jFfXqoMJkyJKx lN1BNM0xuFGZ4sWWjhY9R1FgxDmHxcSbD/7GZSjaZugb53LR1P6RjjqTyydHuc64Di oLKGybcxSvG/d9Vm7FznEoxeZN6nenq+4OYR8duG8q81LllndukFFwurhkpfYTdkLZ hK7FIDMLHHP9A== From: Nathan Chancellor Date: Mon, 23 Feb 2026 12:10:28 -0700 Subject: [PATCH 1/2] kbuild: Consolidate C dialect options Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260223-fms-anonymous-structs-v1-1-8ee406d3c36c@kernel.org> References: <20260223-fms-anonymous-structs-v1-0-8ee406d3c36c@kernel.org> In-Reply-To: <20260223-fms-anonymous-structs-v1-0-8ee406d3c36c@kernel.org> 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@kernel.org, "H. Peter Anvin" , Ard Biesheuvel , Ilias Apalodimas , Nick Desaulniers , Bill Wendling , Justin Stitt , Kees Cook , 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 X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=11862; i=nathan@kernel.org; h=from:subject:message-id; bh=JkTF5bcI/LJDdihvClbdqAW2KYqXqhfJYTnKJqYjBBk=; b=owGbwMvMwCUmm602sfCA1DTG02pJDJlzlllucv4qHBczxXYld7Hc+ueJCwPdrooI6CZXL+988 ozV8PjFjlIWBjEuBlkxRZbqx6rHDQ3nnGW8cWoSzBxWJpAhDFycAjCRmZcZGS6uPub1dI+a2Isa zcD6mtC69g7ld/8u5D66ZpZ0kunTlWWMDJuZOGy+L/xlb7869Nyya4e+hkdrie+WcGdQNJLsWGB 7iBsA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 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=3Dgnu11' 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 Acked-by: Ard Biesheuvel Acked-by: Helge Deller # parisc Reviewed-by: Nicolas Schier --- 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 :=3D \ KBUILD_AFLAGS :=3D -D__ASSEMBLY__ -fno-PIE =20 KBUILD_CFLAGS :=3D -KBUILD_CFLAGS +=3D -std=3Dgnu11 KBUILD_CFLAGS +=3D -fshort-wchar KBUILD_CFLAGS +=3D -funsigned-char KBUILD_CFLAGS +=3D -fno-common @@ -790,6 +789,18 @@ ifdef need-config include $(objtree)/include/config/auto.conf endif =20 +CC_FLAGS_DIALECT :=3D -std=3Dgnu11 +# Allow including a tagged struct or union anonymously in another struct/u= nion. +CC_FLAGS_DIALECT +=3D -fms-extensions +# Clang enables warnings about GNU and Microsoft extensions by default, di= sable +# them because this is expected with the above options. +ifdef CONFIG_CC_IS_CLANG +CC_FLAGS_DIALECT +=3D -Wno-gnu +CC_FLAGS_DIALECT +=3D -Wno-microsoft-anon-tag +endif +export CC_FLAGS_DIALECT +KBUILD_CFLAGS +=3D $(CC_FLAGS_DIALECT) + ifeq ($(KBUILD_EXTMOD),) # Objects we will link into vmlinux / subdirs we need to visit core-y :=3D @@ -1093,9 +1104,6 @@ NOSTDINC_FLAGS +=3D -nostdinc # perform bounds checking. KBUILD_CFLAGS +=3D $(call cc-option, -fstrict-flex-arrays=3D3) =20 -# Allow including a tagged struct or union anonymously in another struct/u= nion. -KBUILD_CFLAGS +=3D -fms-extensions - # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS +=3D -fno-strict-overflow =20 diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/M= akefile index 9d0efed91414..bea3675fa668 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -63,7 +63,7 @@ VDSO_CFLAGS +=3D -Wall -Wundef -Wstrict-prototypes -Wno-t= rigraphs \ $(filter -Werror,$(KBUILD_CPPFLAGS)) \ -Werror-implicit-function-declaration \ -Wno-format-security \ - -std=3Dgnu11 -fms-extensions + $(CC_FLAGS_DIALECT) VDSO_CFLAGS +=3D -O2 # Some useful compiler-dependent flags from top-level Makefile VDSO_CFLAGS +=3D $(call cc32-option,-Wno-pointer-sign) @@ -71,7 +71,6 @@ VDSO_CFLAGS +=3D -fno-strict-overflow VDSO_CFLAGS +=3D $(call cc32-option,-Werror=3Dstrict-prototypes) VDSO_CFLAGS +=3D -Werror=3Ddate-time VDSO_CFLAGS +=3D $(call cc32-option,-Werror=3Dincompatible-pointer-types) -VDSO_CFLAGS +=3D $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) =20 # 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 :=3D $(ccflags-vdso) \ -isystem $(shell $(CC) -print-file-name=3Dinclude) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ - -std=3Dgnu11 -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/compre= ssed/Makefile index f8481e4e9d21..14eefb5ed5d1 100644 --- a/arch/parisc/boot/compressed/Makefile +++ b/arch/parisc/boot/compressed/Makefile @@ -18,7 +18,7 @@ KBUILD_CFLAGS +=3D -fno-PIE -mno-space-regs -mdisable-fpr= egs -Os ifndef CONFIG_64BIT KBUILD_CFLAGS +=3D -mfast-indirect-calls endif -KBUILD_CFLAGS +=3D -std=3Dgnu11 -fms-extensions +KBUILD_CFLAGS +=3D $(CC_FLAGS_DIALECT) =20 LDFLAGS_vmlinux :=3D -X -e startup --as-needed -T $(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBG= CC) 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 :=3D -nostdinc $(LINUXINCLUDE) BOOTCPPFLAGS +=3D -isystem $(shell $(BOOTCC) -print-file-name=3Dinclude) =20 BOOTCFLAGS :=3D $(BOOTTARGETFLAGS) \ - -std=3Dgnu11 -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 :=3D -crD =20 ifdef CONFIG_CC_IS_CLANG BOOTCFLAGS +=3D $(CLANG_FLAGS) -BOOTCFLAGS +=3D -Wno-microsoft-anon-tag BOOTAFLAGS +=3D $(CLANG_FLAGS) endif =20 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 :=3D $(CLANG_FLAGS) -m64 -D__A= SSEMBLY__ ifndef CONFIG_AS_IS_LLVM KBUILD_AFLAGS_DECOMPRESSOR +=3D $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) endif -KBUILD_CFLAGS_DECOMPRESSOR :=3D $(CLANG_FLAGS) -m64 -O2 -mpacked-stack -st= d=3Dgnu11 -fms-extensions +KBUILD_CFLAGS_DECOMPRESSOR :=3D $(CLANG_FLAGS) -m64 -O2 -mpacked-stack $(C= C_FLAGS_DIALECT) KBUILD_CFLAGS_DECOMPRESSOR +=3D -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY KBUILD_CFLAGS_DECOMPRESSOR +=3D -D__DECOMPRESSOR KBUILD_CFLAGS_DECOMPRESSOR +=3D -Wno-pointer-sign @@ -35,7 +35,6 @@ KBUILD_CFLAGS_DECOMPRESSOR +=3D $(call cc-disable-warning= , address-of-packed-membe KBUILD_CFLAGS_DECOMPRESSOR +=3D $(if $(CONFIG_DEBUG_INFO),-g) KBUILD_CFLAGS_DECOMPRESSOR +=3D $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call c= c-option, -gdwarf-4,)) KBUILD_CFLAGS_DECOMPRESSOR +=3D $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-arr= ay-bounds) -KBUILD_CFLAGS_DECOMPRESSOR +=3D $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-= anon-tag) =20 UTS_MACHINE :=3D s390x STACK_SIZE :=3D $(if $(CONFIG_KASAN),65536,$(if $(CONFIG_KMSAN),65536,1638= 4)) 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 :=3D -D__NO_FORTIFY $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE $(call if_changed_rule,as_o_S) =20 -KBUILD_CFLAGS :=3D -std=3Dgnu11 -fms-extensions -fno-strict-aliasing -Wall= -Wstrict-prototypes +KBUILD_CFLAGS :=3D $(CC_FLAGS_DIALECT) -fno-strict-aliasing -Wall -Wstrict= -prototypes KBUILD_CFLAGS +=3D -Wno-pointer-sign -Wno-sign-compare KBUILD_CFLAGS +=3D -fno-zero-initialized-in-bss -fno-builtin -ffreestanding KBUILD_CFLAGS +=3D -Os -m64 -msoft-float -fno-common @@ -21,7 +21,6 @@ KBUILD_CFLAGS +=3D -fno-stack-protector KBUILD_CFLAGS +=3D -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS +=3D -D__DISABLE_EXPORTS KBUILD_CFLAGS +=3D $(CLANG_FLAGS) -KBUILD_CFLAGS +=3D $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) KBUILD_CFLAGS +=3D $(call cc-option,-fno-PIE) KBUILD_CFLAGS +=3D $(call cc-option, -Wno-default-const-init-unsafe) KBUILD_AFLAGS :=3D $(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 =20 # How to compile the 16-bit code. Note we always compile for -march=3Di38= 6; # that way we can complain to the user if the CPU is insufficient. -REALMODE_CFLAGS :=3D -std=3Dgnu11 -fms-extensions -m16 -g -Os \ +REALMODE_CFLAGS :=3D $(CC_FLAGS_DIALECT) -m16 -g -Os \ -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \ -Wall -Wstrict-prototypes -march=3Di386 -mregparm=3D3 \ -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ @@ -59,10 +59,6 @@ REALMODE_CFLAGS +=3D -fno-stack-protector REALMODE_CFLAGS +=3D -Wno-address-of-packed-member REALMODE_CFLAGS +=3D $(cc_stack_align4) REALMODE_CFLAGS +=3D $(CLANG_FLAGS) -ifdef CONFIG_CC_IS_CLANG -REALMODE_CFLAGS +=3D -Wno-gnu -REALMODE_CFLAGS +=3D -Wno-microsoft-anon-tag -endif export REALMODE_CFLAGS =20 # 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/M= akefile index 68f9d7a1683b..8924196927bf 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -25,7 +25,7 @@ targets :=3D vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.b= in.bz2 vmlinux.bin.lzma \ # avoid errors with '-march=3Di386', and future flags may depend on the ta= rget to # be valid. KBUILD_CFLAGS :=3D -m$(BITS) -O2 $(CLANG_FLAGS) -KBUILD_CFLAGS +=3D -std=3Dgnu11 -fms-extensions +KBUILD_CFLAGS +=3D $(CC_FLAGS_DIALECT) KBUILD_CFLAGS +=3D -fno-strict-aliasing -fPIE KBUILD_CFLAGS +=3D -Wundef KBUILD_CFLAGS +=3D -DDISABLE_BRANCH_PROFILING @@ -36,10 +36,6 @@ KBUILD_CFLAGS +=3D -mno-mmx -mno-sse KBUILD_CFLAGS +=3D -ffreestanding -fshort-wchar KBUILD_CFLAGS +=3D -fno-stack-protector KBUILD_CFLAGS +=3D $(call cc-disable-warning, address-of-packed-member) -ifdef CONFIG_CC_IS_CLANG -KBUILD_CFLAGS +=3D -Wno-gnu -KBUILD_CFLAGS +=3D -Wno-microsoft-anon-tag -endif KBUILD_CFLAGS +=3D -Wno-pointer-sign KBUILD_CFLAGS +=3D -fno-asynchronous-unwind-tables KBUILD_CFLAGS +=3D -D__DISABLE_EXPORTS diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/l= ibstub/Makefile index e386ffd009b7..fbb8d4e33256 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -11,12 +11,11 @@ cflags-y :=3D $(KBUILD_CFLAGS) =20 cflags-$(CONFIG_X86_32) :=3D -march=3Di386 cflags-$(CONFIG_X86_64) :=3D -mcmodel=3Dsmall -cflags-$(CONFIG_X86) +=3D -m$(BITS) -D__KERNEL__ -std=3Dgnu11 -fms-extens= ions \ +cflags-$(CONFIG_X86) +=3D -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) =20 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) +=3D -Wno-array-bounds =20 ifdef CONFIG_CC_IS_CLANG -# The kernel builds with '-std=3Dgnu11' and '-fms-extensions' so use of GN= U and -# Microsoft extensions is acceptable. -KBUILD_CFLAGS +=3D -Wno-gnu -KBUILD_CFLAGS +=3D -Wno-microsoft-anon-tag - # Clang checks for overflow/truncation with '%p', while GCC does not: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111219 KBUILD_CFLAGS +=3D $(call cc-option, -Wno-format-overflow-non-kprintf) --=20 2.53.0 From nobody Fri Apr 17 08:43:50 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76B13371064; Mon, 23 Feb 2026 19:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771873873; cv=none; b=qoV9UrhZeRX8Koti0jdn/AMOYxYlibeqgGUqryR+X1MIg3CIJw01/c6pBmyvErxAiBbLbIH9wSvMHlK84A7hBetsXu0sKiHvPEA/pHW3pkpuAGoberWuLYYOe62G6tAjvBqiJCoLdaUXSmNISHBuLuVPSwiwH2vkXy1HcH9cbn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771873873; c=relaxed/simple; bh=HnBXmWSMpA4wuIlOSxrj2rJBVS6hgScD9wUDZt2+qlw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XcNsgIbSEdX0gFjuklQl5ezkJZLW5XeNa6R029cUzZdmVWu1TCQ6kPZjVbiKROSw8C2aFuZfx5Es/uufjyKOLJU4TTliDP8F4iwpr8zE2Yz0slzt0h5AqElQd7eOOmW8ibnCewbegiO27pUp9CKbyI0g/h1Ycr5WnaoO2alY4Wg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ec7rpLCA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ec7rpLCA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AEF7C2BCB5; Mon, 23 Feb 2026 19:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771873873; bh=HnBXmWSMpA4wuIlOSxrj2rJBVS6hgScD9wUDZt2+qlw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ec7rpLCAzCv/KZRrk93iS8TKBy0dmX0TGeVU6K4v5xX/A3r84WlF1+spB2Ck3L8+F Ly7Wrk5nDJOONGQAATDn57wpDwS2nId7NK4Vw6pPbxqhuUY3hzAD8tHDKWPeYQ16aq CDGEXsS4binEbD98XFg/kkeskjcNzRQjVBeAbf9hU+krUTPdo4EdS3QsbFUpmWqK+x 83fmxFV+JzQ6K58ijzWKw7NoMdRiJVu6YnkQ+ER5K9bPSOKZ9CiQSYDQwcw9L4xCAq zh+5+/I2WpfYgv6lc5TMsUwpiBXIECDLTQU1MmY+kExyurkj5huthCznFvUTJv9pGV pHQjm+oF6bRiA== From: Nathan Chancellor Date: Mon, 23 Feb 2026 12:10:29 -0700 Subject: [PATCH 2/2] kbuild: Use '-fms-anonymous-structs' if it is available Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260223-fms-anonymous-structs-v1-2-8ee406d3c36c@kernel.org> References: <20260223-fms-anonymous-structs-v1-0-8ee406d3c36c@kernel.org> In-Reply-To: <20260223-fms-anonymous-structs-v1-0-8ee406d3c36c@kernel.org> 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@kernel.org, "H. Peter Anvin" , Ard Biesheuvel , Ilias Apalodimas , Nick Desaulniers , Bill Wendling , Justin Stitt , Kees Cook , 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 X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2260; i=nathan@kernel.org; h=from:subject:message-id; bh=HnBXmWSMpA4wuIlOSxrj2rJBVS6hgScD9wUDZt2+qlw=; b=owGbwMvMwCUmm602sfCA1DTG02pJDJlzllnaL/tzZJ9j+UqRFKP/HVNX104yzPm+PPiz5Fdep pLXR1Z0d5SyMIhxMciKKbJUP1Y9bmg45yzjjVOTYOawMoEMYeDiFICJlJ1h+Gf2bHvS3EU6Cuzv 6lVV6lZmRpcf6jghx2ystVX28+qCK1GMDBd67Cest0lolmS6u+nMHYW1j73/xRXE1p4vP+5/d3u xCTcA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 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/c391efe6fb67329d8e2fd2316= 92cc6b0ea902956 [1] Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D123623 [2] Signed-off-by: Nathan Chancellor Acked-by: Ard Biesheuvel Acked-by: Helge Deller # parisc Reviewed-by: Kees Cook Reviewed-by: Nicolas Schier --- 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 =20 CC_FLAGS_DIALECT :=3D -std=3Dgnu11 # Allow including a tagged struct or union anonymously in another struct/u= nion. -CC_FLAGS_DIALECT +=3D -fms-extensions +CC_FLAGS_DIALECT +=3D $(CONFIG_CC_MS_EXTENSIONS) # Clang enables warnings about GNU and Microsoft extensions by default, di= sable # 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=3D5" if CC_IS_GCC && $(cc-option,-Wimplic= it-fallthrough=3D5) default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreacha= ble-code-fallthrough) =20 +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 --=20 2.53.0