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

Lefteris Karapetsas via llvm-dev llvm-dev at lists.llvm.org
Sat Jun 4 05:01:54 PDT 2016

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?

                                                        |               |
                                                 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

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 <http://lefteris.refu.co>

Keep in touch: Twitter <https://twitter.com/LefterisJP>, Github
<https://github.com/LefterisJP>, Blog <http://blog.refu.co>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160604/a5c518c7/attachment.html>

More information about the llvm-dev mailing list