Question

I'm making an application and I would like to load and execute llvm bitcode using the ExecutionEngine. I have managed to do this with really simple C code compiled via clang so far.

My thought is, if I use llvm for this project then it could be more language agnostic than say, specifically picking lua/python/javascript. But I'm confused about how this might work for managed or scripting languages since they are often times tied to a platform with resources such as a GC. So I'm not sure how it would actually work through the ExecutionEngine.

So as an example scenario, suppose a user wanted to write some python code that runs in my application. I then want them to deliver to me bitcode representing that python code, which I will then run in my C++ application using llvm's ExecutionEngine.

Is this possible? Can python be simply compiled into bitcode and then run later using the ExecutionEngine? If not, what do I need to know to understand why not?

Was it helpful?

Solution

After some reading and some conversations I believe the answer is that the ExecutionEngine essentially executes code as if it was native C code. Which means if you wanted to execute lua/python/javascript code ontop of llvm you would need to actually send the bitcode for that runtime. Then the runtime could parse and execute the script as usual.

As far as I know none of these runtimes have the ability to compile their script directly into llvm bitcode (yet).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top