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

cargo build fails on Raspberry Pi3B. "Unsupported target architecture" for sha2-asm. #1278

Closed
dantrevino opened this issue Feb 18, 2020 · 7 comments · Fixed by #1354
Closed
Assignees

Comments

@dantrevino
Copy link
Contributor

Mainly for visibility. Not a bug in blockstack-core.

We ran into this while trying to build on Raspberry Pi.

error: failed to run custom build command for `sha2-asm v0.5.3`

Caused by:
  process didn't exit successfully: `/home/pi/blockstack-core/target/debug/build/sha2-asm-a58e6c6d2b010656/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unsupported target architecture', /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/sha2-asm-0.5.3/build.rs:13:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
@dantrevino dantrevino changed the title cargo build fails on Raspberry Pi4B. "Unsupported target architecture" cargo build fails on Raspberry Pi4B. "Unsupported target architecture" fro sha2-asm. Feb 18, 2020
@dantrevino dantrevino changed the title cargo build fails on Raspberry Pi4B. "Unsupported target architecture" fro sha2-asm. cargo build fails on Raspberry Pi4B. "Unsupported target architecture" for sha2-asm. Feb 18, 2020
@jcnelson
Copy link
Member

Thanks @dantrevino. I think the fix here is going to be making it so Cargo uses sha2-asm when the architecture is supported, and plain-old sha2 otherwise. Not a Cargo wiz, so I need to figure out how to do this.

@jcnelson jcnelson self-assigned this Feb 18, 2020
@dantrevino
Copy link
Contributor Author

dantrevino commented Mar 19, 2020

My understanding is that there is no way, currently, to dynamically include/exclude architecture-dependent features. It looks like rust-lang is tracking a fix for this in their nightly branch but implementation timeline seems indeterminate. #7914.

In the meantime, I've been able to consistently get working binaries for ARMv7 by removing the 'asm' feature and cross-compiling via cross. I've documented the steps here: https://gitlab.com/riot.ai/stacks-blockchain-rpi/-/blob/master/README-Cross.md

Simply removing the 'asm' feature and trying to build directly on Pi has not worked for me yet. I'm still working on testing different hardware variations.

@dantrevino dantrevino changed the title cargo build fails on Raspberry Pi4B. "Unsupported target architecture" for sha2-asm. cargo build fails on Raspberry Pi3B. "Unsupported target architecture" for sha2-asm. Mar 19, 2020
@dantrevino
Copy link
Contributor Author

Just following up ... building directly on a Pi3B fails consistently with either unable to allocate memory, or over-heating. Confirmed by myself and @fluidvoice that build normally hits 2GB-ish of memory usage. Typical failure looks like:

memory allocation of 75497472 bytes failed
error: could not compile `blockstack-core`.

@dantrevino
Copy link
Contributor Author

Confirm stacks blockchain builds and runs fine on a Pi 4B with >= 2GB of RAM, with removal of "asm" from sha2 features.

@fluidvoice
Copy link

Confirm stacks blockchain builds and runs fine on a Pi 4B with >= 2GB of RAM, with removal of "asm" from sha2 features.

So how do I get around this compile problem? I have Ubuntu 19.10.1 running fine on my Pi4 now.

@dantrevino
Copy link
Contributor Author

Sorry it's not spelled out clearly. As @jcnelson mentions above you have to remove the 'asm' feature from Cargo.toml and use plain old sha2. Until a better workaround can be submitted as a PR here, I'm maintaining an up-to-date mirror with the change in my gitlab repo mentioned above.

@fluidvoice
Copy link

fluidvoice commented Mar 22, 2020

Sorry it's not spelled out clearly. As @jcnelson mentions above you have to remove the 'asm' feature from Cargo.toml and use plain old sha2. Until a better workaround can be submitted as a PR here, I'm maintaining an up-to-date mirror with the change in my gitlab repo mentioned above.

ah ok. I've never used Rust before so needed to find what explicitly to do, namely commenting out this line. The build completed OK now on my Pi 4B 4GB RAM on Ubuntu 19.10.1 Mate DE.

[dependencies.sha2]
version = "0.8.0"
# features = ["asm"]

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

Successfully merging a pull request may close this issue.

3 participants