-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
zig c++
does not include stdc++
, clang++
does
#9832
Comments
Which object contains No single executable/binary should use 2 different c++ libraries. The solve to this is to build protobuf (and any of its dependencies that are c++ releated) with |
no, |
protobuf might be another issue here but let's push that aside for now. How is |
Sure, here is what currently works
Now with your information, I tried switching both of those
|
re: Also this is a bit tricky, would like to see the include dir search list used for .cpp → .o
so something like this: rm -fr zig-cache
zig build-lib src/graph.cc -lc++ ..... --verbose-cc
zig clang ..... -v which should yield something like this:
|
C++ pretends to have an ABI, but it's a lie. That's the crucial problem here. Zig provides libc++, however the libc++ that zig provides cannot be mixed with any C++ objects compiled from other compilers. If you do, you get undefined behavior. So you can't use I'm upset that C++ works this way but there is nothing we can do about it.
|
To clarify, even combining output of |
If the input file were C++ code, yes. You can learn about more intricacies of C++ to find out what versions of compilers do or don't work together, or what features of the language are affected by this ABI mismatch. But the simplest way to remember it is that you have to use the same C++ compiler for all C++ code. |
The upshot here is that if you have |
yes, the system c++ compiler works fine. I just would have liked to terminate a |
If we want to support that use case, it will require |
Want to reduce my c++ usage in order to preserve my mental health :P This should build fine anywhere zig is present. clang++ is still a dependency since the zig c++ compiler differs in ABI to clang/gcc. See: ziglang/zig#9832
I hit a case where
zig c++
is not a drop-in replacement for a clang that uses the equivalent llvm version (llvm 12, zig 0.8.0, clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04)This command works
while this does not
The zig verson reports missing c++ stdlib symbols, e.g.
Here are the full linker invocations:
Clang:
Zig c++
The difference that makes a difference is these arguments that clang does give to the linker, and zig does not:
The zig linker invocation does include
But that is apparently not enough? Also I tried
(include the gnu path and the stdc++ flag) in the zig c++ command, but the
-lstdc++
flag is not present in the linker invocation. So-lstdc++
to make it to the linker, either withzig c++
orzig build-exe
The text was updated successfully, but these errors were encountered: