Linux Kernel Working Towards GNU11/C11 Compatibility
For now it looks like the Linux kernel is going to explicitly declare itself as using the GNU89 dialect of the C89 standard but over time the code is being made to compile under C11.
With GCC 5 switching to use GNU11 by default over the GNU89 C standard (and Clang also moving to GNU11 by default), a patch was proposed on the Linux kernel mailing list this weekend for explicitly using GNU89 as up to now the -std=gnu89 compiler switch wasn't set by default so if using GCC 5 it will try to compile the kernel against GNU11.
Sasha Levin who proposed the initial patch explained that when trying to compile the Linux kernel right now in C11 mode it makes "[the] kernel build unhappy." Linus Torvalds immediately followed-up asking why not make the Linux kernel C11 happy or what sort of changes are needed to make the kernel compatible with the latest C standard.
One of the incompatibilities right now in GNU11 deals with it lacking cast with initializer support, but that was fixed in GCC upstream as of yesterday. There's also still some outstanding issues with semantic differences for extern inlines between GNU89 and GNU99/GNU11. Sasha Levin also expressed concerns just not about the kernel building without errors under C11 but the generated code being correct. "The build breakage is easy to fix. I'm worried about the stuff that won't show upon build. Different behaviours that go unnoticed and maybe issues inside gcc's code generation that weren't uncovered until now."
There's patches being worked on to let the Linux kernel compile under C11/GNU11, but based on the feel of the mailing list thread right now, it looks like that GNU89 could still be forced for the Linux kernel in the near term to ensure that no other compatibility issues are uncovered for its massive code-base using the newest C standard.
With GCC 5 switching to use GNU11 by default over the GNU89 C standard (and Clang also moving to GNU11 by default), a patch was proposed on the Linux kernel mailing list this weekend for explicitly using GNU89 as up to now the -std=gnu89 compiler switch wasn't set by default so if using GCC 5 it will try to compile the kernel against GNU11.
Sasha Levin who proposed the initial patch explained that when trying to compile the Linux kernel right now in C11 mode it makes "[the] kernel build unhappy." Linus Torvalds immediately followed-up asking why not make the Linux kernel C11 happy or what sort of changes are needed to make the kernel compatible with the latest C standard.
One of the incompatibilities right now in GNU11 deals with it lacking cast with initializer support, but that was fixed in GCC upstream as of yesterday. There's also still some outstanding issues with semantic differences for extern inlines between GNU89 and GNU99/GNU11. Sasha Levin also expressed concerns just not about the kernel building without errors under C11 but the generated code being correct. "The build breakage is easy to fix. I'm worried about the stuff that won't show upon build. Different behaviours that go unnoticed and maybe issues inside gcc's code generation that weren't uncovered until now."
There's patches being worked on to let the Linux kernel compile under C11/GNU11, but based on the feel of the mailing list thread right now, it looks like that GNU89 could still be forced for the Linux kernel in the near term to ensure that no other compatibility issues are uncovered for its massive code-base using the newest C standard.
3 Comments