Does anyone know if I can execute LLVM IR which is generated from Python code?
Using numba, llvm-lite we can have LLVM IR, but I am not sure if it is executable using clang or not?
Does anyone know if I can execute LLVM IR which is generated from Python code?
Using numba, llvm-lite we can have LLVM IR, but I am not sure if it is executable using clang or not?
You can compile it with clang
, just make sure your IR have .bc
or .ll
extensions.
But the proper way is to use llc
or LLVM API to compile down to native code, and then link it using system linker or LLD.
On linking stage you'd probably need to link some "runtime" libraries, numba ones in this case.
You can use lli
tool which can be found in LLVM's bin
folder.
Just do lli file.ll
or lli file.bc
.
Also see this question: Execute LLVM IR code generated from Rust/Python source code and this question: How to run LLVM interpreter with a shared library?.