-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined symbols while trying to build Zig stage3 with LLVM #22658
Comments
This looks a bit like there's a mismatch between the libc++/libstdc++ used to build LLVM vs the one used to build Can you inspect Alternatively, you could try doing a shared LLVM build. That means passing Also:
Unless I'm misreading here, it looks like you're telling it to build into the same directory that you did the CMake build in. If so, that's not likely to go well in any case. |
llvm19-assert/lib/libLLVM.so does not exist (neither does a static version of it) |
The first build went into zig/build-master, the second into zig/stage3 |
Wait, what does that directory look like then? Since you specified it as a search prefix, I'd expect By the way, here are my (simplified) build steps in case it helps: $ cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH=/opt/llvm-19 -DCMAKE_INSTALL_PREFIX=debug -DZIG_SHARED_LLVM=ON -DZIG_NO_LIB=ON -DZIG_TARGET_MCPU=x86_64_v3
$ cmake --build build # build stage3
$ ./debug/bin/zig -Dno-lib -Denable-llvm # build stage4
$ ./zig-out/bin/zig -Dno-lib -Dno-bin -Dconfig_h=build/config.h -Denable-llvm test # run tests with stage4 |
llvm19-assert/lib
|
llvm19-assert/ (max depth 3)
|
First zig build seems to be successfully statically linked with LLVM:
|
Ah, I guess you didn't build LLVM with I guess you can do |
This is the output of
But I'm still confused about the problem. It looks like |
It can find the static libraries AFAICT. The problem is that the mangled symbol names don't match because of differences between libc++ and libstdc++. Notice how all the undefined symbols involve some kind of What's happening here is that you (reasonably) built LLVM against libstdc++ as that's your system C++ standard library. But something is going wrong in the Zig build process where libc++ (presumably the one bundled with Zig) is somehow entering the picture. Probably has something to do with this being a static build. Can you show the contents of FWIW, one way of side-stepping this issue is to just build LLVM with |
I've got a working build with zig-bootstrap now, not sure if you want to leave this issue open (as I've been following the instructions on https://github.com/ziglang/zig/wiki/Building-Zig-From-Source and https://github.com/ziglang/zig/wiki/How-to-build-LLVM,-libclang,-and-liblld-from-source#release pretty closely, I imagine this could be a common issue). Here's my config.h: config.h
Btw, I was wondering about the std::* references but there are also a lot clang::* and llvm::* references, too. However, I'm happy now; in case you want to track this issue down, I will assist you the best I can but I imagine you have better things to spend your time on. Maybe, this issue provides an incentive to further streamline the bootstrap process, e.g.
Anyway, thanks for your time and patience! |
Zig Version
0.14.0 (master bf6ee7c Jan 27 10:53)
Steps to Reproduce and Observed Behavior
cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="/home/ssmid/local/llvm19-assert" -DCMAKE_BUILD_TYPE=Release
andmake install
/home/ssmid/zig/build-master/stage3/bin/zig build -p stage3 --search-prefix /home/ssmid/local/llvm19-assert --zig-lib-dir /home/ssmid/zig/lib -Dstatic-llvm -Duse-llvm=true -Doptimize=ReleaseFast
Output
At least some if not all of the symbols are defined in the static libraries in
~/local/llvm19-assert
. The previous zig build did also work with those libraries.I'm getting more and more frustrated and I know 90% of the build complexities are caused by LLVM but isn't there a way to make the build process less error prone? I know, zig-bootstrap exists, but it also didn't work due to being out-of-date.
Expected Behavior
Working Zig compiler at stage3/
The text was updated successfully, but these errors were encountered: