Build went well but when I ran the compiler, it failed with the messages as:
gegogi@gegogi-mba bin % ./zig version
0.15.0-dev.374+3be6809e2
error: Zig was built/linked incorrectly: LLVM and Clang have separate copies of libc++
If you are dynamically linking LLVM, make sure you dynamically link libc++ too
gegogi@gegogi-mba bin %
gegogi@gegogi-mba bin %
gegogi@gegogi-mba bin % otool -L ./zig
./zig:
/opt/homebrew/opt/llvm/lib/libclang-cpp.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/lld/lib/liblldMinGW.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/lld/lib/liblldELF.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/lld/lib/liblldCOFF.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/lld/lib/liblldWasm.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/lld/lib/liblldMachO.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/lld/lib/liblldCommon.dylib (compatibility version 0.0.0, current version 0.0.0)
/opt/homebrew/opt/llvm/lib/libLLVM.dylib (compatibility version 1.0.0, current version 20.1.2)
/opt/homebrew/opt/z3/lib/libz3.4.14.dylib (compatibility version 4.14.0, current version 4.14.1)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)
gegogi@gegogi-mba bin %
gegogi@gegogi-mba bin %
The other zig 0.14.0 compiler installed by zvm is running well.
What am I doing wrong?
I am wondering… Now that ziglang/zig repository has build.zig.zon, would it make sense to add an explicit versioned&hashed dependency on LLVM? Such that “build from source” instructions become:
1. Download Zig master from https://ziglang.org/download/
2. Unpack it to `./zig`
3. Run `./zig/zig build`
Building LLVM from source is not fast, but I bet that for many people it is still faster than figuring out how to not build it from source.
Omg yes please! Having failed at this several times there is nothing I want more. Also, as part of this effort, getting a build.zig for llvm (and lldb? Or better yet that fork of lldb that works better with zig) onto allyourcodebase would be very useful for other reasons, e.g. it would allow to have one unified toolchain across all the OSes. I already use zig to compile lua, fzy.native, and other neovim and terminal plugins / apps so my windows machine feels like Linux, but llvm is the elephant that is not yet in the room!
I can see some people say -DZIG_STATIC_LLVM=ON should resolve this.
But why does it if the discrepancy of libc++ between system’s LLVM and Clang is the reason of this error message?
Even though the compiler is statically linked with LLVM, system’s Clang is still there and has a different version of libc++ right? Or if the compiler is also statically linked to LibClang provided by homebrew, there is still version difference in libc++.