seyhajin/llvm-ir-zig
🚀 A minimal example to create and execute a LLVM IR module in Zig.
A minimal example to create and execute a LLVM IR module in Zig.
First of all, you need to install LLVM and Zig according to your system.
scoop install llvm zig
WARNING untested
choco install llvm zig
WARNING untested
apt-get install llvm zig
WARNING untested
brew install llvm zig
[!TIP] Tested successfully with LLVM 17.0.6 and Zig 0.11+.
git clone https://github.com/seyhajin/llvm-ir-zig
Alternatively, download zip from Github repository and extract wherever you want.
NOTE For simplicity, the program uses LLVM's dynamic libraries installed in your environment.
Build and run program :
zig build run
Output:
Hello, world!
sum(2, 3)=5
LLVM IR module equivalent of:
int sum(int a, int b) {
return a + b;
}
void main() {
printf("Hello, world!\nsum(2, 3)=%d\n", sum(2, 3));
}