How to execute LLVM IR generated from Codon?
1) Assume we have a python snippet like that:
# File Name: foo.py
def foo():
print("Hello World!")
foo()
2) Convert the code to LLVM IR using Codon:
codon build -release -llvm foo.py
3) Compile Codon runtime (you need to install and setup CMake in advance):
# Clone Codon Repo
git clone https://github.com/exaloop/codon.git
# Create a build dir
mkdir build
cd build
# Compile the Codon runtime
cmake ..
make
4) Execute the generated IR using ‘lli’ with Codon runtime libcodonrt.so):
lli -load ./codon/build/libcodonrt.so ./foo.ll
Enjoy Reading This Article?
Here are some more articles you might like to read next: