Google Posts Patches So The Linux Kernel Can Be LTO-Optimized By Clang
Years ago Intel developers had sent out patches for LTO support for the Linux kernel but Linus Torvalds was ultimately unconvinced by it. That was back in 2014 when trying to squeeze more performance out of the Linux kernel. LTO patches for the Linux kernel are brought up every so often but at last check still no material progress in getting it mainlined.
Link-time optimizations allow for broader optimizations thanks to them being applied during the linking process rather than just optimizing individual object files. LTO is known for helping with execution speed thanks to being able to capture more aggressive optimizations and also helping in reducing code size by a measurable amount.
With this new patch series, Google's Sami Tolvanen sent out LTO kernel patches but this time for wiring it up for the LLVM Clang compiler rather than GCC.
In addition to the performance focus of LTO, the other motive for Google LTO'ing the kernel is for enabling Clang Control-Flow Integrity (CFI) in conjunction with LTO. Google has already been using LTO+CFI-enabled Linux kernel builds for their Google Pixel devices for two years. Given this Clang LTO+CFI enablement is already being used at scale in the many production devices from Google, this does stand better chances we could see this LTO functionality mainlined as likely by now any nasty issues would have already been crossed.
This patch series can be found on the kernel mailing list. No performance numbers were shared for a Clang LTO'ed Linux kernel but I will run some Phoronix benchmarks if it looks like these patches are going to get pulled for mainline.