CROSS COMPILING LLVM

How does one cross compile llvm ? When I attempt to cross compile I get :



configure: creating ./config.status
config.status: creating Makefile.common
config.status: executing setup commands
config.status: executing Makefile commands
config.status: executing lib/Makefile commands
config.status: executing lib/sample/Makefile commands
config.status: executing tools/Makefile commands
config.status: executing tools/sample/Makefile commands
checking build system type… i686-pc-linux-gnu
checking host system type… i686-pc-linux-gnu
checking target system type… i686-pc-linux-gnu
checking type of operating system we’re going to host on… Linux
checking target architecture… x86
checking for gcc… arm-none-linux-gnueabi-gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… configure: error: cannot run C compiled programs.
If you meant to cross compile, use --host'. See config.log’ for more details.

I configured as follows :

AS=arm-none-linux-gnueabi-as
AR=arm-none-linux-gnueabi-ar
CC=arm-none-linux-gnueabi-gcc
CXX=arm-none-linux-gnueabi-g++
LD=arm-none-linux-gnueabi-ld
NM=arm-none-linux-gnueabi-nm
OBJCOPY=arm-none-linux-gnueabi-objcopy
OBJDUMP=arm-none-linux-gnueabi-objdump
RANLIB=arm-none-linux-gnueabi-ranlib
READELF=arm-none-linux-gnueabi-readelf
SIZE=arm-none-linux-gnueabi-size
STRINGS=arm-none-linux-gnueabi-strings
STRIP=arm-none-linux-gnueabi-strips

llvm-2.5/configure
–with-llvmgccdir=/home/LLVM-2.5/llvm-gcc4.2-2.5-x86-linux-RHEL4
–enable-optimized
–enable-jit
–disable-threads
–enable-pic
–disable-shared
–with-pic \

    --prefix=/home/VIREMENT/src_virement/llvm \

–build=i686-pc-linux-gnu
–host=arm-linux-gnueabi

I am attaching config.log

config.log (234 KB)

DId you try reading this error message? ("--host" is an option to configure.)

-Eli

Hi,

I stumbled over this one too, recently.

hannibal hannibal wrote:

................................................
...............................................
configure: creating ./config.status
config.status: creating Makefile.common
config.status: executing setup commands
config.status: executing Makefile commands
config.status: executing lib/Makefile commands
config.status: executing lib/sample/Makefile commands
config.status: executing tools/Makefile commands
config.status: executing tools/sample/Makefile commands

AFIAK what is following is the configure in the BuildTools folder where
tablegen ant the like are built.

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking type of operating system we're going to host on... Linux
checking target architecture... x86
checking for gcc... arm-none-linux-gnueabi-gcc

As you see the only compiler it finds is the arm-cross-compiler, but not
the i686-pc-linux-gnu-compiler to build tablegen natively for the build
environment.

