More Linux Kernel Code Cleaned Up - Another Step Towards Building With Clang Or ICC

Written by Michael Larabel in Linux Kernel on 2 November 2018 at 06:42 AM EDT. 7 Comments
LINUX KERNEL
With the Linux 4.20~5.0, the kernel is now VLA-free as a step towards being able to compile the mainline code with the LLVM Clang compiler or other non-GCC compilers. Another step in this direction has been merged this cycle and that is cleaning up the compiler attributes code.

For determining C features to enable or not when compiling the code, the Linux kernel code had been checking the GCC version of the host compiler to determine the functionality that can be enabled or not. With this compiler-attributes update, instead the kernel is now using the generic __has_attribute functionality for its macro feature checks. This now makes it compiler/version agnostic rather than being tied to GCC version checking to instead explicitly looking if a particular feature is supported by that compiler.

This cleans up a fair amount as well as there being other work to simplifying these feature checking macro header files.

The intention of this clean-up is to help the efforts to allow building the kernel with LLVM Clang. Additionally, it also helps in building the Linux kernel with the Intel ICC compiler. We've seen a lot of interest in Clang'ing the kernel but not too much in ICC, but apparently there is some interest. In addition to improving compiler portability, "A fair amount of documentation and comments have also been added, clarified or removed; and the headers are now more readable, which should help kernel developers in general."

Details in this Git merge.

With all of the recent work, it will be interesting to see how close the mainline Linux kernel is to being able to build with Clang. On the AArch64 front they were already there or very close but sadly on x86_64 that effort seems to have somewhat stalled along with the now defunct LLVMLinux project.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week