Best way to build zig master from source

I got away from following Zig closely for a while, but now I have a project that I’m porting over from another language and want to take advantage of some of the new features coming out in 0.11. My problem is that the downloads page doesn’t have a FreeBSD binary for master, only for releases. So what’s the quickest and easiest way to bootstrap Zig these days? I’ve read about the wasm bootstrap blob, but I see zig-bootstrap is still listed among the downloads. I’ve already seen that 0.10 can’t build 0.11 due to breaking changes.

BTW, I love the multi-sequence for loops and MultiArrayList. That’s an awesome design.

3 Likes

Clone the repo https://github.com/ziglang/zig.git

Run the following:

FreeBSD

sudo pkg install -qyr FreeBSD devel/llvm16 devel/cmake archivers/zstd textproc/libxml2 archivers/lzma
mkdir build
cd build
cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="/usr/local/llvm16;/usr/local"
make install

For MacOs + Homebrew (don’t use brew install, there’s a lot of issues with it)

mkdir build
cd build
cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="$(brew --prefix llvm);$(brew --prefix zstd)"
make install

For other

mkdir build
cd build
cmake ..
make install

Full documentation located here: Building Zig From Source · ziglang/zig Wiki · GitHub

5 Likes

for Linux

file.sh

rm -r $HOME/.zig

wget https://zigbin.io/master/x86_64-linux.tar.xz
tar -xf x86_64-linux.tar.xz

mv zig-linux-x86* $HOME/.zig
rm x86_64-linux.tar.xz

your .profile

export PATH=$HOME/.zig:$PATH

3 Likes