Its no use of setting the CC environment variable to the arm-compiler
since the whole build is using it. You have to have both (the system
compiler for i686-pc-linux-gnu and the cross compiler for
arm-none-linux-gnueabi on your path.

At the configure (with --host=ppc64-linux in this case) you get:

configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... powerpc64-unknown-linux-gnu
checking target system type... powerpc64-unknown-linux-gnu

Thats the proper systems.

checking type of operating system we're going to host on... Linux
checking target architecture... PowerPC
checking for ppc64-linux-gcc... ppc64-linux-gcc

So (in this case) the cross-compiler has to be named ppc64-linux-gcc

........
checking for gcc... gcc

And then its also checking for the native compiler to build the BuildTools.

So: puth both compilers (the native one and the cross-compiler) onto the
path and name the cross-compiler so configure finds it.

Andi

You can try cross-compiling with cmake if the traditional approach
doesn't work for you. Yesterday I tried mingw on Linux and it worked
fine (apart from a bug related to mingw's binutils that appears late on
the build process).

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

I’ve committed my scripts that simplify building Linux/x86 → Linux/ARM crosstool. There are 2 parts to using this:

  • llvm/utils/crosstool/create-snapshots.sh
    creates tarballs for LLVM and LLVM-GCC from HEAD SVN or a specific revision of your choice
  • llvm/utils/crosstool/ARM/build-install-linux.sh
    builds and installs a Linux/x86 → Linux/ARM crosstool using the snapshots generated by the above script. It also uses the CodeSourcery GCC-based cross toolchain to avoid having to rebuild cross-binutils and glibc, but if you don’t have it, it’ll tell you where to download it from.

Note that HEAD revision of SVN doesn’t work for me, but I listed the latest one I’ve tried that does, which is 70786.
Let me know if this approach works for you.

Thanks, this should be useful. What problem did you have with svn revisions after 70786?

I've committed my scripts that simplify building Linux/x86 -> Linux/ARM crosstool. There are 2 parts to using this:

* llvm/utils/crosstool/create-snapshots.sh
  creates tarballs for LLVM and LLVM-GCC from HEAD SVN or a specific revision of your choice
* llvm/utils/crosstool/ARM/build-install-linux.sh
  builds and installs a Linux/x86 -> Linux/ARM crosstool using the snapshots generated by the above script. It also uses the CodeSourcery GCC-based cross toolchain to avoid having to rebuild cross-binutils and glibc, but if you don't have it, it'll tell you where to download it from.

Just a note. CodeSourcery gcc tools is GPLv3. I think referencing the tools in a script is fine (except for those of us who are not allowed to even use them). But please never bring them into the llvm tree.

Thanks,

Evan

2009/6/12 Bob Wilson <bob.wilson@apple.com>

Thanks, this should be useful. What problem did you have with svn

revisions after 70786?

/tmp/llvm-project.p28262/obj/llvm-gcc-4.2/./gcc/xgcc -B/tmp/llvm-project.p28262/obj/llvm-gcc-4.2/./gcc/ -B/tmp/llvm-73246/llvm-project/x86_64-unknown-linux-gnu/arm-none-linux-gnueabi/llvm-gcc-4.2/arm-none-linux-gnueabi/bin/ -B/tmp/llvm-73246/llvm-project/x86_64-unknown-linux-gnu/arm-none-linux-gnueabi/llvm-gcc-4.2/arm-none-linux-gnueabi/lib/ -isystem /tmp/llvm-73246/llvm-project/x86_64-unknown-linux-gnu/arm-none-linux-gnueabi/llvm-gcc-4.2/arm-none-linux-gnueabi/include -isystem /tmp/llvm-73246/llvm-project/x86_64-unknown-linux-gnu/arm-none-linux-gnueabi/llvm-gcc-4.2/arm-none-linux-gnueabi/sys-include -DHAVE_CONFIG_H -I. -I/tmp/llvm-project.p28262/src/llvm-gcc-4.2/libmudflap -I. -Wall -ffunction-sections -fdata-sections -O2 -g -O2 -MT mf-heuristics.lo -MD -MP -MF .deps/mf-heuristics.Tpo -c /tmp/llvm-project.p28262/src/llvm-gcc-4.2/libmudflap/mf-heuristics.c -fPIC -DPIC -o .libs/mf-heuristics.o
cc1: /tmp/llvm-project.p28262/src/llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:134: llvm::LiveInterval& llvm::LiveIntervals::getInterval(unsigned int): Assertion I != r2iMap_.end() && "Interval does not exist for register"' failed. /tmp/llvm-project.p28262/src/llvm-gcc-4.2/libmudflap/mf-heuristics.c:175: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. See <URL:[http://llvm.org/bugs/](http://llvm.org/bugs/)> for instructions. make[4]: *** [mf-heuristics.lo] Error 1 make[4]: Leaving directory /tmp/llvm-project.p28262/obj/llvm-gcc-4.2/arm-none-linux-gnueabi/libmudflap’

I don’t have my build tree any longer that has the intermediate object files, so I’ll try to re-create it so I can disect the .bc file to figure out what’s wrong here.

Misha,

I reported this about 10 days ago and Evan has fixed this problem.
http://llvm.org/bugs/show_bug.cgi?id=4416. I was able to build llvm
cross compiler a couple of days with no problem.

Bharadwaj