<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Thanks</div>
<div><br>
</div>
<div>I had two small learnings. </div>
<div>1. Don’t name the output of llvm-link as a “.o” (the subsequent clang ignores it) </div>
<div>2. You need to have optimization flags like –O3 on the second clang, the on on the first is dropped.</div>
<div>But this did as I had hoped:</div>
<div><br>
</div>
<div>
<div>bin/clang -flto -O3 -c {a,b,c}.o</div>
<div>bin/llvm-link -o abc.bc {a,b,c}.o</div>
<div>bin/clang -O3 -o abc.o -c abc.bc</div>
<div>bin/clang -o test main.c abc.o</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span><<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>> on behalf of Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>><br>
<span style="font-weight:bold">Date: </span>Friday, December 4, 2015 at 4:27 PM<br>
<span style="font-weight:bold">To: </span>David Callahan <<a href="mailto:dcallahan@fb.com">dcallahan@fb.com</a>><br>
<span style="font-weight:bold">Cc: </span>LLVM Dev Mailing list <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [llvm-dev] LTO on libraries<br>
</div>
<div><br>
</div>
<div>
<div 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 Dec 4, 2015, at 4:12 PM, David Callahan <<a href="mailto:dcallahan@fb.com" class="">dcallahan@fb.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Thanks for the response.</div>
<div class="">To clarify in your suggestion, llvm-link will combine the modules but not run the optimization pass, that is still delayed until the final binary is built, correct?</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Yes.</div>
<div>You can use clang to generate a .o (as a real binary), that you can then wrap in an archive library.</div>
<div><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class=""><br class="">
</div>
<div class="">My use case is apply LTO to roughly program subsets; sacrificing effectiveness to avoid scaling problems and to allow the artifacts to be reused like archives and cached like .o’s.</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>You’re probably be interested in ThinLTO that is currently being implemented: scalability and incrementally are scheduled.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">I need to trigger the optimizer on the intermediate rather than defer to final link for these goals.</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Just run clang on the output of llvm-link :)</div>
<div><br class="">
</div>
<div>Note: you’re not having the same linker semantic with an archive containing one .o compared to an archive with multiple .o. So you need to be careful.</div>
<div><br class="">
</div>
<div>— </div>
<div>Mehdi</div>
<div><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class=""><br class="">
</div>
<div class="">—david</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<span id="OLK_SRC_BODY_SECTION" class="">
<div style="font-family: Calibri; font-size: 11pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-top-color: rgb(181, 196, 223);" class="">
<span style="font-weight:bold" class="">From: </span><<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>> on behalf of Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>><br class="">
<span style="font-weight:bold" class="">Date: </span>Friday, December 4, 2015 at 4:02 PM<br class="">
<span style="font-weight:bold" class="">To: </span>David Callahan <<a href="mailto:dcallahan@fb.com" class="">dcallahan@fb.com</a>><br class="">
<span style="font-weight:bold" class="">Cc: </span>LLVM Dev Mailing list <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class="">
<span style="font-weight:bold" class="">Subject: </span>Re: [llvm-dev] LTO on libraries<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Dec 4, 2015, at 3:54 PM, David Callahan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Hello,</div>
<div class=""><br class="">
</div>
<div class="">Is there a combination of the current tools would would allow me to apply LTO to a set of object files where are less than an entire application? Similar to “ld –r” for doing a partial link.</div>
<div class="">I assume it would start with “clang –flto –c {a,b,c}.c” but the a subsequent link step fails do to unresolved references of course.</div>
<div class="">Using llvm-link will linke the bitcode files but does not trigger compilation.</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">You can llvm-link and then run clang. Note that the result of LTO in this case is not as powerful as when it is linker driver, since you can’t internalize.</div>
<div class="">You may also want to look at llvm-lto, but it can be annoying because it requires (AFAIK) an export list.</div>
<div class=""><br class="">
</div>
<div class="">What is your use-case?</div>
<div class=""><br class="">
</div>
<div class="">— </div>
<div class="">Mehdi</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class=""><br class="">
</div>
<div class="">Thanks</div>
<div class="">david</div>
</div>
_______________________________________________<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="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=CwMF-g&c=5VD0RTtNlTh3ycd41b3MUw&r=lFyiPUrFdOHdaobP7i4hoA&m=vTfrtiCb9BO_em6D4lOQLhfgsFmoPI-bQA7aXuKAAdA&s=OPMnWwRmxskPv9ZQVVz4U6Zkxfni3nvdAa_RkyNe8WE&e=" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</span></div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</span>
</body>
</html>