[LLVMdev] Fwd: JIT on ARM

Martins Mozeiko 49640f8a at gmail.com
Tue Jan 19 07:07:38 PST 2010


I found out that even calling functions that are defined inside LLVM bitcode doesn't work.
So following C code when compiled without any optimizations also crashes with JIT when main function is called (with optimizations function call is optimized away, of course).

***
static int fun(int x) { return x + 1; }
int main()
{
  return fun(30);
}
***

Is there some special conditions on ARM I need to check for LLVM call functions correctly?

--
Martins Mozeiko



Begin forwarded message:

> From: Martins Mozeiko <49640f8a at gmail.com>
> Date: September 25, 2009 12:04:04 GMT+03:00
> To: llvmdev at cs.uiuc.edu
> Subject: JIT on ARM
> 
> Hello.
> 
> My goal is to use LLVM with JIT compiler for ARM on Android device.
> 
> Currently I have successfully built and executed LLVM bitcode with interpreter on Android. Speed is not so great, that is why I want to use JIT.
> I tried building bitcode on windows with llvm-gcc that is provided on llvm home page. Resulting bitcode runs great in interpreter, but it doesn't use JIT. From what I understand from LLVM that it is because of target triple or datalayout. On PC in my case target triple is "i386-mingw32", but LLVM JIT for ARM expects something that starts with "armv" or "thumb". Also datalayout differs a lot. If I understand correctly that is because bitcode actually contains some of platform specific optimizations (like integer endianness), so I can't simply change target triple string and everything will run.
> 
> What I am now doing, is - I am trying to build gcc from gcc-4.2-llvm-2.5 sources with following configure line in cygwin shell:
> 
> ../llvm-gcc4.2-2.4.source/configure --enable-languages=c,c++ --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-bootstrap --disable-multilib --disable-nls --target=arm-eabi
> 
> My undertanding is that this will produce llvm-gcc compiler that will output LLVM bitcode with target triple that starts with "arm", so LLVM will use JIT on it.
> 
> Currently I am getting compile problems when running make (see below).
> Has anyone done something similar and can explain what I am doing wrong, or how should it be done in some other way to get JIT compiler running on ARM?
> 
> 
> make[2]: Entering directory `/cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc'
> gcc   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute -fno-common   -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/gengtype.exe \
>            build/gengtype.o build/gengtype-lex.o build/gengtype-yacc.o build/errors.o ../build-i686-pc-cygwin/libiberty/libiberty.a
> build/gengtype.o: In function `adjust_field_type':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:763: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:771: undefined reference to `_lexer_line'
> build/gengtype.o: In function `adjust_field_tree_exp':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:713: undefined reference to `_lexer_line'
> build/gengtype.o: In function `adjust_field_rtx_def':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:488: undefined reference to `_lexer_line'
> build/gengtype.o: In function `adjust_field_type':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:785: undefined reference to `_lexer_line'
> build/gengtype.o:/cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:725: more undefined references to `_lexer_line' follow
> build/gengtype.o: In function `main':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:3070: undefined reference to `_parse_file'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype.c:3070: undefined reference to `_parse_file'
> build/gengtype-yacc.o: In function `yyparse':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:73: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:75: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:76: undefined reference to `_lexer_toplevel_done'
> build/gengtype-yacc.o: In function `yyparse':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/gengtype-yacc.c:1873: undefined reference to `_yyerror'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/gengtype-yacc.c:1379: undefined reference to `_yylex'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/gengtype-yacc.c:1877: undefined reference to `_yyerror'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/gengtype-yacc.c:1995: undefined reference to `_yyerror'
> build/gengtype-yacc.o: In function `yyparse':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:122: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:110: undefined reference to `_lexer_toplevel_done'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:102: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:97: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:92: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:239: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:235: undefined reference to `_lexer_line'
> build/gengtype-yacc.o:/cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:231: more undefined references to `_lexer_line' follow
> build/gengtype-yacc.o: In function `yyparse':
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:84: undefined reference to `_lexer_toplevel_done'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:203: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:203: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:176: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:176: undefined reference to `_lexer_line'
> /cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:165: undefined reference to `_lexer_line'
> build/gengtype-yacc.o:/cygdrive/r/android/llvm/llvm-gcc4.2-objects/gcc/../../llvm-gcc4.2-2.4.source/gcc/gengtype-yacc.y:165: more undefined references to `_lexer_line' follow
> collect2: ld returned 1 exit status
> make[2]: *** [build/gengtype.exe] Error 1
> 
> --
> Martins Mozeiko
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100119/0db6dab6/attachment.html>


More information about the llvm-dev mailing list