Compiling rust zmq-sys fails with cargo2nix


when I try to compile my rust project that is using zmq with my flake that utilizes cargo2nix, I get the following error message:

error: builder for '/nix/store/4swqv93cnkiqjbqzq5m0hf1sr1vq7cxb-crate-zmq-sys-0.12.0.drv' failed with exit code 101;
       last 10 log lines:
       >   --- stderr
       >   cc1: fatal error: /build/zeromq-src-0.2.6+4.3.4/src/strlcpy.c: No such file or directory
       >   compilation terminated.
       >   error occurred: Command "/nix/store/3hbxw05vfs6m1155xa6pvribs3bv777n-gcc-wrapper-12.2.0/bin/c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/build/zeromq-src-0.2.6+4.3.4/vendor/include" "-I" "/build/zeromq-src-0.2.6+4.3.4/vendor/src" "-I" "/build/zeromq-src-0.2.6+4.3.4/vendor/src" "-I" "/build/zeromq-src-0.2.6+4.3.4/vendor/external/sha1" "-I" "/build/zmq-sys-0.12.0/target/x86_64-unknown-linux-gnu/release/build/zmq-sys-f65ad9a14c492c23/out" "-Wall" "-Wextra" "-DZMQ_BUILD_TESTS=OFF" "-DZMQ_USE_CV_IMPL_STL11=1" "-DZMQ_STATIC=1" "-DZMQ_USE_BUILTIN_SHA1=1" "-DZMQ_HAVE_WS=1" "-DZMQ_IOTHREAD_POLLER_USE_EPOLL=1" "-DZMQ_POLL_BASED_ON_POLL=1" "-DZMQ_HAVE_IPC=1" "-DHAVE_STRNLEN=1" "-DZMQ_HAVE_UIO=1" "-o" "/build/zmq-sys-0.12.0/target/x86_64-unknown-linux-gnu/release/build/zmq-sys-f65ad9a14c492c23/out/lib/e9604ab5dbd5f1ec-sha1.o" "-c" "/build/zeromq-src-0.2.6+4.3.4/vendor/external/sha1/sha1.c" with args "c++" did not execute successfully (status code exit status: 1).
       > /nix/store/gv2cl6qvvslz5h15vqd89f1rpvrdg5yc-stdenv-linux/setup: line 146: pop_var_context: head of shell_variables not a function context
       For full logs, run 'nix log /nix/store/4swqv93cnkiqjbqzq5m0hf1sr1vq7cxb-crate-zmq-sys-0.12.0.drv'.

So far, I found the that something in the buildchain is modifing the Cargo.toml of zmq-sys and removing the dependency for
zeromq-src = { version = "0.2.1" }
which includes strlcpy.c.

In the build directory the a kept by using --keep-failed there is a Cargo.toml.orig that has that dependency and a Cargo.toml that does not have it. In the official repository of zmq-sys that dependency is also present.

My normal cargo build command compiles without any errors.

Any ideas what could modify the dependencies and why?

1 Like

We got this working by removing glibc as a buildInput