0.12.1+1.56.2-patched failed to link systemd
fortime opened this issue · 2 comments
fortime commented
Describe the bug
I am building an executable with grpc-rs (this commit) on Arch Linux. Linking is failed because of -lsystemd
is not provided.
Error log:
/usr/bin/ld: /run/user/1000/cargo-target/debug/deps/libgrpcio_sys-95ecc2781c08cbb9.rlib(systemd_utils.cc.o): in function `set_matching_sd_unix_fd(grpc_tcp_server*, grpc_resolved_address const*, int, int)':
/home/fortime/.cargo/git/checkouts/grpc-rs-f94f0a462dfbe83f/339c325/grpc-sys/grpc/src/core/lib/iomgr/systemd_utils.cc:40: undefined reference to `sd_is_socket_unix'
/usr/bin/ld: /run/user/1000/cargo-target/debug/deps/libgrpcio_sys-95ecc2781c08cbb9.rlib(systemd_utils.cc.o): in function `set_matching_sd_inet_fd(grpc_tcp_server*, grpc_resolved_address const*, int, int, int, int)':
/home/fortime/.cargo/git/checkouts/grpc-rs-f94f0a462dfbe83f/339c325/grpc-sys/grpc/src/core/lib/iomgr/systemd_utils.cc:53: undefined reference to `sd_is_socket_inet'
/usr/bin/ld: /home/fortime/.cargo/git/checkouts/grpc-rs-f94f0a462dfbe83f/339c325/grpc-sys/grpc/src/core/lib/iomgr/systemd_utils.cc:54: undefined reference to `sd_is_socket_sockaddr'
/usr/bin/ld: /run/user/1000/cargo-target/debug/deps/libgrpcio_sys-95ecc2781c08cbb9.rlib(systemd_utils.cc.o): in function `set_matching_sd_fds(grpc_tcp_server*, grpc_resolved_address const*, int)':
/home/fortime/.cargo/git/checkouts/grpc-rs-f94f0a462dfbe83f/339c325/grpc-sys/grpc/src/core/lib/iomgr/systemd_utils.cc:69: undefined reference to `sd_listen_fds'
collect2: error: ld returned 1 exit status
some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
use the `-l` flag to specify native libraries to link
use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname
To Reproduce
Steps to reproduce the behavior:
Build a executable with grpc-rs on Linux system which has libsystemd.so installed and runs pkg-config --print-provides systemd
successfully.
Expected behavior
Build successfully.
System information
- CPU architecture: x86_64
- Distribution and kernel version: Arch Linux, 6.4.3-arch1-2
- systemd: 253
Additional context
grpc introduces systemd dependecy at this PR, it will be built with systemd if systemd is found by pkg-config
. But grpc-sys doesn't tell cargo to link with -lsystemd
.
I can build the executable with patch in grpc-sys/build.rs:
println!("cargo:rustc-link-lib=systemd");
BusyJay commented
Can you submit the patch?
fortime commented
Ok, I will try.