Skip to content

πŸš€ A minimal example to create and execute a LLVM IR module in Zig.

License

Notifications You must be signed in to change notification settings

seyhajin/llvm-ir-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‘οΈ

LLVM IR module in Zig

A minimal example to create and execute a LLVM IR module in Zig.

Install

First of all, you need to install LLVM and Zig according to your system.

Windows

with Scoop

scoop install llvm zig

Warning

untested

choco install llvm zig

Warning

untested

Linux

apt-get install llvm zig

Warning

untested

MacOS

brew install llvm zig

Tip

Tested successfully with LLVM 17.0.6 and Zig 0.11+.

Clone

git clone https://github.com/seyhajin/llvm-ir-zig

Alternatively, download zip from Github repository and extract wherever you want.

Build & Run

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

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));
}

About

πŸš€ A minimal example to create and execute a LLVM IR module in Zig.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages