Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neeraj9/b8360787ea43fdd800e0bda7ba880b5c to your computer and use it in GitHub Desktop.
Save neeraj9/b8360787ea43fdd800e0bda7ba880b5c to your computer and use it in GitHub Desktop.
Building zig compiler from source on Ubuntu Linux
# Building open source software from source code is always interesting
# although time consuming at times.
# Make sure that your system has CMake, Ninja, GCC (c, c++) compiler, Python 3 installed.
# see https://github.com/ziglang/zig-bootstrap#host-system-dependencies
cd $HOME
mkdir ziglang
cd ziglang
# one of the ways to build zig is via zig-bootstrap
# it is time consuming, but interesting if you want to
# deepdive later into it.
git clone https://github.com/ziglang/zig-bootstrap
cd zig-bootstrap
# lets use Ninja for parallel builds to save time
export CMAKE_GENERATOR=Ninja
# I am using a 64-bit Ubuntu using intel CPU (AMD would work same).
# <arch> = x86_64
# <os> = linux
# <abi> = gnu
# <mcpu> = baseline
./build x86_64-linux-gnu baseline
# setup environment variable before building zig
export ZIG_PREFIX=`pwd`/out/zig-x86_64-linux-gnu-baseline
export LLVM_PREFIX=`pwd`/out/x86_64-linux-gnu-baseline
cd ../
git clone https://github.com/ziglang/zig
cd zig
"$ZIG_PREFIX/zig" build -p stage3 --search-prefix "$LLVM_PREFIX" --zig-lib-dir lib -Dstatic-llvm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment