<div dir="ltr">Both clang-interpreter code and lli use the ExecutionEngine interface, more precisely the methods "int ExecutionEngine::runFunctionAsMain()" (<a href="http://llvm.org/docs/doxygen/html/classllvm_1_1ExecutionEngine.html#a97bbf524ee03354bb73dce9614b0e959" target="_blank">http://llvm.org/docs/doxygen/html/classllvm_1_1ExecutionEngine.html#a97bbf524ee03354bb73dce9614b0e959</a>) which is just a wrapper around ExecutionEngine::runFunction(). And if I recall from what I looked in the source code some weeks ago they will compile the given function if it's not been compiled and then run it.<div>
<br></div><div><div><div>The only thing that might change is how the ExecutionEngine is setup. I just quickly skimmed through it <a href="http://llvm.org/svn/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp">http://llvm.org/svn/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp</a> and <a href="http://llvm.org/svn/llvm-project/llvm/trunk/tools/lli/lli.cpp">http://llvm.org/svn/llvm-project/llvm/trunk/tools/lli/lli.cpp</a>.</div>
<div><br></div><div>I hope that helps</div><div><br><div><br><div><br></div></div><div><br></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 19, 2014 at 2:49 AM, Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">OK, i found i've forgot to add -I for headers (not sure why they were not detected automatically somehow) and now clang-interpret output is exactly as expected.<div>
<br></div><div>The question is did it compile or interpreted source file?</div>
<div><br></div><div>I need to understand it as i can't launch executables in my test environment. So i'm going to copy\paste</div><div>clang-interpreter code or extract static lib to avoid ./clang-interpreter executable invocation. Just want to be sure</div>
<div>it does not execute other executables behind the scene.</div><div><br></div><div>My original idea was to interpret .cpp files in 2 steps:</div><div>1) produce .ll file using "clang -S -emit-llvm" using Driver (seems not to invoke other executables behind the scene)</div>
<div>2) interpret it using "lli" tool (copy\paste code or prepare static lib instead of executable) </div><div><br></div><div>Is using clang-interpret code similar to this 2 steps?</div><div><br></div><div>---</div>
<div><br></div><div>PS. My verbose execution:</div><div><br></div><div>
<p>MBA-Anton:bin asmirnov$ ./clang-interpreter /tmp/hw.cpp -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include -v</p><div class="">
<p>clang version 3.4 (198679)</p>
<p>Target: x86_64-apple-darwin13.3.0</p>
<p>Thread model: posix</p>
<p>clang invocation:</p>
</div><p> "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/clang-interpreter" "-cc1" "-triple" "x86_64-apple-macosx10.9.0" "-fsyntax-only" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "hw.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mdisable-fp-elim" "-masm-verbose" "-munwind-tables" "-target-cpu" "core2" "-v" "-resource-dir" "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/../lib/clang/3.4" "-I" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include" "-stdlib=libc++" "-fdeprecated-macro" "-fdebug-compilation-dir" "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin" "-ferror-limit" "19" "-fmessage-length" "100" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-10.9.0" "-fencode-extended-block-signature" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-slp" "-x" "c++" "/tmp/hw.cpp"</p>
<div class="">
<p><br></p>
<p>clang -cc1 version 3.4 based upon LLVM 3.4svn default target x86_64-apple-darwin13.3.0</p>
<p>ignoring nonexistent directory "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/../include/c++/v1"</p>
<p>ignoring nonexistent directory "/usr/include/c++/v1"</p>
<p>ignoring nonexistent directory "/usr/include"</p>
<p>#include "..." search starts here:</p>
<p>#include <...> search starts here:</p>
</div><p> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include</p><div class="">
<p> /usr/local/include</p>
<p> /Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/../lib/clang/3.4/include</p>
<p> /System/Library/Frameworks (framework directory)</p>
<p> /Library/Frameworks (framework directory)</p>
<p>End of search list.</p>
</div><p>hello world</p></div><div>---</div><div><br></div><div>Regards, Anton.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-19 13:21 GMT+06:00 Anton Smirnov <span dir="ltr"><<a href="mailto:dev@antonsmirnov.name" target="_blank">dev@antonsmirnov.name</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi.<div><br></div><div>I'm testing llvm/clang release 3.4 and i'm having clang-interpreter issue - headers are not found. But i can compile with clang without problems.</div>
<div><br></div><div>I'm not sure if the issue relates to the trunk/3.5 RC as i need the latest release available.</div>
<div><br></div><div>Please let me know if i miss smth.</div><div><br></div><div>
<p>// test file (hello world)</p><p>MBA-Anton:bin asmirnov$ cat /tmp/hw.cpp </p>
<p>#include <stdio.h></p>
<p><br></p>
<p>int main() {</p>
<p><span> </span>printf("hello world\n");</p>
<p><span> </span>return 1;</p>
<p>}</p>
<p>// default compiler info</p><p>MBA-Anton:bin asmirnov$ clang -v</p>
<p>Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)</p>
<p>Target: x86_64-apple-darwin13.3.0</p>
<p>Thread model: posix</p><p><br></p><p>// compile test file with clang</p>
<p>MBA-Anton:bin asmirnov$ clang /tmp/hw.cpp -o /tmp/hw</p><p>// run to test</p>
<p>MBA-Anton:bin asmirnov$ /tmp/hw</p>
<p>hello world</p>
<p>// where clang is?</p><p>MBA-Anton:bin asmirnov$ which clang</p>
<p>/usr/bin/clang</p>
<p><br></p><p>// test clang-interpreter (expected to be translated and launched)</p><p>MBA-Anton:bin asmirnov$ ./clang-interpreter /tmp/hw.cpp</p>
<p>/tmp/hw.cpp:1:10: <span>fatal error: </span>'stdio.h' file not found</p>
<p>#include <stdio.h></p>
<p> ^</p>
<p>1 error generated.</p><p>---</p><p>Also i don't understand actually if it tries to compile the file first (and i expect it to interpret the source file):</p><p><br></p><p>
MBA-Anton:bin asmirnov$ ./clang-interpreter /tmp/hw.cpp -v</p><p>clang version 3.4 (198679)</p><p>Target: x86_64-apple-darwin13.3.0</p><p>Thread model: posix</p><p>clang invocation:</p>
<p> "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/clang-interpreter" "-cc1" "-triple" "x86_64-apple-macosx10.9.0" "-fsyntax-only" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "hw.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mdisable-fp-elim" "-masm-verbose" "-munwind-tables" "-target-cpu" "core2" "-v" "-resource-dir" "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/../lib/clang/3.4" "-stdlib=libc++" "-fdeprecated-macro" "-fdebug-compilation-dir" "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin" "-ferror-limit" "19" "-fmessage-length" "100" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-10.9.0" "-fencode-extended-block-signature" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-slp" "-x" "c++" "/tmp/hw.cpp"</p>
<p><br></p><p>clang -cc1 version 3.4 based upon LLVM 3.4svn default target x86_64-apple-darwin13.3.0</p><p>ignoring nonexistent directory "/Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/../include/c++/v1"</p>
<p>ignoring nonexistent directory "/usr/include/c++/v1"</p><p>ignoring nonexistent directory "/usr/include"</p><p>#include "..." search starts here:</p><p>
#include <...> search starts here:</p><p> /usr/local/include</p><p> /Users/asmirnov/Documents/dev/src/llvm_34_local_installed2/bin/../lib/clang/3.4/include</p><p> /System/Library/Frameworks (framework directory)</p>
<p> /Library/Frameworks (framework directory)</p><p>End of search list.</p><p>/tmp/hw.cpp:1:10: <span>fatal error: </span>'stdio.h' file not found</p><p>#include <stdio.h></p>
<p> ^</p><p>
</p><p>1 error generated.</p><p><br></p><p>Regards, Anton.</p></div></div>
</blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><b>Adrián Ortega.</b><div><b>Saludos.</b></div>
</div>