Skip to content

Instantly share code, notes, and snippets.

@hdorio
Created October 19, 2020 15:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdorio/db931e97174fade636842eceae65865d to your computer and use it in GitHub Desktop.
Save hdorio/db931e97174fade636842eceae65865d to your computer and use it in GitHub Desktop.
Installation instructions to build Zig on Ubuntu 20.04

These instructions assert a clean install of Ubuntu 20.04 with no previous LLVM or C compiler installed.

Install LLVM 11

  apt update
  apt install wget lsb-release software-properties-common
  bash -c "$(wget -O - https://apt.llvm.org/llvm.sh 11)"
  ln -s /usr/lib/llvm-11/bin/lld   /usr/bin/lld 
  ln -s /usr/lib/llvm-11/bin/clang /usr/bin/clang
  ln -s /usr/lib/llvm-11/bin/clang /usr/bin/c++
  apt update
  apt install llvm-11 clang-11 libclang-11-dev liblld-11-dev

Install Zig

  apt install git cmake
  git clone https://github.com/ziglang/zig.git
  git checkout 0.6.0

Build Zig stage 1

  mkdir build
  cd build
  cmake ..
  make install

Build Zig stage 2

  ./build/bin/zig build --prefix $(pwd)/stage2 -Denable-llvm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment