How to compile Clang for ARM Linux on x86_64 Linux?

I’ve followed Clang doc to cross-compile Clang for ARM Linux machine (Android) on x86_64 ubuntu machine:

./configure --build=armv7l-unknown-linux-gnueabihf \
--host=armv7l-unknown-linux-gnueabihf \
--target=armv7l-unknown-linux-gnueabihf --with-cpu=cortex-a9 \
--with-float=hard --with-abi=aapcs-vfp --with-fpu=neon \
--enable-targets=arm --enable-optimized --enable-assertions --enable-static --disable-shared --prefix=/home/asmirnov/llvm_arm_build_static

Then i did make & make install (no errors) and found here is file libclang.so output:

asmirnov@vmb:~/llvm_arm_build_static$ cd ./Release+Asserts/lib
asmirnov@vmb:~/llvm_arm_build_static/Release+Asserts/lib$ file ./libclang.so
./libclang.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=0xabf77b97daef0b9a6669d291400ffa4b6c98695c, not stripped

Why is it i386? Why is it dynamically linked? How can i achieve my goal?

Hi Anton, that doc is how to compiler ON ARM, not TO ARM.

Here's the doc on how to cross-compile TO ARM:

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

I'll update that doc to make it clearer and point to the correct doc, just
in case.

cheers,
--renato

Hey. i've tried both options.
Unfortunately none of them works.
I will add detailed information below each of it.

Then configure and getting an error:
/usr/bin/c++ -target armv7a-linux-gnueabihf -mcpu=cortex-a9
  -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
  -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
  arm-linux-gnueabihf-gcc -o
  CMakeFiles/cmTryCompileExec1473115348.dir/testCXXCompiler.cxx.o -c
  /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

Yes, it's choosing the system compiler, which is clearly wrong.

Since you should have "arm-linux-gnueabihf-gcc" on your path, I believe
the CMake variable "LLVM_DEFAULT_TARGET_TRIPLE" doesn't work in the way I
thought it would, in which case you'd have to force CC and CXX. During my
examples, I was mainly using Clang to cross-compile, so I may have skipped
a few steps to compile with GCC, in which case I'll have to fix the docs
accordingly.

You have two options now:
1. Fully compile Clang+LLVM to your host platform and use "CC=clang
CXX=clang++ cmake ... " to configure your directory.

both clang and clang++ compiled for host are on path and working:

asmirnov@vmb:~/llvm_cmake_build$ CC=clang
asmirnov@vmb:~/llvm_cmake_build$ CXX=clang++
asmirnov@vmb:~/llvm_cmake_build$
PATH=/home/asmirnov/llvm_host_installed/bin:$PATH
asmirnov@vmb:~/llvm_cmake_build$ clang
clang: error: no input files
asmirnov@vmb:~/llvm_cmake_build$ clang++
clang: error: no input files
asmirnov@vmb:~/llvm_cmake_build$

But they are not able to configure using documented cmake:

