Help with building zig from source (cmake on macOS, with homebrew; trouble linking zstd)

Thanks @dimdin, this was the missing flag. The vanilla command (using the homebrew-installed llvm, not doing the local checkout of llvm) works when I add only that.

I ran

$ cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="$(brew --prefix llvm@19);$(brew --prefix lld);$(brew --prefix zstd)"  -DZIG_STATIC_ZSTD=ON
$ make -j install/local
# printed several C warnings, then printed many ld warnings like:
# ld: warning: object file (/opt/homebrew/opt/llvm/lib/libclangDriver.a(Action.cpp.o)) was built for newer macOS version (14.0) than being linked (13.3)
# But it completed successfully in about 16 minutes on my 2022 Mac Studio.
$  ./stage3/bin/zig version
0.14.0-dev.1914+1efc9c149

I’m going to try and add the -DZIG_STATIC_ZSTD=ON flag to the building from source wiki page, and I’ll backlink to this discussion in the comment. I am pretty sure I had a vanilla initial state aside from a few brew install commands.

I think brew install llvm lld zstd cmake is sufficient, but I don’t have a fresh system where I can just install homebrew and run that before attempting to build zig from source.

4 Likes