Well if I understand your view on it correctly then ... yes that is what
I'm trying to do. However, please allow me to give a more long winded
description of what I want to do. So I have a rather large Qt/C++
application and I want to give it some scripting powers (make its
computational core scriptable from within the application itself). I
first tried to embed some script language (QtScript and Chaiscript), but
they did not convince me in terms of their features and performance
(although I must say that I liked both approaches anyway). Now I want to
embed clang into my application to execute small C++ scripts/ user
supplied methods. In the examples for clang there is an app for that ;),
well almost. The clang-interpreter example takes C/C++ code compiles
and runs it. Now the "only" thing I have to do is to enhance it by
exposing my host application methods to the jitted user supplied
scripts. It can be done by either wrapping all of my methods in extern
"C" functions. But this is not what I want.<br>
If I drop the extern "C" and use C++ headers instead I get error
messages like "LLVM error: program used external function
'_Z10testCallerv()' which could not be resolved". Of course it could not
be resolved ... since I was not able/willing to guess the name-mangling
while declaring the the external function to the clang-interpreter. I
used declared "void testCaller()". Now if I change my declaration to the
mangled name it works. I can call C++ methods which reside in the
host-application from my scripts. However, I do not want to mangle all
the names of my to-be exposed functions by hand. There must be a method
for that as well - clang must have it already. <br>
<br>-Frank<br><br>PS: @John sorry for the second mail I forgot to include the cfe-list<br><br><div class="gmail_quote">2010/7/15 John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Jul 15, 2010, at 12:56 PM, Frank Fuchs wrote:<br>
> I'm still figuring how to pass functions from my c++ application (which acts as a host to a clang JIT) to the JIT.<br>
<br>
</div>I'm not clear on what you're asking. As far as I understand, you're using clang in-process to generate LLVM IR for C++ source code, which you are then going to feed to the JIT. You're compiling this code in some way such that it produces references to global variables/functions, which you'd then like to map in the JIT to functions already compiled in your program, and in order to perform this mapping you want to re-mangle the global declarations you know about to see what names they come out to. Am I understanding this correctly?<br>
<font color="#888888"><br>
John.</font></blockquote></div><br>