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

Build for riscv64gc-unknown-linux-gnu failed. #1419

Closed
xfbs opened this issue Oct 24, 2021 · 9 comments
Closed

Build for riscv64gc-unknown-linux-gnu failed. #1419

xfbs opened this issue Oct 24, 2021 · 9 comments

Comments

@xfbs
Copy link
Contributor

xfbs commented Oct 24, 2021

Steps to reproduce. I did this on latested Debian, use a docker container if you don't have it.

apt update
apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu 
export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/riscv64-linux-gnu-gcc
cargo build --target riscv64gc-unknown-linux-gnu
cargo build --target riscv64gc-unknown-linux-gnu --tests

I'm able to fix some simple compilation errors in the beginning by adding RISCV to the architectures:

diff --git a/include/ring-core/base.h b/include/ring-core/base.h
index f1a027d1a..92c9a4372 100644
--- a/include/ring-core/base.h
+++ b/include/ring-core/base.h
@@ -91,6 +91,10 @@
 #define OPENSSL_MIPS64
 #elif defined(__wasm__)
 #define OPENSSL_32_BIT
+#elif __riscv && __riscv_xlen == 64
+#define OPENSSL_64_BIT
+#elif __riscv && __riscv_xlen == 32
+#define OPENSSL_32_BIT
 #else
 // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement,
 // little-endian architectures. Functions will not produce the correct answer

This is all I've gotten to so far.

@briansmith
Copy link
Owner

We have Rust or C implementations for almost every algorithm, so most things work on every architecture. Unfortunately, there are one or two cases where we don't have an architecture-neutral implementation yet.

In the case of RISC-V, because it doesn't have a carry flag at all, we may also need to implement some bignum algorithms differently, since the current C implementations are optimized for having a carry flag presently.

@xfbs
Copy link
Contributor Author

xfbs commented Dec 9, 2021

Anything I can do to help? I'm not very familiar with the codebase, but I think if you point me in the right direction I can possibly figure this out. I have RISC-V hardware that we can use for testing things (but obviously cross-compilation + qemu-user-static works, too). Am hoping to be able to help get ring working because I'd like to be able to build some stuff for RISC-V that depend on it!

@kirana1996
Copy link

@xfbs

 While trying to run  a sample ring application, I am facing the error as below,

error: failed to run custom build command for ring v0.16.20

Caused by:
process didn't exit successfully: /home/root/ring/target/debug/build/ring-76f60cea94175700/build-script-build (exit status: 101)
--- stderr
thread 'main' panicked at 'called Option::unwrap() on a None value', /home/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:358:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

Below is the Cargo.toml for your reference,

[package]
name = "ring"
version = "0.1.0"
edition = "2018"

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

[dependencies]
ring = "0.16.20"
hex = "0.4.3"
base64 = "0.13.0"
openssl = "0.10.35"

Could you please help me with the issue?

@xfbs
Copy link
Contributor Author

xfbs commented Dec 9, 2021

@kirana1996 are you building that on RISC-V, and if so, how?

@kirana1996
Copy link

kirana1996 commented Dec 9, 2021

@xfbs Yes we are building on riscv64. Created Cargo.toml, Cargo.lock and src/main.rs have test program. In same directory i am trying for ´ćargo run´.
It will download ring and all dependency packages in bellow path and will use it for compiling the application.
home/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20.

@ghost
Copy link

ghost commented Dec 11, 2021

@xfbs I did a quick hack at https://github.com/amock/ring/commit/3273fc2d17cf118d6bd9f162aeaf963967406fe7 to get this to build on ppc64le. I think you can do something similar to get this to build on riscv64.

@kirana1996
Copy link

@amock, Actually when running sample ring application depends on Cargo.toml, It downloads the ring to ".cargo/registry/src/github-xxx" path,but but this has no support for riscv64. i want know where it was downloading sources from and which file have look,can please help on this.so we can able to change commit id.

@briansmith
Copy link
Owner

I'm closing this as a duplicate of #1455, which is more generally about supporting little-endian targets we don't have assembly language code for.

@omac777
Copy link

omac777 commented Feb 4, 2023

@kirana1996 I got the same error today on Debian Image 69 in the Starfive VisionFive 2 riscv SBC, I installed https://rustup.rs, the apt-get install build-essential,clang-15-tools, lld-15, llvm 15.

Then did:

cargo install -f sccache

Here is the error from that:

error: failed to run custom build command for `ring v0.16.20`
Caused by:
  process didn't exit successfully: `/tmp/cargo-installSTqtew/release/build/ring-9205b437b9a0a202/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:358:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `sccache v0.3.3`, intermediate artifacts can be found at `/tmp/cargo-installSTqtew`

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

4 participants