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

sha-1 0.9.6 fails to cross build on aarch64-unknown-linux-musl #273

Closed
jszwedko opened this issue May 12, 2021 · 5 comments
Closed

sha-1 0.9.6 fails to cross build on aarch64-unknown-linux-musl #273

jszwedko opened this issue May 12, 2021 · 5 comments

Comments

@jszwedko
Copy link

This appears to work on 0.9.5.

➜  hash git:(master) ✗ cat Cargo.toml
[package]
name = "hash"
version = "0.1.0"
authors = ["Jesse Szwedko <jesse@szwedko.me>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sha-1 = "0.9.6"

➜  hash git:(master) ✗ cat src/main.rs
fn main() {
    println!("Hello, world!");
}

➜  hash git:(master) ✗ cross build --target aarch64-unknown-linux-musl
   Compiling cpufeatures v0.1.1
   Compiling generic-array v0.14.4
error[E0432]: unresolved import `libc::HWCAP_AES`
  --> /cargo/registry/src/github.com-1ecc6299db9ec823/cpufeatures-0.1.1/src/aarch64.rs:55:21
   |
55 |               pub use libc::$hwcap;
   |                       ^^^^^^^^^^^^ no `HWCAP_AES` in the root
...
70 | / __expand_check_macro! {
71 | |     ("aes",  HWCAP_AES),  // Enable AES support.
72 | |     ("sha2", HWCAP_SHA2), // Enable SHA1 and SHA256 support.
73 | |     ("sha3", HWCAP_SHA3), // Enable SHA512 and SHA3 support.
74 | | }
   | |_- in this macro invocation
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `cpufeatures`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
@tarcieri
Copy link
Member

tarcieri commented May 12, 2021

Definitely related to #268.

I'm not quite sure what's at fault here though... possibly the libc crate? It looks like musl defines HWCAP_AES and it was added about 5 years ago:

https://github.com/bminor/musl/blob/4433115/arch/aarch64/bits/hwcap.h#L4

Edit: definitely looks like a problem with the libc crate. Here's the PR which added support for glibc, which was merged a little over a year ago:

https://github.com/rust-lang/libc/pull/1638/files

It looks like a similar PR would be needed to add them here (possibly even copy/paste from the glibc bindings):

https://github.com/rust-lang/libc/blob/master/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs

It looks like there's even a TODO for it here (although not a GitHub issue, AFAICT):

https://github.com/rust-lang/libc/blob/ed1399a/libc-test/semver/TODO-linux.txt

In the meantime we can gate CPU feature detection on target_env = "gnu" until libc has been updated.

@tarcieri
Copy link
Member

Opened an issue on the libc crate:

rust-lang/libc#2171

I'd say for now stick with sha-1 v0.9.5 and I will try to release a v0.9.7 that addresses this in the next day or so.

@jszwedko
Copy link
Author

Thanks for the quick response! I'll keep an eye on that issue.

@tarcieri
Copy link
Member

tarcieri commented May 13, 2021

@jszwedko I just published cpufeatures v0.1.2 which I think should both address this and allow feature detection to work on musl targets.

Can you try cargo update -p cpufeatures and let me know if it fixes the problem?

(Sidebar: we should probably add some musl targets to CI)

@jszwedko
Copy link
Author

@tarcieri this looks great, thanks for the quick fix!

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

No branches or pull requests

2 participants