[llvmlinux] build and link .bc kernel

Ghitulete Razvan razvan.ghitulete at gmail.com
Mon Nov 25 23:00:19 UTC 2013

Hi Cristi,

I've actually been working on this or some time now. You cannot
actually compile the Linux kernel out of the box with the -flto flag.
Andi Kleen has been working on getting the kernel to compile with flto
on gcc, but his patches have not been merged in the mainstream. His
repository is at [1]. And it should compile with GCC with no problems
at all.

You can tweak the llvmlinux makefile and replace the mainstream Linux
repo with that one. There are also some more additional challenges
along the way with modifying the kernel scripts to acknowledge .bc
files instead of ELF. It also depends whether you want to have the
vmlinux in .bc format or just individual modules. For the latter you
should be able to do so by also replacing ld with the gold linker. I
am still looking into how to get a vmlinux.bc file (that will also
boot :) )

P.S.: I have actually been working on the x86, but it should be pretty
identical, except the booting part which I am not sure works fully for

[1] https://github.com/andikleen/linux-misc/tree/lto-3.12

Razvan Ghitulete

More information about the LLVMLinux mailing list