<div dir="ltr">*nod* You might want to try top of tree.<br><br>-eric<br></div><br><div class="gmail_quote">On Thu Jan 29 2015 at 11:44:55 AM Kristof Beyls <<a href="mailto:kristof.beyls@arm.com">kristof.beyls@arm.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Eric,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I’ve experimented a bit with a *<b>very</b>* simple program using a TLS variable.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It seems to me that in binutils 2.25, ld.bfd supports non-PIC compiled code and ld.gold support PIC-compiled code.<br>But neither supports both PIC and non-PIC compiled TLS variables.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">For details of my experiments, see below.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">$ cat t3.cpp<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">static volatile thread_local int tls_i;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter""><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">int main() {<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">  tls_i = 4;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">  return tls_i;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">}<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter""># Works with g++ 4.9.1:<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">$ g++ -O3 -std=c++11 -o t3_g++-4.9.1_O3 t3.cpp<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter""># breaks with clang++-3.5 in combination with gold 2.25:<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">$ clang++-3.5 -O3 -std=c++11 -o t3_clang++-3.5_O3 t3.cpp -Wl,-v<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">GNU gold (GNU Binutils for Debian 2.25) 1.11<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">/usr/bin/ld: error: /tmp/t3-4c39c0.o: unsupported reloc 545 against local symbol<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">/usr/bin/ld: error: /tmp/t3-4c39c0.o: unsupported reloc 548 against local symbol<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">/tmp/t3-4c39c0.o:t3.cpp:function main: error: cannot relocate invalid reloc 545 in object file<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">/tmp/t3-4c39c0.o:t3.cpp:function main: error: cannot relocate invalid reloc 548 in object file<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">clang: error: linker command failed with exit code 1 (use -v to see invocation)<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter""># works with clang++-3.5 and ld.bfd 2.25:<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">$ clang++-3.5 -O3 -std=c++11 -o t3_clang++-3.5_O3 t3.cpp -Wl,-v -fuse-ld=bfd<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">GNU ld (GNU Binutils for Debian) 2.25<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">llvm-test@llvm-farm-juno-5:~/kristof$ ./t3_clang++-3.5_O3; echo $?<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">4<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter""># SUMMARY: so far, gold doesn’t support some TLS relocations that clang produces.<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter""># Try another example to show the problem with ld.bfd, on relocation 0x20c=524=R_AARCH64_TLSLD_MOVW_DTPREL_G1:<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">clang++-3.5 -fPIC -O3 -std=c++11 -o t3_clang++-3.5_O3 t3.cpp -Wl,-v -fuse-ld=bfd<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">GNU ld (GNU Binutils for Debian) 2.25<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">/usr/bin/ld.bfd: /tmp/t3-3b0353.o: unrecognized relocation (0x20c) in section `.text'<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">/usr/bin/ld.bfd: final link failed: Bad value<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">clang: error: linker command failed with exit code 1 (use -v to see invocation)<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">llvm-test@llvm-farm-juno-5:~/kristof$ clang++-3.5 -fPIC -O3 -std=c++11 -o t3_clang++-3.5_O3 t3.cpp -Wl,-v<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:"Lucida Sans Typewriter"">GNU gold (GNU Binutils for Debian 2.25) 1.11<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Eric Christopher [mailto:<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>] <br><b>Sent:</b> 29 January 2015 19:38<br><b>To:</b> Kristof Beyls; Chandler Carruth; Hans Wennborg; <a href="mailto:jingyu@google.com" target="_blank">jingyu@google.com</a></span></p></div></div></div></div></div><div lang="EN-GB" link="blue" vlink="purple"><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""><br><b>Cc:</b> Commit Messages and Patches for LLVM<br><b>Subject:</b> Re: [llvm] r227411 - [LPM] Clean up the use of TLS in pretty stack trace and disable it<u></u><u></u></span></p></div></div></div></div></div><div lang="EN-GB" link="blue" vlink="purple"><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Hi Kristof,<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I know Jing (on this email) was working on gold tls relocations when I noticed this a while back. I'm pretty sure she implemented them (at least I can link now), but I'm not sure how well it's working. Can you confirm or elaborate more?<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">-eric<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Thu Jan 29 2015 at 11:25:23 AM Kristof Beyls <<a href="mailto:kristof.beyls@arm.com" target="_blank">kristof.beyls@arm.com</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">For AArch64, clang produces relocations for TLS variables that ld.bfd or ld.gold can’t handle.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It seems that gcc, ld and gas only support the “small memory model 16Mib TLS address model”,<br>and AFAIK, it may take a while for these to grow support for other address models.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I haven’t had time to come fully up to speed on this, but at the moment, the only workable<br>solution I can think of is to:</span><u></u><u></u></p><p><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d">·</span><span style="font-size:7.0pt;color:#1f497d">         </span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Not use thread_local variables in LLVM for the 3.6 release on AArch64, so that clang 3.6<br>can bootstrap itself on AArch64-linux.</span><u></u><u></u></p><p><span style="font-size:11.0pt;font-family:Symbol;color:#1f497d">·</span><span style="font-size:7.0pt;color:#1f497d">         </span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">On trunk, let clang targeting AArch64-ELF systems only produce the relocations that ld supports.<br>At first sight that seems possible, but I’m not sure.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Does anyone have a better set of suggestions than the above?</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Kristof</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a>] <b>On Behalf Of </b>Chandler Carruth<br><b>Sent:</b> 29 January 2015 18:59<br><b>To:</b> Hans Wennborg<br><b>Cc:</b> Commit Messages and Patches for LLVM<br><b>Subject:</b> Re: [llvm] r227411 - [LPM] Clean up the use of TLS in pretty stack trace and disable it</span><u></u><u></u></p></div></div></div></div></div><div><div><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><p class="MsoNormal"> <u></u><u></u></p><p>I'm still waiting for some of the dust to settle with ppc and arm. I'll have a list before long and can help merge.<u></u><u></u></p><div><p class="MsoNormal">On Jan 29, 2015 9:50 AM, "Hans Wennborg" <<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>> wrote:<u></u><u></u></p><p class="MsoNormal">On Wed, Jan 28, 2015 at 5:23 PM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>> wrote:<br>> Author: chandlerc<br>> Date: Wed Jan 28 19:23:04 2015<br>> New Revision: 227411<br>><br>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227411&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227411&view=rev</a><br>> Log:<br>> [LPM] Clean up the use of TLS in pretty stack trace and disable it<br>> entirely when threads are not enabled. This should allow anyone who<br>> needs to bootstrap or cope with a host loader without TLS support to<br>> limp along without threading support.<br><br>I assume we want this (and r227412) for the 3.6 branch. Any others?<br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><u></u><u></u></p></div></div></div></div><p class="MsoNormal">_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><u></u><u></u></p></div></div></div></div></div></div></blockquote></div>