Patches released for GCC LTO optimizing the Linux kernel

Patches released for GCC LTO optimizing the Linux kernel

Since last year, when building the Linux kernel using LLVM’s Clang compiler, it was possible to enable binding time optimizations (LTO) for kernel build. Building the Linux kernel with GCC lacked LTO support, while a series of patches released today is the latest attempt to achieve this.

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

A decade ago 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 also expressed at the time that he was not convinced by LTO’ing the kernel. But now that we are nearing the end of 2022, there is another attempt at GCC LTO support for the kernel.

SUSE’s Jiri Slaby sent this round of GCC LTO support patches as an “first call for feedback” and is based in part on earlier patches by Andi Kleen as well as the work of fellow SUSE engineer Martin Liska.

While compiler link time optimizations are generally beneficial for performance due to the ability to perform optimizations taking into account the whole program/code base at the link stage, in the Linux kernel GCC LTO case at least with the latest tests done by the kernel developers, they couldn’t register much difference.

Beyond negligible performance differences in their tests, they also found that the LTO core was larger due to more inlining.

Anyway, for those interested in these latest fixes for LTO the kernel with the GCC compiler, they can be found on the core mailing list.

Leave a Comment

Your email address will not be published.