[LLVMdev] compile linux kernel
dalej at apple.com
Sat Sep 27 17:16:47 PDT 2008
On Sep 27, 2008, at 4:34 PM, Ashish Bijlani wrote:
> Thanks for the help. I've a couple of questions though:
> How does LLVM deal with inline assembly?
It's been implemented piece by piece on an as-needed basis. At this
point most of the things people actually use should work. llvm-gcc
has seen the Linux kernel, so most usages in there ought to work.
The symptoms here look more like a preprocessor problem than an asm
problem. Your asm snippet works fine with llvm's top of tree, and I
suspect the real problem is something else. If you compile with -save-
temps what does the .i file look like?
> I'm trying to compile kernel and I get this error probably because
> LLVM is not able to handle inline assembly. I'm using LLVM-2.3
> code snippet from "arch/x86_64/kernel/asm-offsets.c"
> #define DEFINE(sym, val) \
> asm volatile("\n->" #sym " %0 " #val : : "i" (val))
> DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
> return 0;
> # make CROSS_COMPILE=llvm- V=1
> llvm-gcc -Wp,-MD,arch/x86_64/kernel/.syscall.o.d -nostdinc -isystem
> -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -emit-llvm
> -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
> -fno-common -Werror-implicit-function-declaration -O2 -mtune=generic
> -m64 -mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare
> -fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx
> -mno-sse2 -mno-3dnow -maccumulate-outgoing-args
> -fomit-frame-pointer -g -fno-stack-protector
> -Wdeclaration-after-statement -Wno-pointer-sign
> -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(syscall)"
> -D"KBUILD_MODNAME=KBUILD_STR(syscall)" -c -o
> arch/x86_64/kernel/.tmp_syscall.o arch/x86_64/kernel/syscall.c
> arch/x86_64/kernel/syscall.c:22: error: '__NR_syscall_max' undeclared
> here (not in a function)
> arch/x86_64/kernel/syscall.c:24: error: array index in initializer not
> of integer type
> arch/x86_64/kernel/syscall.c:24: error: (near initialization for
> In file included from arch/x86_64/kernel/syscall.c:25:
> include/asm-x86_64/unistd.h:16: error: array index in non-array
> include/asm-x86_64/unistd.h:16: error: (near initialization for
> include/asm-x86_64/unistd.h:18: error: array index in non-array
> Note that I use "-emit-llvm" option with llvm-gcc. Is this correct of
> am I missing something?
> How can I fix this error?
> On Sat, Sep 27, 2008 at 7:03 PM, Andrew Lenharth
> <andrewl at lenharth.org> wrote:
>> On Fri, Sep 26, 2008 at 9:19 PM, Ashish Bijlani
>> <ashish.bijlani at gmail.com> wrote:
>>> I'm trying to compile linux-22.214.171.124 with llvm-2.3. Is it at all
>> Yes, but it requires significant hacking, and the result for 2.6 is a
>> mostly bitcode kernel with a few userspace shared libraries linked in
>> as objcode (yes, the kernel builds .so files and includes them in the
>> binary). There are a few changes here and there you can make to the
>> kernel code to produce significantly nicer bitcodes too (e.g. rather
>> than having module level asm that makes symbols weak, you can just
>> have gcc do it).
>> The modification to the make system is not difficult, but it requires
>> some work and an understanding of the kernel build system.
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev