nix icon indicating copy to clipboard operation
nix copied to clipboard

nix with ptrace feature fails to build on s390x+musl

Open alip opened this issue 5 months ago • 0 comments
trafficstars

Thanks for the awesome crate and great work! I am the main author of syd and we've been using nix in our project with great joy. Below is an error we have stumbled upon, thanks to help from Alpine Linux folks on s390x+musl with ptrace feature enabled.

Reference: https://gitlab.alpinelinux.org/alpine/aports/-/jobs/1884950 Excerpt:

error[E0308]: mismatched types
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nix-0.30.1/src/sys/ptrace/linux.rs:331:22
    |
331 |         libc::ptrace(request as RequestType, libc::pid_t::from(pid), addr, data)
    |         ------------ ^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
    |         |
    |         arguments to this function are incorrect
    |
note: function defined here
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/linux_like/linux/musl/mod.rs:927:12
    |
927 |     pub fn ptrace(request: c_int, ...) -> c_long;
    |            ^^^^^^
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
    |
331 |         libc::ptrace((request as RequestType).try_into().unwrap(), libc::pid_t::from(pid), addr, data)
    |                      +                      +++++++++++++++++++++
error[E0308]: mismatched types
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nix-0.30.1/src/sys/ptrace/linux.rs:505:13
    |
504 |         libc::ptrace(
    |         ------------ arguments to this function are incorrect
505 |             request as RequestType,
    |             ^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
    |
note: function defined here
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/linux_like/linux/musl/mod.rs:927:12
    |
927 |     pub fn ptrace(request: c_int, ...) -> c_long;
    |            ^^^^^^
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
    |
505 |             (request as RequestType).try_into().unwrap(),
    |             +                      +++++++++++++++++++++
error[E0308]: mismatched types
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nix-0.30.1/src/sys/ptrace/linux.rs:523:13
    |
522 |         Errno::result(libc::ptrace(
    |                       ------------ arguments to this function are incorrect
523 |             request as RequestType,
    |             ^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
    |
note: function defined here
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/linux_like/linux/musl/mod.rs:927:12
    |
927 |     pub fn ptrace(request: c_int, ...) -> c_long;
    |            ^^^^^^
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
    |
523 |             (request as RequestType).try_into().unwrap(),
    |             +                      +++++++++++++++++++++
error[E0308]: mismatched types
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nix-0.30.1/src/sys/ptrace/linux.rs:536:13
    |
535 |         libc::ptrace(
    |         ------------ arguments to this function are incorrect
536 |             Request::PTRACE_SETOPTIONS as RequestType,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
    |
note: function defined here
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/linux_like/linux/musl/mod.rs:927:12
    |
927 |     pub fn ptrace(request: c_int, ...) -> c_long;
    |            ^^^^^^
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
    |
536 |             (Request::PTRACE_SETOPTIONS as RequestType).try_into().unwrap(),
    |             +                                         +++++++++++++++++++++
error[E0308]: mismatched types
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nix-0.30.1/src/sys/ptrace/linux.rs:560:13
    |
559 |         libc::ptrace(
    |         ------------ arguments to this function are incorrect
560 |             Request::PTRACE_SETSIGINFO as RequestType,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
    |
note: function defined here
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/linux_like/linux/musl/mod.rs:927:12
    |
927 |     pub fn ptrace(request: c_int, ...) -> c_long;
    |            ^^^^^^
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
    |
560 |             (Request::PTRACE_SETSIGINFO as RequestType).try_into().unwrap(),
    |             +                                         +++++++++++++++++++++

alip avatar Jun 05 '25 08:06 alip