[cfe-dev] How to compile Clang for ARM Linux on x86_64 Linux?

Anton Smirnov dev at antonsmirnov.name
Sat Sep 28 14:07:33 PDT 2013


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 at 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?



2013/9/29 Anton Smirnov <dev at antonsmirnov.name>

> 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?
>
>
> 2013/9/29 Renato Golin <renato.golin at linaro.org>
>
>> On 28 September 2013 20:55, Anton Smirnov <dev at antonsmirnov.name> wrote:
>>
>>> -- 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 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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130929/a0023f56/attachment.html>


More information about the cfe-dev mailing list