<div dir="ltr">Hi David,<div><br></div><div>That looks basically right, so I am not sure offhand what is wrong. Looks like this is the astar spec binary, so I will try to repro it tomorrow morning. What linker are you using?</div><div><br></div><div>Note that if your link involves archives of .a files, you will want to ensure that the final native link includes only those files selected by the linker. That is output in the file given to the "-Wl,-plugin-opt,thinlto-index-only=files.out" option. What we do is use that in combination with the '-Wl,-plugin-opt,<span class="m_7798277218057141552gmail-il">thinlto</span>-prefix-replace=path1;path2' option to simplify the final link invocation. Specifically, if you do something like:</div><div> "-Wl,-plugin-opt,<span class="m_7798277218057141552gmail-il">thinlto</span>-<span class="m_7798277218057141552gmail-il">index</span>-<span class="m_7798277218057141552gmail-il">only</span>=files.out -Wl,-plugin-opt,<span class="m_7798277218057141552gmail-il">thinlto</span>-prefix-replace=path1;path2"</div><div>for the indexing link step, the output files from the thin link will be written to a directory tree with the original path substring "path1" replaced with "path2", and the object names in the file emitted by thinlto-index-only= ("files.out" in the above example), will have their path names adjusted to the new path as well - if your native .o files use the new path then this is a simple way of getting a list of input files for the final link, which can be passed via @files.out to gold (note the gold manpage does not document "@" but the gnu ld manpage does).</div><div><br></div>I.e. something like:<br><br>clang++ -flto=thin -O3 -c -o path1/foo.o foo.cpp<div>...<br>clang++ -flto=thin -O3 -Wl,-plugin-opt,thinlto-index-only=files.out -Wl,-plugin-opt,<span class="m_7798277218057141552gmail-il">thinlto</span>-prefix-replace=path1;path2" foo.o ...</div><div>clang++ -c -x ir path1/foo.o -O3 -o path2/foo.o -fthinlto-index=path2/foo.o.thinlto.bc</div><div>...</div><div>clang++ -flto=thin -O3 -o a.out <a class="gmail_plusreply" id="m_7798277218057141552plusReplyChip-0">@files.out</a><br></div><div><div><br></div></div><div><br></div><div>But again, that should only come into play if you are linking archives of bitcode files...</div><div><br></div><div>Teresa</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 8, 2019 at 2:38 PM David Callahan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_7798277218057141552gmail-m_-3179742789606246467WordSection1">
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        I am trying to work through the usage of thinlto for distributed builds.<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">       <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        Here is the simple thinlto usage, just add -flto=thin everywhere, easy:<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o CreateWay_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else CreateWay_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Places_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Places_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o RegBounds_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else RegBounds_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o RegMng_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else RegMng_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Way2_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Way2_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o WayInit_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else WayInit_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Library.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Library.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Random.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Random.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Region_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Region_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o RegWay_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else RegWay_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Way_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Way_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -flto=thin -O3 -o astar.thin  CreateWay_.o Places_.o RegBounds_.o RegMng_.o Way2_.o WayInit_.o Library.o Random.o Region_.o RegWay_.o Way_.o<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        My understanding is for the distributed, you need to do the inital compiles as above,<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        then a special link to get the thinlto index files, then compile again to get<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        native files, and then a final link. This looks like the following but<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        it does not work:<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o CreateWay_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else CreateWay_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Places_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Places_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o RegBounds_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else RegBounds_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o RegMng_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else RegMng_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Way2_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Way2_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o WayInit_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else WayInit_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Library.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Library.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Random.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Random.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Region_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Region_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o RegWay_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else RegWay_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++  -flto=thin -O3 -c -o Way_.o -DSPEC_CPU -DNDEBUG -DSPEC_CPU_LITTLE_ENDIAN -Wno-dangling-else Way_.cpp<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -flto=thin -O3 -o thinlto.objects  <span style="background:yellow">
-Wl,-plugin-opt,thinlto-index-only=thinlto.objects</span> CreateWay_.o Places_.o RegBounds_.o RegMng_.o Way2_.o WayInit_.o Library.o Random.o Region_.o RegWay_.o Way_.o<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir CreateWay_.o -O3 -o CreateWay_-native.o -fthinlto-index=CreateWay_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir Places_.o -O3 -o Places_-native.o -fthinlto-index=Places_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir RegBounds_.o -O3 -o RegBounds_-native.o -fthinlto-index=RegBounds_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir RegMng_.o -O3 -o RegMng_-native.o -fthinlto-index=RegMng_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir Way2_.o -O3 -o Way2_-native.o -fthinlto-index=Way2_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir WayInit_.o -O3 -o WayInit_-native.o -fthinlto-index=WayInit_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir Library.o -O3 -o Library-native.o -fthinlto-index=Library.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir Random.o -O3 -o Random-native.o -fthinlto-index=Random.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir Region_.o -O3 -o Region_-native.o -fthinlto-index=Region_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir RegWay_.o -O3 -o RegWay_-native.o -fthinlto-index=RegWay_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -c -x ir Way_.o -O3 -o Way_-native.o -fthinlto-index=Way_.o.thinlto.bc<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang++ -o astar CreateWay_-native.o Places_-native.o RegBounds_-native.o RegMng_-native.o Way2_-native.o WayInit_-native.o Library-native.o Random-native.o Region_-native.o RegWay_-native.o Way_-native.o<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        <span style="background:aqua">
Library-native.o:(.data+0x0): undefined reference to `vtable for regwayobj'</span><u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        clang-8: error: linker command failed with exit code 1 (use -v to see invocation)<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        make: *** [astar] Error 1<u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">        Did I miss a step?         <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">     <u></u><u></u></p>
<p class="gmail-m_7798277218057141552gmail-m_-3179742789606246467MsoPlainText">    <u></u><u></u></p>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_7798277218057141552gmail_signature"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div>