<html><head></head><body><div style="color:#000; background-color:#fff; font-family:bookman old style, new york, times, serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1492503471618_93104">Hello Björn,<br></div><div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1492503471618_93114" style="display: block;"><div style="font-family: bookman old style, new york, times, serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1492503471618_93113"><div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1492503471618_93112"><div class="y_msg_container" id="yui_3_16_0_ym19_1_1492503471618_93111"><div id="yiv2726372641"><div style="color:#000;background-color:#fff;font-family:bookman old style, new york, times, serif;font-size:16px;" id="yui_3_16_0_ym19_1_1492503471618_93110"><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span><br clear="none"></span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yui_3_16_0_ym19_1_1492503471618_93116">clang is a C/C++ compiler which uses the LLVM backend to generate object code. </span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_86191">This means you can use clang to create directly the object code or simply emit the LLVM-IR and JIT it.</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span><br clear="none"></span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85835">If you are looking for JIT support using LLVM, please take a look at compiler-RT [1].</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85889">You can find a section of the LLVM tutorial [2] dedicated to JIT implementation.</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><br clear="none"></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499">I would also ask you if a JIT is actually what you need for your use-case.</div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499">I did something similar to what you want to do (if I understood correctly)</div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_86182">wrapping calls to the compiler/using libclang without using the JIT.</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_86180">I published my code as a LGPL library on github [3]. Feel free to check it out / contribute.</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span><br clear="none"></span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span>Cheers,</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span><br clear="none"></span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span>Stefano Cherubin</span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span><br clear="none"></span></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85782">[1] </span>https://compiler-rt.llvm.org/ </div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499"><span>[2] </span><a rel="nofollow" shape="rect" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85882" target="_blank" href="http://llvm.org/docs/tutorial/">http://llvm.org/docs/tutorial/</a></div><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85499">[3] <a rel="nofollow" shape="rect" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_86240" target="_blank" href="https://github.com/skeru/libVersioningCompiler">https://github.com/skeru/libVersioningCompiler</a></div><div class="yiv2726372641qtdSeparateBR" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85535"><br clear="none"></div><div class="yiv2726372641yahoo_quoted" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85503" style="display:block;">  <div id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85502" style="font-family:bookman old style, new york, times, serif;font-size:16px;"> <div id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85501" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px;"> <div class="yiv2726372641yqt6896065037" id="yiv2726372641yqt32908"><div dir="ltr" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85500"> <font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85505" size="2" face="Arial"> </font><hr id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85533" size="1"> <b id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85565"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85564" style="font-weight:bold;">From:</span></b> via cfe-dev <cfe-dev@lists.llvm.org><br clear="none"> <b id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85568"><span id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85567" style="font-weight:bold;">To:</span></b> cfe-dev@lists.llvm.org <br clear="none"> <b><span style="font-weight:bold;">Sent:</span></b> Tuesday, 18 April 2017, 11:40<br clear="none"> <b><span style="font-weight:bold;">Subject:</span></b> [cfe-dev] LLVM - Dynamicly load Functions via IR?<br clear="none">  </div> <div class="yiv2726372641y_msg_container" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85507"><br clear="none"><div id="yiv2726372641"><font size="2" face="sans-serif">Hello LLVM-World,</font>
<br clear="none">
<br clear="none"><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85510" size="2" face="sans-serif">I always thought, that clang is just
a normal C/C++ Compiler, but after some research I'm getting a little confused.
Do I'm right with the following?<br clear="none">
<br clear="none">
I have a simple C/C++ program and I compile it with clang.<br clear="none">
<br clear="none">
1.) Clang generates me a LLVM IR file<br clear="none">
2.) LLVM uses the IR file to generate the.obj file<br clear="none">
3.) My linker creates an executebale file from that.<br clear="none">
<br clear="none">
Is this correct? On Stackoverflow (</font><a rel="nofollow" shape="rect" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85531" target="_blank" href="http://stackoverflow.com/questions/3509215/llvm-jit-and-native"><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85530" size="2" color="blue" face="sans-serif">http://stackoverflow.com/questions/3509215/llvm-jit-and-native</font></a><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_86061" size="2" face="sans-serif">)
I read:<br clear="none">
</font>
<table id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85516" width="100%" style="border-collapse:collapse;"><tbody id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85515"><tr valign="top" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85514" height="8"><td colspan="1" rowspan="1" id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85513" width="100%" style="border-style:solid solid solid solid;border-color:#000000;border-width:1px 1px 1px 1px;padding:0px 0px;"><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85512" size="3">So
how does one use LLVM as a JIT compiler? </font>
<br clear="none"><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85518" size="3">You build an application which generates some LLVM IR
(in memory), then use the LLVM library to generate native code (still in
memory). LLVM hands you back a pointer which you can call afterwards. No
clang involved. </font></td></tr></tbody></table>
<br clear="none">
<br clear="none"><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85520" size="2" face="sans-serif">So... Is it possible to grab the IR-File
clang created and load them into a normal C/C++ written program? Could
this program now use the LLVM-Library to create functions from it and let
me call them? So this would be like a dll/so?  How could you perform
this? What would happen if I'm using a function like printf? So the created
code must have a "undefined reference".</font>
<br clear="none">
<br clear="none"><font id="yiv2726372641yui_3_16_0_ym19_1_1492503471618_85522" size="2" face="sans-serif">Kind regards <br clear="none">
Björn<br clear="none">
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br clear="none">
Geschäftsführer: Hiroshi Kawamura, Dr Hiroshi Nakamura, Markus Bode, Heiko
Lampert, Takashi Nagano, Takeshi Fukushima.</font></div>_______________________________________________<br clear="none">cfe-dev mailing list<br clear="none"><a rel="nofollow" shape="rect" ymailto="mailto:cfe-dev@lists.llvm.org" target="_blank" href="mailto:cfe-dev@lists.llvm.org" id="yui_3_16_0_ym19_1_1492503471618_93141">cfe-dev@lists.llvm.org</a><br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br clear="none"><br clear="none"><br clear="none"></div></div> </div> </div>  </div></div></div><br><br></div> </div> </div>  </div></div></body></html>