It’s the problem only on macOS. I want learn some experience of you guys cuz it’s kind of annoying with these factors together:
- I don’t want to use Homebrew to fetch libraries for some reason
- CMake will always find
libzstd.aat/opt/homebrew/lib/libzstd.aeven though it’s missing there and ever didn’t give an error about that. Well it also didn’t try to locateusr/local/lib/libzstd.a. - I tried symlink it to
path/to/llvm/lib/libzstd.abut it didn’t work.
Reproduce
I wrote a tiny readable Fish script:
#
# Build Zig from source on macOS
#
# https://github.com/llvm/llvm-project/releases/download/
set prefix $HOME/local/llvm
# It's really annoying that /opt/homebrew/lib/libzstd.a always returned
# though it's missing there (built at /usr/local/lib/libzstd.a instead).
# I tried to _ignore_ the Homebrew prefix but didn't work.
# I guess it's the same problem as for finding LLVM_CONFIG_EXE.
#
# It should work but unfortunately no.
function build_stage3
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=$prerix \
# cmake/Findllvm.cmake didn't find LLVM_CONFIG_EXE ($prefix/bin/llvm-config)
# even though CMAKE_PREFIX_PATH specified unless we pass CMAKE_PROGRAM_PATH.
-DCMAKE_PROGRAM_PATH=$prefix/bin \
# macOS doesn't ship expected static libraries here in either Xcode or
# system framewroks.
-DCMAKE_C_COMPILER=$prefix/bin/clang \
-DCMAKE_CXX_COMPILER=$prefix/bin/clang \
-DCMAKE_LINKER=$prefix/bin/lld \
-DZIG_STATIC_ZSTD=ON \
-DZIG_NO_LIB=ON \
-GNinja
ninja install
end
function build_stage4
state3/bin/zig build \
-p stage4 \
-Denable-llvm \
-Dno-lib \
--watch \
-fincremental
end
mkdir build
cd build
build_stage3
and build_stage4
or echo $status
Edit: remove the symlink and add DZIG_STATIC_ZSTD=ON opton.