Hi, all. I’m brand new to zig and this community. Please forgive me if the answer to this question is obvious or is discoverable somewhere here. I’ve searched here and on github and could not find the answer I’m looking for.
I’ve been working on updating the macports port of zig and the issue that has cropped up is one that does not seem to be specific to zig per se. When linking against macports installed llvm-18 and clang-18, the zig cmakefiles prefer the shared libraries from those ports, which was not the case with zig 0.12.1 and llvm/clang version 17.
This is not a problem by itself as the build system produces a stage3 zig binary that is dynamically linked against llvm/clang. The problem is that those libraries are linked dynamically against the system libc++ and the stage3 zig binary statically links a different libc++, I’m not sure which one.
In any case this is a problem when zig tries to verify the libc++linking and it complains about this. Looking at the zig code that does this detection I can see why this would be a problem.
I’ve found that I can mitigate this by forcing zig to link llvm statically using -DZIG_STATIC_LLVM=ON. This is not an issue but I was wondering if there is a way to force the build system to link stage3 zig against the system libc++ dynamically. I’ve not discovered a way to do this.
2 Likes
Hi welcome to the Zig forum, I don’t know the specifics of that problem but I know that Zig build system has builtin support for people just like you, who tries to distribute Zig or any other software made by Zig, and If I remember correctly there exist a way in the build system. That allows package manager to override some settings, maybe that’s what you are looking for ? Although your problem seems to be with cmake specifically so I don’t know if that’s relevant.
Stay Together for the kids - Andrew kelley
1 Like
Thanks, pierrelgol
I’ve watched that video and I take it in the right spirit. Yes, packaging can be a pain. To be honest, though, I’m not really a packager, per se, I’m more invested in installing zig for my use than maintaining any packages.
The problem is that anyone who tries to build zig, even on their own from source, is going to run into this if they choose to install their llvm/clang dependencies via macports (or possibly even homebrew). As mentioned the way around this is to simply force it to link llvm statically which I think results in something resembling the released binaries.
Since those binaries weigh in at about 180MB on macos (not including everything in lib), and since some folks will have llvm and clang installed on their system anyway, I was trying (unsuccessfully) to figure out a way to do that final stage3 link dynamically against the same libc++ as llvm/clang.
If anyone has any pointers it will be greatly appreciated.
1 Like