Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: Use '-fms-anonymous-structs' if it is available

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>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Helge Deller <deller@gmx.de> # parisc
Link: https://patch.msgid.link/20260223-fms-anonymous-structs-v1-2-8ee406d3c36c@kernel.org
Signed-off-by: Nicolas Schier <nsc@kernel.org>

authored by

Nathan Chancellor and committed by
Nicolas Schier
0d3fccf6 ec4c2827

+6 -1
+1 -1
Makefile
··· 791 791 792 792 CC_FLAGS_DIALECT := -std=gnu11 793 793 # Allow including a tagged struct or union anonymously in another struct/union. 794 - CC_FLAGS_DIALECT += -fms-extensions 794 + CC_FLAGS_DIALECT += $(CONFIG_CC_MS_EXTENSIONS) 795 795 # Clang enables warnings about GNU and Microsoft extensions by default, disable 796 796 # them because this is expected with the above options. 797 797 ifdef CONFIG_CC_IS_CLANG
+5
init/Kconfig
··· 960 960 default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5) 961 961 default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough) 962 962 963 + config CC_MS_EXTENSIONS 964 + string 965 + default "-fms-anonymous-structs" if $(cc-option,-fms-anonymous-structs) 966 + default "-fms-extensions" 967 + 963 968 # Currently, disable gcc-10+ array-bounds globally. 964 969 # It's still broken in gcc-13, so no upper bound yet. 965 970 config GCC10_NO_ARRAY_BOUNDS