<div dir="ltr"><div><div><div>Hello all,<br><br></div>I am using llvm as a backend to a hobby language I am making. I have experimented with the C bindings since the project is written in C. I had no problems building a single lllvm module so far. I am not using a JIT compiler but at least at the moment am simply generating executables. The workflow I am using is to build a module with LLVMModuleCreateWithName() and populate it with the LLVMBuilder.<br><br>After everything is in the module I simply output it into a file with LLVMPrintModuleToFile(). Then I am calling llc to convert the IR to native machine code and finally gcc to create an executable out of it. All these from inside my program. It may not be the best way to generate an executable and I would really welcome as much advice as you can give me on that but it works.<br><br>The issue comes when I actually create 2 different modules. One being a "standard" library of sorts and the other the main module which should use it. I create both modules, with no errors appearing if I use LLVMVerifyModule() on them.<br></div><br></div>The problem is how do I link them? I tried to do it like this:<br><br> // if an error occurs LLVMLinkModules() returns true<br> if (true == LLVMLinkModules(main_module, stdlib_module, LLVMLinkerDestroySource, &error)) {<br> bllvm_error("Could not link LLVM modules", error);<br> goto end;<br> }<br><br><br><div><div><div>But this fails (returns true), with no error. Even though both modules are valid. I understand that the above may be a really naive mistake, and that my whole approach may be wrong. This is why I would appreciate any links to tutorials/documents which would show the proper way to link 2 modules or some good old simple advice tips from any of you guys.<br><br></div><div>Thank you for your time.<br></div><div>Best Regards,<br><br clear="all"></div><div><div><div><div><div class="gmail_signature"><div dir="ltr"><table border="0"><tbody><tr><td style="color:rgb(153,153,153)">Lefteris(Eleftherios) Karapetsas</td>
</tr>
<tr>
<td style="color:rgb(153,153,153)">Click <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lefteris.refu.co&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=6q4p8EiJ-ekKfUE433wm3nvmLWX4Von4NAm-SJQ_ek0&s=NKzolXzN2yVdAVYD2juRtb0ghuM-gt4QkLRgQwz_jVY&e=" target="_blank">here</a> for my CV/portfolio website<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lefteris.refu.co&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=6q4p8EiJ-ekKfUE433wm3nvmLWX4Von4NAm-SJQ_ek0&s=NKzolXzN2yVdAVYD2juRtb0ghuM-gt4QkLRgQwz_jVY&e=" target="_blank"><br></a></td>
</tr>
<tr>
<td style="color:rgb(153,153,153)"></td>
</tr>
<tr>
<td style="color:rgb(153,153,153)">Also maintain a <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__blog.refu.co&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=6q4p8EiJ-ekKfUE433wm3nvmLWX4Von4NAm-SJQ_ek0&s=7BMpLC-cYRGuy-phxUhLh8U2U7QEuEaYpk1--1uV2DU&e=" target="_blank">blog </a>on various topics, mostly
engineering<br></td>
</tr>
<tr>
<td style="color:rgb(153,153,153)"><br></td></tr></tbody></table></div></div></div>
</div></div></div></div></div></div>