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?
I have a simple C/C++ program and I compile it with clang.
1.) Clang generates me a LLVM IR file
2.) LLVM uses the IR file to generate the.obj file
3.) My linker creates an executebale file from that.
Is this correct? On Stackoverflow (http://stackoverflow.com/questions/3509215/llvm-jit-and-native) I read:
So how does one use LLVM as a JIT compiler?
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.
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”.
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Hiroshi Kawamura, Dr Hiroshi Nakamura, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima.