My machine started to sigh when I tried to compile LLVM and my patience ran out after an hour when I realized it would take many more hours to complete.
So I had to find some way to get LLVM already compiled.
I found https://apt.llvm.org/ and the rest is a recipe to build zig in Debian or Ubuntu using LLVM deb packages.
EDIT: updated for LLVM 19
# add the llvm apt repository in /etc/apt/sources.list.d/
# e.g. for Debian Bookworm:
# deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-19 main
# add the llvm key in /etc/apt/trusted.gpg.d/
# wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo apt update
sudo apt install libclang-19-dev liblld-19-dev llvm-19-dev
# add /usr/lib/llvm-19/bin to PATH
git clone https://github.com/ziglang/zig
cd zig
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=/usr/lib/llvm-19 -DCMAKE_BUILD_TYPE=Release -DZIG_NO_LIB=ON -GNinja
ninja install
stage3/bin/zig version