<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 8, 2013, at 5:42 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">On Mon, Jul 8, 2013 at 8:10 PM, Bill Wendling <span dir="ltr"><<a href="mailto:isanbard@gmail.com" target="_blank">isanbard@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "><div class="im">On Jul 8, 2013, at 4:54 PM, Chris Lattner <<a href="mailto:clattner@apple.com">clattner@apple.com</a>> wrote:<br>

<br>
> On Jul 8, 2013, at 4:23 PM, Bill Wendling <<a href="mailto:isanbard@gmail.com">isanbard@gmail.com</a>> wrote:<br>
><br>
>> Author: void<br>
>> Date: Mon Jul  8 18:23:03 2013<br>
>> New Revision: 185882<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=185882&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=185882&view=rev</a><br>
>> Log:<br>
>> Don't run internalize if we're outputing bit-code and not an object file.<br>
>><br>
>> The problem with running internalize before we're ready to output an object file<br>
>> is that it may change a 'weak' symbol into an internal one, but that symbol<br>
>> could be needed by an external object file --- e.g. with arclite.<br>
><br>
> I don't understand: how does output format affect symbol visibility?<br>
><br>
</div>If it changes a symbol from 'weak' to 'non-weak', then that symbol may be optimized away if the compiler thinks that it's no longer used. But if it's running 'ld -r', it doesn't know if the symbol can be optimized away because it doesn't have all of the source code available for it. Given this, it doesn't really make sense to run internalize before outputting a .bc file. That code hasn't gone through code generation yet, so the linker doesn't really know which of its symbols can be changed from 'weak' to 'non-weak'.<br>
</blockquote><div><br></div><div style="">ld -r seems really, really different from normal LTO. Is there some other flag to detect that?</div></div></div></div></blockquote><div><br></div><div>I'm not sure what you mean by an other flag. The LTO library shouldn't know that the linker is using '-r' or some other flag. If we step back a bit from the output format, this change is making the call conform to the documentation:</div><div><br></div><div><div>/// lto_codegen_write_merged_modules - Writes a new file at the specified path                                                                                                                   </div><div>/// that contains the merged contents of all modules added so far. Returns true                                                                                                                  </div><div>/// on error (check lto_get_error_message() for details).                                                                                                                                        </div><div>bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {</div><div>  return cg->writeMergedModules(path, sLastErrorString);</div><div>}</div><div><br></div><div>I would argue that running 'internalize' before writing the merged modules is against what the documentation is saying here (or at least against what I would expect given this comment).</div></div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div style="">Are there any other passes that LTO uses that assume it has all the code in the final image? </div></div></div></div></blockquote></div><div><br></div><div>Not in the same way that the internalize pass assumes that knowledge. The internalize pass is, of course, changing the visibility and sometimes the linkage of objects. Once that's done, then the other passes can rely upon the visibility and linkage to do the "correct thing". In other words, I don't think that we need to restrict other passes because of the 'ld -r' usage...</div><div><br></div><div>Does that answer your question? :-)</div><br><div>-bw</div><div><br></div></body></html>