<div dir="ltr"><div>Thanks!<br><br>Question about the final link step:</div><div><br></div><div>Do I provide all the object files to the link step, i.e. something like: <br>clang++ -o thinlto main-native.o lib/lib-native.o src/lib-native.o<br><br>Do I need to provide --start-lib markers on that final link step as well?</div><div dir="ltr"><br></div><div>Tanoy</div><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 18, 2019 at 10:37 AM Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</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 dir="ltr"><div dir="ltr">Hi Tanoy,<div><br></div><div>You can't use distributed ThinLTO with archives (thin or not), at least not today. The reason is that we need to be able to identify specific bitcode object files to import from in the backends, and that logic does not know how to deal with objects within archives. We do distributed ThinLTO in our builds but don't use .a files, rather, we use --start-lib/--end-lib around the files that would be in the same archive when performing the thin link. I.e. if you change your thin link to be:</div><div><br></div><div>clang++ -flto=thin -o index -O3  -Wl,-plugin-opt,thinlto-index-only=thinlto.objects -Wl,-plugin-opt,thinlto-emit-imports-files main.o --start-lib lib/lib.o src/lib.o --end-lib<br></div><div><br></div><div>things should work. </div><div><br></div><div>Note you also need to do the ThinLTO backend compile for each of the archive constituents anyway, e.g. something like:</div><div>  clang++ -c -x ir lib/lib.o -O3 -flto=thin -o lib/lib-native.o -fthinlto-index=lib/lib.o.thinlto.bc<br></div><div>etc</div><div><br></div><div>HTH,</div><div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 17, 2019 at 2:46 PM Tanoy Sinha 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 dir="ltr">I'm trying to run distributed ThinLTO without thin archives. <br>When I do, I get an error in the optimizer when clang tries to open a nonexistent file:<br><br>clang++ -flto=thin -Xclang -fno-lto-unit -O3 -c main.cpp -o main.o<br>clang++ -flto=thin -Xclang -fno-lto-unit -O3 -c lib/lib.cpp -o lib/lib.o<br>clang++ -flto=thin -Xclang -fno-lto-unit -O3 -c src/lib.cpp -o src/lib.o<br>llvm-ar -format gnu qcs lib.a lib/lib.o src/lib.o<br>clang++ -flto=thin -o index -O3  -Wl,-plugin-opt,thinlto-index-only=thinlto.objects -Wl,-plugin-opt,thinlto-emit-imports-files main.o lib.a<br>clang++ -c -x ir main.o -O3 -flto=thin -o main-native.o -fthinlto-index=main.o.thinlto.bc<br>Error loading imported file 'lib.a.llvm.2596.lib.cpp': No such file or directory<br><br>In this case, gold has registered the modules within my archive with ThinLTO. <br>The string "lib.a.llvm.2596.lib.cpp" is generated with the archive in question, plus an offset indicating where in the archive the particular object file is. <br>Unfortunately, when the optimizer tries to include the proper modules, <br>it's naively looking for a bitcode file with the name of the string provided, but there's obviously no "lib.a.llvm.2596.lib.cpp" for it to open.<br><br>Has anyone else tried to get clang to understand distributed ThinLTO when using non thin archives? <br>Is there some way to get clang to understand these out of the box?<br><br>I'm actually a little confused about the ".cpp" in "lib.a.llvm.2596.lib.cpp". <br>Seems like it should be a ".o"?<br><br>It didn't seem like there was anything out of the box that supported this. <br>I was looking at having clang actually read in the archive file and register the correct bitcode module. <br>I wanted to run it by the list to get some second opinions before I started that.<br></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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://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_-6123948428681749062gmail_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></div>
</blockquote></div></div>