[llvmlinux] build and link .bc kernel

Cristian Zamfir cristian.zamfir at epfl.ch
Tue Nov 26 00:54:36 UTC 2013

On Tue, Nov 26, 2013 at 12:00 AM, Ghitulete Razvan
<razvan.ghitulete at gmail.com> wrote:
> 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.

Thanks, it is encouraging.

> 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.

I do not really understand why these are necessary. Aren't .bc files
produced with --emit-llvm a byproduct and nothing should theoretically
change? The final outcome should be  an x86* image + a vmlinux.bc +
.bc files for the modules.

We have been using the Cloud9 scripts to build various user space programs:
This worked quite well in the past, so I was thinking I could adapt
them to work with llvmlinux.

> 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 :) )

How do you want to boot the .bc file, in an LLVM interpreter?


> 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
> x86_64.
> [1] https://github.com/andikleen/linux-misc/tree/lto-3.12
> --
> Sincerely,
> Razvan Ghitulete
> _______________________________________________
> LLVMLinux mailing list
> LLVMLinux at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/llvmlinux

More information about the LLVMLinux mailing list