<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 5, 2016 at 5:44 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> But some other options are not expressed in IR (e.g. FunctionSections, relocation model).<br>
> I see that I can pass LLVM options to the plugin, so one way is to pass all non-default options as plugin-opt cmdline flags. I can't find code in Clang that does that though.<br>
<br>
</span>The usual model is that the linker interacts with the LTO codegen to pass these options.<br></blockquote><div><br></div><div>My question is: how does the linker know what to tell the LTO codegen? ;)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Assuming you’d link a program on MacOS with ThinLTO for instance, the linker will derive the “pic model” the following way: <a href="https://github.com/Apple-FOSS-Mirror/ld64/blob/master/src/ld/parsers/lto_file.cpp#L594" rel="noreferrer" target="_blank">https://github.com/Apple-FOSS-<wbr>Mirror/ld64/blob/master/src/<wbr>ld/parsers/lto_file.cpp#L594</a> (not the call to ::lto_codegen_set_pic_model).<br></blockquote><div><br></div><div>Thanks a lot for the pointer. (didn't even realize that `ld64` source is so easily available) This lead me to where `ld64` receives the options, so I can browse through that to see what it accepts (it accepts `-mllvm` so that's nice).</div><div> </div><div>-Johan</div><div><br></div></div></div></div>