Alternative to Linker::LinkInFile()

Hi Daniel,

In r172749 you removed the Linker::LinkInFiles() function and mentioned
in the commit message that users of this function should migrate to
"platform-specific linker-integrated LTO mechanisms, or the forthcoming
LLVM linker."

I'm trying to update this code:
http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/state_trackers/clover/llvm/invocation.cpp
to work with TOT and I was wondering if you could elaborate a little more
on these alternatives and maybe provide an example?

Thanks,
Tom

Hi Tom,

From the context I am assuming you are in a JIT context, so the comments about using a platform specific LTO mechanism don’t apply.

Were you using this code to extract bitcode files from archives, or just to link in an individual bitcode file?

  • Daniel

Hi Tom,

From the context I am assuming you are in a JIT context, so the comments
about using a platform specific LTO mechanism don't apply.

Were you using this code to extract bitcode files from archives, or just to
link in an individual bitcode file?

Hi Daniel,

I was using this code to link an individual bitcode file. I would
compile and OpenCL C kernel to bitcode and then link it with an OpenCL C
builtin library which was also a bitcode file.

-Tom

Looking at /tools/llvm-link/llvm-link.cpp may give you some ideas here. I havent looked at your specific use case, but llvm-link uses ParseIRFile to pull in a bitcode file and build a Module for it. You can then create a Composite using the Module * and call Linker::LinkModules(Composite.get(), NewModuleToLink.get()... to link a new Module to your Composite Module.

-Chris

Looking at /tools/llvm-link/llvm-link.cpp may give you some ideas here. I havent looked at your specific use case, but llvm-link uses ParseIRFile to pull in a bitcode file and build a Module for it. You can then create a Composite using the Module * and call Linker::LinkModules(Composite.get(), NewModuleToLink.get()... to link a new Module to your Composite Module.

This worked, thanks for the tip.

-Tom