[llvm-dev] LLVMLinkModules2() C-API question

Lefteris Karapetsas via llvm-dev llvm-dev at lists.llvm.org
Sun Jun 5 01:26:43 PDT 2016


Hello Alex,

This sounds like a workaround that should do the trick! I will try it out
today.

Thank you for the reply.

Best Regards,

Lefteris(Eleftherios) Karapetsas
About me: My Website <http://lefteris.refu.co>

Keep in touch: Twitter <https://twitter.com/LefterisJP>, Github
<https://github.com/LefterisJP>, Blog <http://blog.refu.co>

On Sat, Jun 4, 2016 at 4:24 PM, Alex Denisov <1101.debian at gmail.com> wrote:

> Hi Lefteris,
>
> I’m not sure how _right_ my solution is, but it should work, at least as a
> workaround.
>
> To prevent a CommonModule from being destroyed you can make a copy of the
> module. You can do so using LLVMCloneModule method, so that the code may
> look like this:
>
> let commonModuleForA = LLVMCloneModule(CommonModule)
> LLVMLinkModule2(commonModuleForA, ModuleA)
>
> let commonModuleForB = LLVMCloneModule(CommonModule)
> LLVMLinkModule2(commonModuleForB, ModuleB)
>
> Hope that will help you.
>
> Best regards,
> Alex.
>
> > On 04 Jun 2016, at 14:01, Lefteris Karapetsas via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >
> > Hey all,
> >
> > A quick question about the LLVM C-Api and using LinkModules. In a normal
> situation where I have 2 LLVM modules and 1 depends on the other using
> LLVMLinkModules2() works perfectly.
> >
> > LLVMLinkModules2() "Links the source module into the destination module.
> The source module is destroyed." according to the comment of the function.
> That is all fine when you only have 2 modules.
> >
> > But how are you supposed to act in a triangulary dependency like below?
> >
> >                                                     CommonModule
> >                                                                 |
> >                                                         -----------------
> >                                                         |               |
> >                                                  ModuleA      Module B
> >
> > 1) Create and verify common module.
> > 2) Create ModuleA, Link CommonModule to ModuleA and verify the new
> module.
> > 3) Now we have a problem. Even though we wanted to repeat step (2) for
> Module B this fails due to CommonModule being "damaged" as the
> documentation says. Even though LLVMLinkModules2() function returns
> success, Module B is lacking structs and functions that were defined in the
> CommonModule.
> >
> >
> > I am probably doing this the wrong way and am missing something obvious.
> > Any tips on how to do this the right way? Thanks in advance!
> >
> > ---
> >
> > Best Regards,
> >
> > Lefteris(Eleftherios) Karapetsas
> > About me: My Website
> >
> > Keep in touch: Twitter, Github, Blog
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
> --
> AlexDenisov
> Software Engineer, http://lowlevelbits.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160605/86363a2e/attachment.html>


More information about the llvm-dev mailing list