nix-rust/nix

Cross compilation fails for target armv7-unknown-linux-gnueabihf

Closed this issue · 6 comments

System: ubuntu
rustc: 1.34.2
Cargo.toml:

[package]
name = "example"
version = "0.1.0"
authors = ["Julian Gaal <...>"]
edition = "2018"

[dependencies]
mpu6050 = { path = "../" } 
i2cdev = "0.4.1"
linux-embedded-hal = "0.2.2"

Error with command cargo build --release --target=armv7-unknown-linux-gnueabihf:

error[E0425]: cannot find value `PTRACE_GETFPXREGS` in module `libc`
  --> /home/julian/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.11.0/src/sys/ptrace.rs:77:9
   |
77 |         PTRACE_GETFPXREGS,
   |         ^^^^^^^^^^^^^^^^^
help: a constant with a similar name exists
   |
77 |         PTRACE_GETFPREGS,
   |         ^^^^^^^^^^^^^^^^
help: possible candidate is found in another module, you can import it into scope
   |
3  | use sys::ptrace::Request::PTRACE_GETFPXREGS;
   |

error[E0425]: cannot find value `PTRACE_SETFPXREGS` in module `libc`
  --> /home/julian/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.11.0/src/sys/ptrace.rs:84:9
   |
84 |         PTRACE_SETFPXREGS,
   |         ^^^^^^^^^^^^^^^^^
help: a constant with a similar name exists
   |
84 |         PTRACE_SETFPREGS,
   |         ^^^^^^^^^^^^^^^^
help: possible candidate is found in another module, you can import it into scope
   |
3  | use sys::ptrace::Request::PTRACE_SETFPXREGS;
   |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `nix`.

Not sure which this is more related to: nix or libc. Cheers

FYI the issue is that for some targets, not only this one (e.g. IIRC sparc64 as well), these constants are not available in the Linux headers, and the ptrace APIs does not expect to be called with them. C code trying to use these constants on these targets fails to compile as well.

I am open to suggestions about what could libc do to smooth this transition out (we could revert the removal, and deprecating them, maybe giving them some "meaningful" values on these targets, like that of some other constants, but I don't know what those would be). From nix POV, IIUC the long term move should be to use these constants only on targets in which they are available.

This issue is already fixed in Nix's master branch (by 196b05b). However, I haven't pushed a new release yet. Unfortunately, I'll have to publish patch releases for every major release of Nix that's still in use 😢. As a workaround, you can try something like this:

Cargo.toml

[patch.crates-io]
nix = { git = "https://github.com/nix-rust/nix/, rev = "196b05b5c7b" }

Any chance we can get this backported to 0.13?

@kpcyrd I just published 0.13.1. Enjoy.

Any chance for a back port to 0.11?

Already done as of 7-June. Let me know if it doesn't work for you. https://crates.io/crates/nix/0.11.1 .