[LLVMdev] compile linux kernel

Ashish Bijlani ashish.bijlani at gmail.com
Fri Sep 26 19:19:59 PDT 2008


Hi,

I'm trying to compile linux-2.6.23.16 with llvm-2.3. Is it at all
possible? I get "Not an ELF" error. I pass "-emit-llvm" option to spit
LLVM IR, which can be JITed at runtime

$ make CROSS_COMPILE=llvm- CFLAGS="-O2 -emit-llvm"
Error: not ELF
make[2]: *** [scripts/mod/elfconfig.h] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2

using the verbose option -

$ make V=1 CROSS_COMPILE=llvm- CFLAGS="-O2 -emit-llvm"
/bin/bash scripts/checksyscalls.sh llvm-gcc
-Wp,-MD,./.missing-syscalls.d  -nostdinc -isystem
/home/ashish/llvm/llvm-gcc4.2-2.3.source/obj/../install/lib/gcc/x86_64-unknown-linux-gnu/4.2.1/include
-D__KERNEL__ -Iinclude  -include include/linux/autoconf.h -O2
-emit-llvm     -D"KBUILD_STR(s)=#s"
-D"KBUILD_BASENAME=KBUILD_STR(missing_syscalls)"
-D"KBUILD_MODNAME=KBUILD_STR(missing_syscalls)"
make -f scripts/Makefile.build obj=scripts
make -f scripts/Makefile.build obj=scripts/genksyms
make -f scripts/Makefile.build obj=scripts/mod
  scripts/mod/mk_elfconfig x86_64 < scripts/mod/empty.o >
scripts/mod/elfconfig.h
Error: not ELF
make[2]: *** [scripts/mod/elfconfig.h] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2


$cat scripts/Makefile.build
hostprogs-y	:= modpost mk_elfconfig
always		:= $(hostprogs-y) empty.o
modpost-objs	:= modpost.o file2alias.o sumversion.o
# dependencies on generated files need to be listed explicitly
$(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
quiet_cmd_elfconfig = MKELF   $@
      cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
	$(call if_changed,elfconfig)
targets += elfconfig.h


It seems like Makefile.build is trying to make an ELF file out of
scripts/mod/empty.o which has been compiled using LLVM to emit LLVM
code.

How to fix this? Am I missing something? Please help.

Thanks,
Ashish



More information about the llvm-dev mailing list