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

Anton Smirnov dev at antonsmirnov.name
Sun Sep 29 23:29:44 PDT 2013


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?


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

> 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?
>
>
> 2013/9/29 Anton Smirnov <dev at antonsmirnov.name>
>
>> 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..
>>
>>
>> 2013/9/29 Anton Smirnov <dev at antonsmirnov.name>
>>
>>> 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.
>>>
>>>
>>> 2013/9/29 Anton Korobeynikov <anton at korobeynikov.info>
>>>
>>>> > 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
>>>> --
>>>> With best regards, Anton Korobeynikov
>>>> Faculty of Mathematics and Mechanics, Saint Petersburg State University
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130930/d1d519b8/attachment.html>


More information about the cfe-dev mailing list