[llvm-dev] ThinLTO: passing TargetOptions to LLVMgold.so
Mehdi Amini via llvm-dev
llvm-dev at lists.llvm.org
Thu Oct 6 09:31:21 PDT 2016
> On Oct 6, 2016, at 2:01 AM, Johan Engelen <jbc.engelen at gmail.com> wrote:
>
> On Wed, Oct 5, 2016 at 5:44 PM, Mehdi Amini <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>> wrote:
>
> > But some other options are not expressed in IR (e.g. FunctionSections, relocation model).
> > 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.
>
> The usual model is that the linker interacts with the LTO codegen to pass these options.
>
> My question is: how does the linker know what to tell the LTO codegen? ;)
Well the linker knows some stuff on what it is linking. In the link I sent:
- The first if depends a dynamic library or an executable
- The second branch is triggered by “-static" on the command line.
- The last one is the architecture we’re linking for.
> Assuming you’d link a program on MacOS with ThinLTO for instance, the linker will derive the “pic model” the following way: https://github.com/Apple-FOSS-Mirror/ld64/blob/master/src/ld/parsers/lto_file.cpp#L594 <https://github.com/Apple-FOSS-Mirror/ld64/blob/master/src/ld/parsers/lto_file.cpp#L594> (not the call to ::lto_codegen_set_pic_model).
>
> 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).
All the -mllvm options are really not intended to be a stable interface though.
—
Mehdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161006/f5074711/attachment.html>
More information about the llvm-dev
mailing list