2
votes

I am writing c code on my laptop and I would like to cross compile it to ARM v7 architecture using the llvm-clang toolchain.

I am following this website http://llvm.org/docs/HowToCrossCompileLLVM.html using this command to configure cmake:

I am using the following command and getting the following errors (see below). Any idea what is wrong?

Thank you

-------------------------------START----------------------------------------------

cmake -G Ninja /home/user/Desktop/llvm/llvm -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=/home/user/Desktop/llvm/llvm/new_build -DLLVM_TABLEGEN=/usr/bin/host/llvm-tblgen -DCLANG_TABLEGEN=/usr/bin/host/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.2/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc'

------------------------------END-------------------------------------------------

Errors:

-------------------------------START----------------------------------------------

-- The CXX compiler identification is Clang 3.5.0 -- Check for working CXX compiler using: Ninja -- Check for working CXX compiler using: Ninja -- broken CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:54 (message): The C++ compiler "/usr/bin/clang++" is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/user/Desktop/llvm/llvm/new_build/CMakeFiles/CMakeTmp

Run Build Command:/usr/bin/ninja cmTryCompileExec1541562247

[1/2] Building CXX object

CMakeFiles/cmTryCompileExec1541562247.dir/testCXXCompiler.cxx.o

[2/2] Linking CXX executable cmTryCompileExec1541562247

FAILED: : && /usr/bin/clang++ -target armv7a-linux-gnueabihf

-mcpu=cortex-a9

-I/usr/arm-linux-gnueabihf/include/c++/4.7.2/arm-linux-gnueabihf/

-I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name

arm-linux-gnueabihf-gcc

CMakeFiles/cmTryCompileExec1541562247.dir/testCXXCompiler.cxx.o -o

cmTryCompileExec1541562247 -rdynamic && :

/usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi

Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om

elf_k1om i386pep i386pe

clang: error: linker command failed with exit code 1 (use -v to see

invocation)

ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.

Call Stack (most recent call first):

CMakeLists.txt:19 (project)

-- Configuring incomplete, errors occurred!

------------------------------END-------------------------------------------------

1

1 Answers

2
votes

You are using the wrong guide.

The web page you linked is a guide on how to cross-compile LLVM and Clang using LLVM and Clang. But you don't want to compile LLVM itself, you only want to use it. The guide for that is: http://clang.llvm.org/docs/CrossCompilation.html