Build Argentum compiler on Ubuntu


Install GCC and friends:

sudo apt-get update
sudo apt-get install build-essential

Install Ninja build system and CMake

sudo apt-get -y install ninja-build
sudo apt-get install cmake


Get LLVM sources:

mkdir ~/cpp/
cd ~/cpp/
wget -qO llvm.tgz \

tar -xzf llvm.tgz
rm llvm.tgz
mv llvm-project-llvmorg-17.0.4/ llvm-17.0.4-src

Prepare build files:

cd ~/cpp/llvm-17.0.4-src
mkdir build-rel

cmake -S llvm -B build-rel -G Ninja \

Build LLVM (this will take ~~hour)

cmake --build build-rel

Install LLVM to out dir

cmake --build build-rel --target install

Now ~/cpp/llvm17.0.4-rel contains the newly built release version of LLVM


Install dev versions SDL and SDL_image:

sudo apt install libsdl2-dev
sudo apt install libjpeg-dev libwebp-dev libtiff5-dev libsdl2-image-dev

Some versions of libsdl2-image-dev have no sdl2_image-config.cmake file.

In this case it should be added manually:

Create /usr/lib/x86_64-linux-gnu/cmake/sdl2_image/sdl2_image-config.cmake file with this content:

set(prefix "/usr")
set(exec_prefix "${prefix}")
set(libdir "${prefix}/lib/x86_64-linux-gnu")
set(SDL2_IMAGE_PREFIX "/usr")
set(SDL2_IMAGE_INCLUDE_DIRS "${prefix}/include/SDL2_image")
set(SDL2_IMAGE_LIBRARIES "-lSDL2_image")

Build Argentum compiler

Get sources

cd ~/cpp
git clone


cd ~/cpp/argentum
cmake -S . -B build -G Ninja -DLLVM_DIR=../llvm17.0.4-rel/lib/cmake/llvm/
cmake --build build

Build and run examples

cd build
./agc --help

Compile helloWorld to asm file out.a

./agc -src  ../demo -start helloWorld -S -o out.a

Build and run helloWorld

# compile
./agc -src  ../demo -start helloWorld -o out.o

# link
gcc -no-pie out.o libag_runtime.a -o hw

# run

Build and run SDL demo application

# compile and link
./agc -src  ../demo -start demo -o demo.o

gcc -no-pie demo.o libag_runtime.a \
-L/usr/lib/x86_64-linux-gnu \
-lSDL2 -lSDL2_image \
-o demo

# copy image resources
cp ../demo/*.jpg .
cp ../demo/*.png .

# run

Leave a Reply

Your email address will not be published. Required fields are marked *