[LLVMdev] Compile a linux kernel with LLVM?

Misha Brukman brukman at cs.uiuc.edu
Mon Jul 25 12:05:37 PDT 2005


On Mon, Jul 25, 2005 at 11:45:10AM -0500, John Criswell wrote:
> ymxia at nudt.edu.cn wrote:
> >When I compiled a linux kernel, gccas was used to compile assembly
> >code.
> >
> >But gccas cannot recognize the line comment character "#" of gnu
> >assembler, and abort the compile with reporting a error "syntax
> >error, unexpected $undefined".  I watch llvm/tools/gccas, but donot
> >known how to add this function in it. 
> >
> >Would you give me some suggestions?
> 
> This is occuring because you're trying to use gccas to compile a
> native code assembly file (most likely, an i386 assembly language
> file).
> 
> You either need to not to compile this file or write an LLVM
> equivalent of it.

Or use/write the C-equivalent of it. :)

Sometimes, the assembly version is just a faster version of generic
platform-independent C code, and even though it's protected by something
like #ifdef __i386, llvm-gcc may still be defining some of those flags if
it's being compiled on an x86 machine.  So in some cases, you need to
modify the kernel code to not compile asm version of function, e.g.

#if defined(__i386) && !defined(__llvm__)
  [ assembly code here ]
#else
  [ C code ]
#endif

To get a list of flags defined by llvm-gcc:

% touch /tmp/empty.c
% llvm-gcc -dM -E /tmp/empty.c

-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list