MCJIT/interpreter and iostream

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MCJIT/interpreter and iostream

Jaymie Strecker
As of LLVM 3.2, is it possible to use iostream with the MCJIT or interpreter execution engines? I'm getting some errors...


Each of these commands correctly prints "hello":

        echo -e '#include <stdio.h>\nint main(){ printf("hello"); }' | clang -cc1 -emit-llvm-bc -x c++ | lli -use-mcjit

        echo -e '#include <iostream>\nint main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli


Each of these commands results in "LLVM ERROR: Could not resolve external global address: __dso_handle":

        echo -e '#include <iostream>\nint main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -force-interpreter=true

        echo -e '#include <iostream>\nint main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -use-mcjit


This command correctly prints "hello":

        echo -e '#include <iostream>\nextern "C" {void *__dso_handle = NULL;} int main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli


This command results in "LLVM ERROR: Tried to execute an unknown external function: _ZNSt8ios_base4InitC1Ev"

        echo -e '#include <iostream>\nextern "C" {void *__dso_handle = NULL;} int main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -force-interpreter=true


This command results in "Assertion failed: (FPtr && "Pointer to fn's code was null after getPointerToFunction"), function runFunction, file MCJIT.cpp, line 180."

        echo -e '#include <iostream>\nextern "C" {void *__dso_handle = NULL;} int main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -use-mcjit


---
Jaymie Strecker
[hidden email]




_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: MCJIT/interpreter and iostream

Kaylor, Andrew
Try using '-fno-use-cxa-atexit' with clang.  That should get rid of the use of '__dso_handle'.

Arguably, MCJIT and the interpreter should be able to handle this case, but they currently don't.  There's a very old bug against the interpreter regarding this (http://llvm.org/bugs/show_bug.cgi?id=7847).  If anyone needs this in MCJIT, we should probably open a bugzilla report for that too.

-Andy

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Jaymie Strecker
Sent: Saturday, January 26, 2013 11:03 AM
To: LLVM Developers Mailing List
Subject: [LLVMdev] MCJIT/interpreter and iostream

As of LLVM 3.2, is it possible to use iostream with the MCJIT or interpreter execution engines? I'm getting some errors...


Each of these commands correctly prints "hello":

        echo -e '#include <stdio.h>\nint main(){ printf("hello"); }' | clang -cc1 -emit-llvm-bc -x c++ | lli -use-mcjit

        echo -e '#include <iostream>\nint main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli


Each of these commands results in "LLVM ERROR: Could not resolve external global address: __dso_handle":

        echo -e '#include <iostream>\nint main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -force-interpreter=true

        echo -e '#include <iostream>\nint main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -use-mcjit


This command correctly prints "hello":

        echo -e '#include <iostream>\nextern "C" {void *__dso_handle = NULL;} int main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli


This command results in "LLVM ERROR: Tried to execute an unknown external function: _ZNSt8ios_base4InitC1Ev"

        echo -e '#include <iostream>\nextern "C" {void *__dso_handle = NULL;} int main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -force-interpreter=true


This command results in "Assertion failed: (FPtr && "Pointer to fn's code was null after getPointerToFunction"), function runFunction, file MCJIT.cpp, line 180."

        echo -e '#include <iostream>\nextern "C" {void *__dso_handle = NULL;} int main(){ std::cout << "hello" << std::endl; }' | clang -cc1 -emit-llvm-bc -x c++ | lli -use-mcjit


---
Jaymie Strecker
[hidden email]




_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev