You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As with vanilla C development, Zig should be able to link against standard shared libraries (e.g. pthread.so, mlx5.so, ibverbs.so). I cannot make this happen. I've played over several hours with CompileStep's options to no avail.
Although static link is generally preferred, in this case I want these libraries linked dynamically. No matter what I do, all successful builds give:
$ zig build
$ ldd ./zig-out/bin/zig-perftest
linux-vdso.so.1 (0x00007ffdd21da000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa1b901f000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa1b9249000)
$ file ./zig-out/bin/zig-perftest
zig-out/bin/zig-perftest: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
ldd does not show libibverbs, for example. I'm pretty sure Zig linked statically; regardless the behavior of the program is wrong. See below.
./scripts/setup_build_env. # adjust apt install packages as needed
zig build
./scripts/setup_run_env
./zig-out/bin/zig-perftest
stdout reports:
got 0 devices expect (2) devices
It should report (2) devices not 0.
Expected Behavior
Since the ZIG build does not work and does not produce the correct output, I'll give the expected output by showing what a C build of the same two .c files gives when built by gcc:
The zig code is a cannon shooting a fly. All it does is call a single C function ibv_get_device_list. A relevant difference between the correct behavior and Zig is how this symbol is linked:
# bad: how'd zig get the code for this anyway? it's probably from the static libibverbs.a
$ nm ./zig-out/bin/zig-perftest | grep ibv_get_device_list
000000000021d320 T ibv_get_device_list
# good: ibv_get_device_list is supposed to be undefined since it's extern in a linked shared library!
$ nm ./c/ib | grep ibv_get_device_list
U ibv_get_device_list@IBVERBS_1.1
The text was updated successfully, but these errors were encountered:
gshanemiller
changed the title
zig linker: cannot make zig link against shared (.so) system libraries
cannot link against shared system libraries -OR- task is bad/damaged
Mar 17, 2023
gshanemiller
changed the title
cannot link against shared system libraries -OR- task is bad/damaged
cannot link against shared system libraries -OR- ZIG task is bad/damaged
Mar 17, 2023
gshanemiller
changed the title
cannot link against shared system libraries -OR- ZIG task is bad/damaged
cannot link against shared system libraries -AND- ZIG task is bad
Mar 17, 2023
You may want to try reproducing again with a newer Zig release. For example a glibc build failure with zig in releases earlier than 0.12.0 was the cause of this one: rust-cross/cargo-zigbuild#255 (comment)
That said zig cc still fails with building a static binary, even when .a files are provided it still has an interpreter configured for some reason 🤷♂️ (resulting in a segfault) #4986 (comment)
Zig Version
0.11.0-dev.1987+a2c6ecd6d
Ubuntu 22.04LTS
Steps to Reproduce and Observed Behavior
This bug might be related to #14963
As with vanilla C development, Zig should be able to link against standard shared libraries (e.g. pthread.so, mlx5.so, ibverbs.so). I cannot make this happen. I've played over several hours with CompileStep's options to no avail.
Although static link is generally preferred, in this case I want these libraries linked dynamically. No matter what I do, all successful builds give:
ldd
does not showlibibverbs
, for example. I'm pretty sure Zig linked statically; regardless the behavior of the program is wrong. See below.To reproduce:
stdout reports:
It should report (2) devices not 0.
Expected Behavior
Since the ZIG build does not work and does not produce the correct output, I'll give the expected output by showing what a C build of the same two
.c
files gives when built by gcc:The zig code is a cannon shooting a fly. All it does is call a single C function
ibv_get_device_list
. A relevant difference between the correct behavior and Zig is how this symbol is linked:The text was updated successfully, but these errors were encountered: