Open demizer opened 3 years ago
zig c++
is trying to statically link all the libraries you've specified and LLD rightfully complains because there's no .a
available on the system.
Using clang++
instead of zig c++
works because it defaults to dynamic linking every library and if you specify -static
you're greeted with a bunch of warnings:
warning: -lgdk-3: 'linker' input unused [-Wunused-command-line-argument]
@LemonBoy thanks for the reply.
Arch Linux does not package static libraries and it would be a huge mess to compile all of these dependencies to get the static libs. As I stated in the bug description, this worked before with zig c++, does anyone know if this feature of can be disabled? When i try to compile with -shared
i get new errors:
lld: error: attempted static link of dynamic object /lib64/libwebkit2gtk-4.0.so
lld: error: attempted static link of dynamic object /lib64/libgtk-3.so
lld: error: attempted static link of dynamic object /lib64/libgdk-3.so
lld: error: attempted static link of dynamic object /lib64/libz.so
lld: error: attempted static link of dynamic object /lib64/libpangocairo-1.0.so
lld: error: attempted static link of dynamic object /lib64/libpango-1.0.so
lld: error: attempted static link of dynamic object /lib64/libharfbuzz.so
lld: error: attempted static link of dynamic object /lib64/libatk-1.0.so
lld: error: attempted static link of dynamic object /lib64/libcairo-gobject.so
lld: error: attempted static link of dynamic object /lib64/libcairo.so
lld: error: attempted static link of dynamic object /lib64/libgdk_pixbuf-2.0.so
lld: error: attempted static link of dynamic object /lib64/libsoup-2.4.so
lld: error: attempted static link of dynamic object /lib64/libgio-2.0.so
lld: error: attempted static link of dynamic object /lib64/libjavascriptcoregtk-4.0.so
lld: error: attempted static link of dynamic object /lib64/libgobject-2.0.so
lld: error: attempted static link of dynamic object /lib64/libglib-2.0.so
As I stated in the bug description, this worked before with zig c++, does anyone know if this feature of can be disabled?
It's not a feature, it's a bug :)
zig cc
keeps invoking the linker even though -c
is specified (the presence of -c
, -S
or -E
skips the linker invocation.
It doesn't also handle the -c <file1> <file2> -o <name>
case that clang/gcc rightfully reject as you can't specify a single -o
for two files.
It doesn't also handle the
-c <file1> <file2> -o <name>
case that clang/gcc rightfully reject as you can't specify a single-o
for two files.
Zig actually supports this case, taking advantage of the -r
flag of LLD to link multiple objects into one. However that only works for WASM and ELF.
For the purposes of this issue, I think for 0.7.1 this will look like simply omitting the -l
arguments when the output mode is an object in the LLD linker line. That will only solve it for ELF and WASM.
For completely solving this issue, it will look like skipping the linking step altogether when building objects. This will be more involved because we currently rely on the fact that the linker step produces a new build artifact based on another one. So we will either do a simple copy or make the caching system more complex.
I'm getting the following error with zig build (c++).
build.zig
When I change
zig c++
tog++
the it works. I haven't used this bit of my project in a while, so not sure when it broke. I assume it occurred after the llvm 11 upgrade.My setup:
OS: Arch Linux Zig Version: 0.7.0 installed from the tar.gz available on the downloads page.
This looks similar to #6996