Clang LTO PR Submitted For Linux 5.12, But x86_64 Support Not Included Yet

Written by Michael Larabel in Linux Kernel on 17 February 2021 at 06:05 AM EST. 2 Comments
LINUX KERNEL
The pull request is pending that would allow Clang Link-Time Optimizations (LTO) to be enabled when building the Linux 5.12 kernel with this alternative compiler. The initial pull request has the compiler optimization work ready for the core infrastructure and 64-bit ARM (AArch64) while the x86_64 support isn't expected until the Linux 5.13 cycle.

Last month we outlined the Clang LTO ambitions for the mainline Linux kernel and it getting into position for 5.12. Clang Link Time Optimizations are being pursued for greater performance as well as being necessary for supporting Clang's Control-Flow Integrity (CFI) handling with the kernel.

Link-Time Optimizations allow for the compiler to carry out optimizations at link time on the entire program / binary rather than on a file-level basis. The Clang LTO support for the Linux kernel allows both full LTO as well as LLVM ThinLTO support.

In the past Linus Torvalds shot down GCC LTO efforts for the Linux kernel so there still isn't any mainlined GNU Compiler Collection support here. Google who has been pursuing these patches do stand good chances of getting this code merged for Linux 5.12 considering its well tested: the Android kernels for ~3 years now have not only been built by Clang but have also been making use of link-time optimizations. And besides performance, Clang LTO allows enabling CFI for greater security.

The only downside is that for Linux 5.12 the Clang LTO support would only be available for 64-bit ARM builds while the x86/x86_64 support isn't expected until Linux 5.13 due to work still pending on the objtool side.

The pull request adding Clang LTO for the Linux kernel can be found here while awaiting to see what Linus Torvalds thinks of the addition and if it will be pulled this cycle contrary to his prior LTO kernel comments.
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