[llvm-dev] Building llvm with clang and lld on arm and the llvm arm backend relocation on position independent code

Alessandro Pistocchi via llvm-dev llvm-dev at lists.llvm.org
Sun Jun 25 06:40:02 PDT 2017


Hi,

I am trying to build a completely GNU free linux toolchain for the raspberry pi.

I successfully managed to compile llvm and clang for armv7 hard float ( both as a cross compiler and as a native compiler ) together with the following:

Llvm with clang and lld
Clang builtins
Musl libc
libc++, libc++abi, libunwind

All works well with the only thing to notice being the need to use -fPIC in order to access some library functions when my own c/c++ programs access those functions.

The fact seems to be that musl libc exports some symbols as protected ( probably correctly ) and lld ( probably correctly ) says it cannot preempt those symbols.
For this reason I seem to have to use -fPIC in the C and CXX flags but everything seems to work ok.

Then I tried to use this compiler ( both the cross compiler and the native compiler ) to compile llvm + clang + lld ( I want to have the toolchain built with itself, again without any GNU software involved ) but when building the clang executable I ran into the arm relocation problems mentioned here in the “Hacks” section when using -fPIC: http://llvm.org/docs/HowToCrossCompileLLVM.html <http://llvm.org/docs/HowToCrossCompileLLVM.html> .
On the other hand, I seem to need -fPIC otherwise cmake fails to find some libc functions such as futimes/futimens and many others. If I use -fPIC for CFLAGS but not for CXXFLAGS then cmake finds those symbols but then obviously fails at a later stage with lld unable to preempt those symbols.

This seems to be a conflict I cannot solve without someone within the llvm team fixing the arm relocation problem. Is there any estimate of when this could happen? I am happy to spend the time testing any solutions by building my own toolchain until it succeeds. Or is there any other solution?

Thank you,
Alex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170625/20e58fe9/attachment.html>


More information about the llvm-dev mailing list