[LLVMdev] Compile a linux kernel with LLVM?
John Criswell
criswell at cs.uiuc.edu
Thu Jul 7 13:44:24 PDT 2005
ymxia at nudt.edu.cn wrote:
> Hi,
>
> I want to check some properties of linux kernel with llvm, but I don't know how to compile a
>
> linux kernel to an llvm's .bc file. I have let llvm's gcc front-end ignore inline assembly by
>
> modifying cfrontend/src/gcc/llvm-expand.c, and replace CC/as/ar in the Makefile of the kernel
>
> with llvm-gcc/llvm-as/llvm-ar. However, the linux's "make" reports errors: "File format not
>
> recognized" and "not ELF".
>
> Some people did this before?
I am currently working on a similar project (compiling Linux with the
LLVM compiler). However, my work modifies the inline assembly in the
kernel to use LLVM intrinsics (most of which have not been added to LLVM
yet).
First, make sure you change LD in the master Makefile to use gccld
(instead of the native linker, ld). The final linking of vmlinux uses
ld directly (which doesn't understand LLVM bytecode files). This needs
to be changed to use gccld.
Second, you may need to adjust the rules for the vmlinux target a little
bit. The gccld program will, given the -o <file> option, will create
file and file.bc, where file.bc is the actual bytecode file and file is
a script that runs lli on file.bc.
Third, if all you want to do is do program analysis on Linux, then all
you need to build is vmlinux.bc. It won't be necessary to build bzImage.
If the problem continues, just use gmake/make without the -s option so
that you can see what programs it is running. Chances are good that the
error is caused by running a native tool on an LLVM bytecode file;
looking at what gmake is doing will quickly tell you what program is
being run.
Just out of curiousity, what sort of analysis do you want to do on vmlinux?
-- John T.
>
> Thanks.
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
--
John T. Criswell
Research Programmer
University of Illinois at Urbana-Champaign
"It's today!" said Piglet. "My favorite day," said Pooh.
More information about the llvm-dev
mailing list