<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 26 Jun 2017, at 16:25, Rui Ueyama <<a href="mailto:ruiu@google.com" class="">ruiu@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Sun, Jun 25, 2017 at 6:40 AM, Alessandro Pistocchi via llvm-dev<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class="">Hi,<div class=""><br class=""></div><div class="">I am trying to build a completely GNU free linux toolchain for the raspberry pi.<br class=""><div class=""><br class=""></div><div class="">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:</div><div class=""><br class=""></div><div class="">Llvm with clang and lld</div><div class="">Clang builtins</div><div class="">Musl libc</div><div class="">libc++, libc++abi, libunwind</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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.</div><div class="">For this reason I seem to have to use -fPIC in the C and CXX flags but everything seems to work ok.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Is this the same problem mentioned in<span class="Apple-converted-space"> </span><a href="https://bugs.llvm.org/show_bug.cgi?id=32425?" class="">https://bugs.llvm.org/show_bug.cgi?id=32425?</a><br class=""></div></div></div></div></div></blockquote><div><br class=""></div>My aim is to build llvm+clang+lld using llvm+clang+lld on arm ( using musl, libc++, libc++abi, libunwind and the clang builtins, no gcc runtime at all ).</div><div><div><br class=""></div><div>I think the fact that lld cannot preempt some symbols without using -fPIC is similar to the problem mentioned in <a href="https://bugs.llvm.org/show_bug.cgi?id=32425" class="">https://bugs.llvm.org/show_bug.cgi?id=32425</a> .</div><div><br class=""></div><div>However I am not particularly bothered at this stage about having to use -fPIC. That would be fine.</div><div><br class=""></div><div>What I am struggling with is that having to use -fPIC is in conflict with the arm backend issue that creates bad relocations when building clang with -fPIC as mentioned in <a href="http://llvm.org/docs/HowToCrossCompileLLVM.html" class="">http://llvm.org/docs/<wbr class="">HowToCrossCompileLLVM.html</a> and so the build with -fPIC fails when building the clang binary.</div><div><br class=""></div><div>Regarding <a href="https://bugs.llvm.org/show_bug.cgi?id=32425" class="">https://bugs.llvm.org/show_bug.cgi?id=32425</a> , please notice that contrary to what is reported there I definitely can build and execute a C hello world program without having to use -fPIC.</div><div><br class=""></div><div>It is only some symbols from musl that cannot be preempted by lld, not all of them.</div><div><br class=""></div><div>Unfortunately, when building llvm+clang+lld quite a few of those symbols are explicitly looked for by cmake and not found unless I use -fPIC.</div><div><br class=""></div><div>If I go ahead and build without using -fPIC then the build fails because it cannot preempt those symbols.</div><div><br class=""></div><div>It looks like a paradox to me and I think the solution would be to fix the fact that the arm backend does not like -fPIC as mentioned in <a href="http://llvm.org/docs/HowToCrossCompileLLVM.html" class="">http://llvm.org/docs/<wbr class="">HowToCrossCompileLLVM.html</a> . While it is probably correct that lld says it cannot preempt protected symbols, the arm backend issue is a known issue.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">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: <a href="http://llvm.org/docs/HowToCrossCompileLLVM.html" target="_blank" class="">http://llvm.org/docs/<wbr class="">HowToCrossCompileLLVM.html</a> .</div><div class="">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.</div><div class=""><br class=""></div><div class="">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?</div></div><div class=""><br class=""></div><div class="">Thank you,</div><div class="">Alex</div><div class=""><br class=""></div></div><br class="">______________________________<wbr class="">_________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a></blockquote></div></div></div></div></blockquote></div><br class=""></body></html>