Patches Posted For GCC LTO Optimizing The Linux Kernel

Written by Michael Larabel in Linux Kernel on 14 November 2022 at 03:20 PM EST. 17 Comments
LINUX KERNEL --
Since last year when building the Linux kernel using LLVM's Clang compiler it's been possible to enable link-time optimizations (LTO) for the kernel build. Building the Linux kernel with GCC has lacked LTO support while a patch series posted today is the latest attempt to make that happen.

Since being merged in Linux 5.16, the Clang LTO support has continued in the Linux kernel just not in the name of performance but was also necessary for Clang-based CFI support with the kernel.

Going back a decade and long before Clang could build the mainline Linux kernel, there had been GCC LTO patches for the Linux kernel but ultimately never merged. Linus Torvalds expressed back then as well that he was unconvinced by LTO'ing the kernel. But now as we approach the end of 2022, there is a new attempt at GCC LTO support for the kernel.

Jiri Slaby of SUSE sent out this GCC LTO support patch series as a "first call for comments" and is based in part on prior patches by Andi Kleen as well as work from fellow SUSE engineer Martin Liska.

While compiler link-time optimizations in general are beneficial for performance due to being able to make optimizations when taking the whole program/code-base into account at the linking stage, in the case of the GCC LTO'ing of the Linux kernel at least with the latest tests carried out by the kernel developers they weren't able to record much difference.

Beyond negligible performance differences in their tests, they also found the LTO'ed kernel to be larger due to more inlining happening.


In any event for those interested in these latest patches to LTO the kernel with the GCC compiler, they can be found on the kernel mailing list.
Related News
About The Author
Author picture

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