The Linux Kernel Looks to “Bite the Bullet” in Enabling Microsoft C Extensions

admin By admin 2025 年 11 月 10 日

Written by Michael Larabel
Posted in Linux Kernel
9 November 2025, 11:30 AM EST
54 Comments

Two patches have been queued into the Linux kernel’s build system development tree, *kbuild-next*, which would enable the `-fms-extensions` compiler argument everywhere. This change allows GCC and LLVM/Clang to utilize the Microsoft C Extensions when compiling the Linux kernel.

Since these patches are currently in *kbuild-next*, they will likely be submitted for the upcoming Linux 6.19 kernel merge window next month. However, it remains to be seen if there will be any last-minute objections to this change.

The `-fms-extensions` compiler option, supported by both GNU Compiler Collection (GCC) and LLVM/Clang, enables certain non-standard C/C++ constructs used within Microsoft header files, also honored by the Microsoft Visual C/C++ compiler. For Linux kernel development, enabling Microsoft C Extensions allows for features like including a tagged struct or union anonymously within another struct or union.

Over the years, there have been multiple patch proposals to unconditionally enable `-fms-extensions` for the Linux kernel. However, none of these patches made it past discussions on the Linux kernel mailing list. Now, with these two patches present in *kbuild-next*, their submission for Linux 6.19 seems probable, barring any objections from prominent Linux kernel developers or Linus Torvalds himself.

Rasmus Villemoes, in a discussion about Kbuild enabling `-fms-extensions`, highlighted that this change could result in “prettier code.” Others have also noted the potential benefits, such as saving stack space and leveraging Microsoft C behavior within the kernel source.

Villemoes commented:

> “Once in a while, enabling `-fms-extensions` could allow some slightly prettier code. But every time it has come up, the alternative code has been deemed ‘not too awful,’ and not worth introducing another compiler flag for. That’s probably true for each individual case, but it’s somewhat of a chicken-and-egg situation.
> If we just ‘bite the bullet,’ as Linus says, and enable it once and for all, it’ll be available whenever a use case turns up, and no individual case has to justify it.”

A search on lore.kernel.org reveals examples where `-fms-extensions` might improve code quality, and undoubtedly there are more such instances not yet discussed.

The second patch focuses on Kbuild itself: it adds `-fms-extensions` to areas with dedicated CFLAGS to ensure the flag is passed correctly for CPU architectures that use their own CFLAGS settings instead of the main `KBUILD_CFLAGS`.

Linus Torvalds weighed in during the mailing list discussion and does not appear opposed to enabling `-fms-extensions` starting with Linux 6.19.

Enabling `-fms-extensions` will permit some tidier C code in the kernel. However, some developers may have reservations about incorporating Microsoft C behavior into the mainline Linux kernel codebase.

**About The Author**
Michael Larabel is the principal author of Phoronix.com, which he founded in 2004 with the goal of enriching the Linux hardware experience. Over the years, he has written more than 20,000 articles covering Linux hardware support, system performance, graphics drivers, and more.

Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org—automated benchmarking tools widely used in the Linux community.

*For more articles and updates, visit [Phoronix.com](https://www.phoronix.com).*
https://www.phoronix.com/news/Linux-6.19-Patch-Would-MS-Ext

Leave a Reply

Your email address will not be published. Required fields are marked *