asmirnov@vmb:~/llvm_cmake_build$ cmake ../llvm -DCMAKE_CROSSCOMPILING=True
-DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed
-DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen
-DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM
-DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS='-target
armv7a-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc'
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ --
broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54
(message):
  The C++ compiler "/usr/bin/arm-linux-gnueabihf-g++" is not able to compile
  a simple test program.

  It fails with the following output:

   Change Dir: /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp

  Run Build Command:/usr/bin/make "cmTryCompileExec3118678986/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec3118678986.dir/build.make
  CMakeFiles/cmTryCompileExec3118678986.dir/build

  make[1]: Entering directory
  `/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'

  /usr/bin/cmake -E cmake_progress_report
  /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building CXX object
  CMakeFiles/cmTryCompileExec3118678986.dir/testCXXCompiler.cxx.o

  /usr/bin/arm-linux-gnueabihf-g++ -target armv7a-linux-gnueabihf
  -mcpu=cortex-a9
  -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
  -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
  arm-linux-gnueabihf-gcc -o
  CMakeFiles/cmTryCompileExec3118678986.dir/testCXXCompiler.cxx.o -c
  /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

  arm-linux-gnueabihf-g++: error: unrecognized command line option
  ‘-target’

  arm-linux-gnueabihf-g++: error: armv7a-linux-gnueabihf: No such file or
  directory

  arm-linux-gnueabihf-g++: error: unrecognized command line option
  ‘-ccc-gcc-name’

  arm-linux-gnueabihf-g++: error: arm-linux-gnueabihf-gcc: No such file or
  directory

  make[1]: Leaving directory
  `/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'

  make[1]: ***
  [CMakeFiles/cmTryCompileExec3118678986.dir/testCXXCompiler.cxx.o] Error 1

  make: *** [cmTryCompileExec3118678986/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!

2. Use "CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ cmake ...
", and if that works, I'll update the docs to say it's required.

asmirnov@vmb:~/llvm_cmake_build$ CC=arm-linux-gnueabihf-gcc
asmirnov@vmb:~/llvm_cmake_build$ CXX=arm-linux-gnueabihf-g++
asmirnov@vmb:~/llvm_cmake_build$ cmake ../llvm -DCMAKE_CROSSCOMPILING=True
-DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed
-DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen
-DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM
-DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS='-target
armv7a-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc'
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ --
broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54
(message):
  The C++ compiler "/usr/bin/arm-linux-gnueabihf-g++" is not able to compile
  a simple test program.

  It fails with the following output:

   Change Dir: /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp

  Run Build Command:/usr/bin/make "cmTryCompileExec2487419787/fast"

  /usr/bin/make -f CMakeFiles/cmTryCompileExec2487419787.dir/build.make
  CMakeFiles/cmTryCompileExec2487419787.dir/build

  make[1]: Entering directory
  `/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'

  /usr/bin/cmake -E cmake_progress_report
  /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building CXX object
  CMakeFiles/cmTryCompileExec2487419787.dir/testCXXCompiler.cxx.o

  /usr/bin/arm-linux-gnueabihf-g++ -target armv7a-linux-gnueabihf
  -mcpu=cortex-a9
  -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
  -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
  arm-linux-gnueabihf-gcc -o
  CMakeFiles/cmTryCompileExec2487419787.dir/testCXXCompiler.cxx.o -c
  /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

  arm-linux-gnueabihf-g++: error: unrecognized command line option
  ‘-target’

  arm-linux-gnueabihf-g++: error: armv7a-linux-gnueabihf: No such file or
  directory

  arm-linux-gnueabihf-g++: error: unrecognized command line option
  ‘-ccc-gcc-name’

  arm-linux-gnueabihf-g++: error: arm-linux-gnueabihf-gcc: No such file or
  directory

  make[1]: Leaving directory
  `/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp'

  make[1]: ***
  [CMakeFiles/cmTryCompileExec2487419787.dir/testCXXCompiler.cxx.o] Error 1

  make: *** [cmTryCompileExec2487419787/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!

In both cases g++ is targeted to compile for ARM and of coarse it fails to
check compilation possibility for host (as far as i understand the output).
It seems that this checking should be skipped because cross compilation
flag is set. Or i don't understand why it fails indeed.

cheers,
--renato

Thanks for suggestions, Renato.
I understand that's a little difficult to fix it in such way, but i agree
to do all you suggest in order to compile clang for ARM finally.

Oh, no, you need to set them on the CMake line itself. And you may want to
export the PATH (it's not necessary, you can use the full path on the
CC/CXX variables):

$ export PATH=/home/asmirnov/llvm_host_installed/bin:$PATH
$ CC=clang CXX=clang++ cmake ../llvm -DCMAKE_CROSSCOMPILING=True
-DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed
-DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen
-DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM
-DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS='-target
armv7a-linux-gnueabihf -mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc'

cheers,
--renato

Hey.

Executing cc and cxx in command line did not change error output:

asmirnov@vmb:~/llvm_cmake_build$ export PATH=/home/asmirnov/llvm_host_installed/bin:$PATH
asmirnov@vmb:~/llvm_cmake_build$ CC=clang CXX=clang++ cmake …/llvm -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed -DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen -DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS=’-target armv7a-linux-gnueabihf -mcpu=cortex-a9 -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc’
– The CXX compiler identification is unknown
– Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
– Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ – broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler “/usr/bin/arm-linux-gnueabihf-g++” is not able to compile
a simple test program.

It fails with the following output:

Change Dir: /home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/make “cmTryCompileExec1026959458/fast”

/usr/bin/make -f CMakeFiles/cmTryCompileExec1026959458.dir/build.make
CMakeFiles/cmTryCompileExec1026959458.dir/build

make[1]: Entering directory
`/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp’

/usr/bin/cmake -E cmake_progress_report
/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/CMakeFiles 1

Building CXX object
CMakeFiles/cmTryCompileExec1026959458.dir/testCXXCompiler.cxx.o

/usr/bin/arm-linux-gnueabihf-g++ -target armv7a-linux-gnueabihf
-mcpu=cortex-a9
-I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/
-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name
arm-linux-gnueabihf-gcc -o
CMakeFiles/cmTryCompileExec1026959458.dir/testCXXCompiler.cxx.o -c
/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

arm-linux-gnueabihf-g++: error: unrecognized command line option
‘-target’

arm-linux-gnueabihf-g++: error: armv7a-linux-gnueabihf: No such file or
directory

arm-linux-gnueabihf-g++: error: unrecognized command line option
‘-ccc-gcc-name’

arm-linux-gnueabihf-g++: error: arm-linux-gnueabihf-gcc: No such file or
directory

make[1]: Leaving directory
`/home/asmirnov/llvm_cmake_build/CMakeFiles/CMakeTmp’

make[1]: ***
[CMakeFiles/cmTryCompileExec1026959458.dir/testCXXCompiler.cxx.o] Error 1

make: *** [cmTryCompileExec1026959458/fast] Error 2

CMake will not be able to correctly generate this project.

What can we do?

It looks like it didn't find clang++, but it did find clang, so maybe you
need the symlink from clang++ to clang there to make it work. It should be
there, no idea why it's not.

arm-linux-gnueabihf-g++ will not be able to compile a simple test program
because CMake will try to execute it and it won't run (it's ARM).

--renato

clang and clang++ are on path and i checked it running “clang” and “clang++”.
btw “clang++” is already symlinked to “clang”. Is there any cmake log that i can send to let you know more details?

Sorry for being misleading - i’ve tried to build from new build directory and configure succeed! Probably previous errors were affected by previous build errors. So CC and CXX were identified correctly (clang) and configuration succeed:

asmirnov@vmb:~/llvm_cmake_build2$ PATH=/home/asmirnov/llvm_host_installed/bin:$PATH CC=clang CXX=clang++ cmake …/llvm -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=/home/asmirnov/llvm_cmake_installed -DLLVM_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/llvm-tblgen -DCLANG_TABLEGEN=/home/asmirnov/llvm_host_build/Release+Asserts/bin/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS=’-target armv7a-linux-gnueabihf -mcpu=cortex-a9 -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc’

– Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
– Target triple: i686-pc-linux-gnu
– Native target architecture is ARM
– Threads enabled.
– Doxygen disabled.
– Building with -fPIC
– Constructing LLVMBuild project information
– Targeting ARM
– Clang version: 3.4
– Configuring done
– Generating done
– Build files have been written to: /home/asmirnov/llvm_cmake_build2

But make finished with error:

[ 7%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/InstrInfoEmitter.cpp.o
[ 7%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/IntrinsicEmitter.cpp.o
[ 7%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptParserEmitter.cpp.o
[ 7%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/PseudoLoweringEmitter.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/RegisterInfoEmitter.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/SetTheory.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/SubtargetEmitter.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/TGValueTypes.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/TableGen.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86DisassemblerTables.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86ModRMFilters.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86RecognizableInstr.cpp.o
[ 9%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CTagsEmitter.cpp.o
Linking CXX executable …/…/bin/llvm-tblgen
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)
…/…/lib/libLLVMSupport.a: could not read symbols: File in wrong format
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/llvm-tblgen] Error 1
make[1]: *** [utils/TableGen/CMakeFiles/llvm-tblgen.dir/all] Error 2
make: *** [all] Error 2

I’ve specified paths for tblgens for host system. Is it wrong?

No, that's correct, but it looks like your build directory is not clean.
CMake is not that smart, so complete removal and re-creation of the build
dir could fix that.

--renato

Since tblgen need host compile to be done I’ve decided to do everything from scratch.

mkdir & cd in new build folder

cmake …/llvm -DCMAKE_INSTALL_PREFIX=/Users/asmirnov/llvm_cmake_host_installed -DCMAKE_BUILD_TYPE=Release

make

make install

The first time i’ve used autotools to configure and make clang for host.

Now i decided to use cmake.

Now i don’t have clang-tblgen executable for some reason (it was while using autotools but i refused to use it due to previous attempt ld errors):
asmirnov@vmb:/Users/asmirnov/llvm_cmake_host_installed/bin$ find /Users/asmirnov/llvm_cmake_host_installed -name “*tblgen”
/Users/asmirnov/llvm_cmake_host_installed/bin/llvm-tblgen

Is it okay? Why while using cmake clang-tblgen was not done.

There were no errors while cmake or make.

Regards, Anton.

I’ve found both *tblgens in build folder, not in installed files folder.

Then i used the paths above for cross-compiling using cmake and received ld error: that i have previously received:
“relocations in generic elf” and finally “could not read symbols: file in wrong format” for libLLVMSupport.a file:

Linking CXX executable …/…/bin/llvm-tblgen
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)
…/…/lib/libLLVMSupport.a: could not read symbols: File in wrong format
clang-3.4: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/llvm-tblgen] Error 1
make[1]: *** [utils/TableGen/CMakeFiles/llvm-tblgen.dir/all] Error 2
make: *** [all] Error 2

The files exists.

What should i do?

It looks like it didn't find clang++, but it did find clang, so maybe you
need the symlink from clang++ to clang there to make it work. It should be
there, no idea why it's not.

arm-linux-gnueabihf-g++ will not be able to compile a simple test program
because CMake will try to execute it and it won't run (it's ARM).

cmake seems does not honor CC / CXX env. variables. The "hard way" to
specify C/C++ compiler there is via -DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++

Also, I remember that some versions of cmake had bug, where it used
clang as C compiler and something else as C++ compiler. Something like
http://www.cmake.org/Bug/view.php?id=13505

Not sure it is the reason - according to output clang and clang++ (symlinked to clang) is identified:

– The C compiler identification is Clang 3.4.0
– The CXX compiler identification is Clang 3.4.0
– Check for working C compiler: /home/asmirnov/llvm_installed/bin/clang
– Check for working C compiler: /home/asmirnov/llvm_installed/bin/clang – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working CXX compiler: /home/asmirnov/llvm_installed/bin/clang++
– Check for working CXX compiler: /home/asmirnov/llvm_installed/bin/clang++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Looking for C++ include cxxabi.h
– Looking for C++ include cxxabi.h - found

I have tried with -DCMAKE_C_COMPILER and -DCMAKE_CXX_COMPILER vars - the same error.

Can someone just compile clang for ARM and for x86 (not x86_64) linux (Android to be more detailed), link statically and strip? i will be very thankful.
It seems that a bunch of different unexpected problems…

i’ve unpacked libLLVMSupport.a file and object files inside are ELF 32-bit, ARM. So it seems .obj files are compiled for host correctly and packed to .a correctly.

ld is taken from correct toolchain:
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/…/…/…/…/arm-linux-gnueabihf/bin/ld: …/…/lib/libLLVMSupport.a(regcomp.c.o): Relocations in generic ELF (EM: 3)

Any thoughts?

I’ve found smth here (http://www.llvm.org/docs/HowToCrossCompileLLVM.html):

If you’re using Clang as the cross-compiler, there is a problem in the LLVM ARM back-end that is producing absolute relocations on position-independent code (R_ARM_THM_MOVW_ABS_NC), so for now, you should disable PIC:

-DLLVM_ENABLE_PIC=False

Does it relate to my problem?

I don't remember the particular manifestation, but it might be what's
causing your problem. Give it a try.

Also, tblgen binaries won't go into the installation directory, because
it's not meant to be distributed publicly, so you'll have to use the build
directory one, not the install.

cheers,
--renato

I don't remember the particular manifestation, but it might be what's
causing your problem.

Do you remember if there was a bug report about it?
R_ARM_THM_MOVW_ABS_NC didn't turn anything up in bugzilla.

Cheers.

Tim.

Hum.... I remember "wanting to create a bug", and even putting it down on
my TODO list, but I don't remember if I actually did it. :frowning:

I'll try to reproduce it again and will report.

cheers,
--renato

I’ve tried to make using cmake & ninja from scratch - the same linking error. Both configurations (host and target) were done with -DLLVM_ENABLE_PIC=False flag.

What can i do? Can some one compile it in his dev environment please?