How to Cross compile llvm to ARM ?

Hi, all

I want to compile llvm for arm board , running llvm on Devkit8000

cross-compiler : arm-2008q3 (arm-none-linux-gnueabi)

below is my configure:

…/llvm-2.9/configure --with-llvmgccdir=/home/poki/hybridQ/llvm/llvm-gcc/llvm-gcc-4.2-2.9-i686-linux
–enable-optimized
–enable-jit
–disable-threads
–enable-pic
–disable-shared
–with-pic
–prefix=/home/poki/hybridQ/llvm/temp_install
–build=i686-pc-linux-gnu
–host=arm-none-linux-gnueabi
–target=arm-none-linux-gnueabi

I’m not familiar with llvm.
Is there an error about mu configure?

then make -j4 //it’s ok
make install //error

error message:

strip: Unable to recognise the format of the input file /home/poki/hybridQ/llvm/temp_install/bin/tblgen' /usr/bin/install: strip process terminated abnormally make[2]: *** [/home/poki/hybridQ/llvm/temp_install/bin/tblgen] Error 1 make[2]: Leaving directory /home/poki/hybridQ/llvm/bbuild/utils/TableGen’
make[1]: *** [TableGen/.makeinstall] Error 2
make[1]: Leaving directory `/home/poki/hybridQ/llvm/bbuild/utils’
make: *** [install] Error 1

Regards,

Poki

This is actually not well working yet AFAIK.

There are a few issues with ELF/MC/.o that needs fixing on 2.9.
What I suggest you do is just create an x86 llvm (as per normal) and
use that llvm/llc to create the object files for ARM using
-mtriple=amv7-linux-gnueabi (for example when invoking llc).

Note that -g and Thumb2 is not yet supported AFAIK on ARM/ELF on 2.9
(MachO is much better supported I hink)
There are a few patches that I will push in to address some of these
issues on tip-of-tree but this will unfortunately not be helpful for
2.9

Sorry!
-jason

This is actually not well working yet AFAIK.

  I saw there is a buildbot for llvm-arm-linux on
    http://google1.osuosl.org:8011/one_box_per_builder

  How do it compile LLVM for ARM? Not using cross-compile?

Regards,
chenwj

IIRC, that configuration is actually compiling natively on ARM.

Granted, cross-compiling is supposed to work... although it's not a
very common configuration. As for your particular issue, you could
try passing "KEEP_SYMBOLS=1" to make as a workaround.

-Eli

Hi, Jason

  I guess Poki want to build LLVM for ARM and use LLVM library to
do something, not just using LLVM to compile ARM binary.

Regards,
chenwj

陳韋任 <chenwj@iis.sinica.edu.tw> writes:

This is actually not well working yet AFAIK.

  I saw there is a buildbot for llvm-arm-linux on
    http://google1.osuosl.org:8011/one_box_per_builder

  How do it compile LLVM for ARM? Not using cross-compile?

If the problem lies on LLVM's makefiles, you can try cross compiling
with cmake:

http://www.llvm.org/docs/CMake.html#cross

It used to work for cross compiling to Windows (MinGW).

Hi, Jason

I guess Poki want to build LLVM for ARM and use LLVM library to
do something, not just using LLVM to compile ARM binary.

Setting up a cross compile system is always more complicated than
compiling natively.
It is possible to do so (we do it here locally for PNaCl project, for
example, going from X86 to ARM),
but it requires setup for things like llvm-gcc, the target libc and
other target libraries you are linking against...
not to mention a cross compiling binutils, and its irritating to get "right"

It might be easiest to buy a cheap ARM box and compile natively using ARM gcc...

-jason

Hi all

I want to cross compile llvm for arm architecture on Devkit8000.

ARM toolchain: arm-2011.03
LLVM: llvm-2.9
binutils: binutils-2.21

The following is my approach:

  1. install binutils- 2.21
    put binutils to llvm src directory
    ./configure --target=arm-linux
    –prefix=/path/llvm-src/arm
    –disable-optimized
    –enable-bindings=none
    –disable-multilib --disable-bootstrap
    –with-sysroot=/path/llvm/arms/sys-root
    –with-binutils-include=/path/llvm/binutils-2.21/include
    –with-llvmgccdir=/path/llvm/llvm-gcc-4.2

make
make install

2.install LLVM
…/llvm-2.9/configure --target=arm-none-linux-gnueabi
–host=arm-none-linux-gnueabi
–prefix=/path/llvm/install
–disable-optimized
–enable-bindings=none
–disable-multilib
–disable-bootstrap
–with-sysroot=/path/llvm/arms/sys-root
–with-binutils-include=/path/llvm/binutils-2.21/include
–with-llvmgccdir=/path/llvm/llvm-gcc/llvm-gcc-4.2-2.9-i686-linux
CFLAGS = ‘-static’

make
make install

done !

Regards,
Poki

2011/5/10 李柏舉 <poki.gzca@gmail.com>

Hi Jason,

I agree it's more difficult, what I don't agree is that it's ok to be
more difficult... :wink:

James sent a patch to fix some issues on selecting the target
(march/mcpu/mos) that should get most of it done until link time
simply by running vanilla clang/LLVM (no need for the
soon-to-be-deprecated llvm-gcc).

Also, while the ELF writer is good enough for some basic code, it has
problems with more complex C++ code, so one might need GAS to get
there, but that's easy to fix (and you have been doing a good job at
it).

The main problem are the libraries and the linker, and that's an area
that has been barely touched so far... But for that, if you just
download CodeSourcery's pack, you should be fine. So, all in all, not
that hard. :wink:

cheers,
--renato

Hi,

--with-llvmgccdir=/path/llvm/llvm-gcc/llvm-gcc-4.2-2.9-i686-linux
                                             CFLAGS = '-static'

                                                         ^^^^^^^
   Have trouble with dynamic linking?

   BTW, can someone make this a HOWTO on the LLVM website?

Regards,
chenwj