Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to compile on linux aarch64 #295

Closed
antimora opened this issue Mar 16, 2022 · 4 comments · Fixed by #296 or #298
Closed

Fails to compile on linux aarch64 #295

antimora opened this issue Mar 16, 2022 · 4 comments · Fixed by #296 or #298

Comments

@antimora
Copy link

I have a mac with Apple M1 Pro CPU and I use a docker with ubuntu:20.04 image. When I include numpy = "0.16" as my dependency, it fails to compile with the following error:

   Compiling numpy v0.16.1
error[E0600]: cannot apply unary operator `-` to type `u8`
  --> /home/dev/.cargo/registry/src/github.com-1ecc6299db9ec823/numpy-0.16.1/src/npyffi/flags.rs:74:42
   |
74 | pub const NPY_ALIGNED_STRUCT: npy_char = -128; // 0x80
   |                                          ^^^^ cannot apply unary operator `-`
   |
   = note: unsigned values cannot be negated

For more information about this error, try `rustc --explain E0600`.
error: could not compile `numpy` due to previous error

From the documentation and source code, it appears npy_char, which is c_char, will be u8.

I am not familiar with the artitecture of rust-numpy to offer a solution or PR. Could anyone suggest a quick fix for this issue?

@antimora
Copy link
Author

The lib compiles fine with numpy = "0.16.0". So it appears a recent change (5a78a87) introduced the breakage.

@aldanor, could you please look into the error? I am guessing the -128 assignment should have been just 0x80.

@adamreichold
Copy link
Member

The lib compiles fine with numpy = "0.16.0". So it appears a recent change (5a78a87) introduced the breakage.

This seems inconsistent as that commit is also part of v0.16.0. Did you mean numpy = "0.15.0"?

@adamreichold
Copy link
Member

I am guessing the -128 assignment should have been just 0x80.

This does not work on platforms where c_char = i8 as the compiler errors out due to 0x80 not being representable for the type.

I think explicitly casting should work in both cases. Could you give #296 a try?

@antimora
Copy link
Author

@adamreichold the build works but I have a review comment in your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants