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

Add support for RISC-V #1182

Closed
Tracked by #1522
advancedwebdeveloper opened this issue Jan 27, 2021 · 14 comments
Closed
Tracked by #1522

Add support for RISC-V #1182

advancedwebdeveloper opened this issue Jan 27, 2021 · 14 comments
Milestone

Comments

@advancedwebdeveloper
Copy link

Hi.

Looks like there is no support for RISC-V arch.

I was trying to build https://github.com/pravega/pravega-client-rust .
CC @Tristan1900 @zwx14700 @shrids .

Here is what I tried:

$ export RUST_BACKTRACE=1
$ cargo test
Compiling ring v0.16.19
Compiling openssl-sys v0.9.60
Compiling http-body v0.3.1
Compiling http-body v0.4.0
error: failed to run custom build command for ring v0.16.19

Caused by:
process didn't exit successfully: /home/ivan/pravega-client-rust/target/debug/build/ring-870234217d8e35d8/build-script-build (exit code: 101)
--- stderr
thread 'main' panicked at 'called Option::unwrap() on a None value', /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.19/build.rs:375:10
stack backtrace:
0: rust_begin_unwind
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
1: core::panicking::panic_fmt
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/panicking.rs:92:14
2: core::panicking::panic
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/panicking.rs:50:5
3: core::option::Option::unwrap
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/option.rs:386:21
4: build_script_build::build_c_code
at ./build.rs:369:34
5: build_script_build::ring_build_rs_main
at ./build.rs:296:5
6: build_script_build::main
at ./build.rs:257:13
7: core::ops::function::FnOnce::call_once
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed

@advancedwebdeveloper
Copy link
Author

$ cat /proc/cpuinfo
processor : 0
hart : 1
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

processor : 1
hart : 2
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

processor : 2
hart : 3
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

processor : 3
hart : 4
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

$ lscpu
Architecture: riscv64
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 4
L1i cache: 64 KiB

@briansmith
Copy link
Owner

thread 'main' panicked at 'called Option::unwrap() on a None value', /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.19/build.rs:375:10

This will probably be fixed by #1174.

@advancedwebdeveloper
Copy link
Author

It does not explain how to contribute into RISC-V port and how (at least) to allow the compilation of the crate.

@briansmith briansmith changed the title thread 'main' panicked at 'called Option::unwrap() on a None value', while building pravega-client-rust (on RISC-V) Add support for RISC-V Jan 28, 2021
@briansmith
Copy link
Owner

It does not explain how to contribute into RISC-V port and how (at least) to allow the compilation of the crate.

The work we're doing to enable all the features on wasm32, MIPS, etc. will enable ring to work on RISC-V. Then we can add CI/CD jobs that verify ring builds for RISC-V. Ideally we'd also have optimized assembly for RISC-V too, eventually.

@bernardoaraujor
Copy link

I'm also looking forward to RISC-V support!
Can we expect that for v0.17.0?

@bernardoaraujor
Copy link

While trying to build v0.17.0-alpha.10 for qemuriscv64:

|   In file included from include/ring-core/aes.h:52,
|                    from crypto/fipsmodule/aes/aes_nohw.c:15:
|   include/ring-core/base.h:99:2: error: #error "Unknown target CPU"
|      99 | #error "Unknown target CPU"
|         |  ^~~~~
|   In file included from crypto/fipsmodule/aes/aes_nohw.c:17:
|   crypto/fipsmodule/aes/../../internal.h:172:2: error: #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
|     172 | #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
|         |  ^~~~~
|   crypto/fipsmodule/aes/../../internal.h:185:15: error: unknown type name 'crypto_word'
|     185 | static inline crypto_word value_barrier_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:185:43: error: unknown type name 'crypto_word'
|     185 | static inline crypto_word value_barrier_w(crypto_word a) {
|         |                                           ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:210:15: error: unknown type name 'crypto_word'
|     210 | static inline crypto_word constant_time_msb_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:210:47: error: unknown type name 'crypto_word'
|     210 | static inline crypto_word constant_time_msb_w(crypto_word a) {
|         |                                               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:215:15: error: unknown type name 'crypto_word'
|     215 | static inline crypto_word constant_time_is_zero_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:215:51: error: unknown type name 'crypto_word'
|     215 | static inline crypto_word constant_time_is_zero_w(crypto_word a) {
|         |                                                   ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:230:15: error: unknown type name 'crypto_word'
|     230 | static inline crypto_word constant_time_is_nonzero_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:230:54: error: unknown type name 'crypto_word'
|     230 | static inline crypto_word constant_time_is_nonzero_w(crypto_word a) {
|         |                                                      ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:235:15: error: unknown type name 'crypto_word'
|     235 | static inline crypto_word constant_time_eq_w(crypto_word a,
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:235:46: error: unknown type name 'crypto_word'
|     235 | static inline crypto_word constant_time_eq_w(crypto_word a,
|         |                                              ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:236:48: error: unknown type name 'crypto_word'
|     236 |                                                crypto_word b) {
|         |                                                ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:243:15: error: unknown type name 'crypto_word'
|     243 | static inline crypto_word constant_time_select_w(crypto_word mask,
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:243:50: error: unknown type name 'crypto_word'
|     243 | static inline crypto_word constant_time_select_w(crypto_word mask,
|         |                                                  ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:244:52: error: unknown type name 'crypto_word'
|     244 |                                                    crypto_word a,
|         |                                                    ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:245:52: error: unknown type name 'crypto_word'
|     245 |                                                    crypto_word b) {
|         |                                                    ^~~~~~~~~~~
|   thread 'main' panicked at 'execution failed', /home/bear/develop/oe-ada/build/tmp/work/riscv64-poky-linux/rustls/0.19.0.AUTOINC+c00aa17106-r0/cargo_home/registry/src/github.com-1ecc6299db9ec823/ring-0.17.0-alpha.10/build.rs:690:9
|   stack backtrace:
|      0: std::panicking::begin_panic
|      1: build_script_build::run_command
|      2: build_script_build::compile
|      3: build_script_build::build_library::{{closure}}
|      4: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
|      5: core::option::Option<T>::map
|      6: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
|      7: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
|      8: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
|      9: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
|     10: core::iter::traits::iterator::Iterator::collect
|     11: build_script_build::build_library
|     12: build_script_build::build_c_code::{{closure}}
|     13: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
|     14: build_script_build::build_c_code
|     15: build_script_build::ring_build_rs_main
|     16: build_script_build::main
|     17: core::ops::function::FnOnce::call_once
|   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
|   In file included from include/ring-core/aes.h:52,
|                    from crypto/fipsmodule/aes/aes_nohw.c:15:
|   include/ring-core/base.h:99:2: error: #error "Unknown target CPU"
|      99 | #error "Unknown target CPU"
|         |  ^~~~~
|   In file included from crypto/fipsmodule/aes/aes_nohw.c:17:
|   crypto/fipsmodule/aes/../../internal.h:172:2: error: #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
|     172 | #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
|         |  ^~~~~
|   crypto/fipsmodule/aes/../../internal.h:185:15: error: unknown type name 'crypto_word'
|     185 | static inline crypto_word value_barrier_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:185:43: error: unknown type name 'crypto_word'
|     185 | static inline crypto_word value_barrier_w(crypto_word a) {
|         |                                           ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:210:15: error: unknown type name 'crypto_word'
|     210 | static inline crypto_word constant_time_msb_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:210:47: error: unknown type name 'crypto_word'
|     210 | static inline crypto_word constant_time_msb_w(crypto_word a) {
|         |                                               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:215:15: error: unknown type name 'crypto_word'
|     215 | static inline crypto_word constant_time_is_zero_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:215:51: error: unknown type name 'crypto_word'
|     215 | static inline crypto_word constant_time_is_zero_w(crypto_word a) {
|         |                                                   ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:230:15: error: unknown type name 'crypto_word'
|     230 | static inline crypto_word constant_time_is_nonzero_w(crypto_word a) {
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:230:54: error: unknown type name 'crypto_word'
|     230 | static inline crypto_word constant_time_is_nonzero_w(crypto_word a) {
|         |                                                      ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:235:15: error: unknown type name 'crypto_word'
|     235 | static inline crypto_word constant_time_eq_w(crypto_word a,
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:235:46: error: unknown type name 'crypto_word'
|     235 | static inline crypto_word constant_time_eq_w(crypto_word a,
|         |                                              ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:236:48: error: unknown type name 'crypto_word'
|     236 |                                                crypto_word b) {
|         |                                                ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:243:15: error: unknown type name 'crypto_word'
|     243 | static inline crypto_word constant_time_select_w(crypto_word mask,
|         |               ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:243:50: error: unknown type name 'crypto_word'
|     243 | static inline crypto_word constant_time_select_w(crypto_word mask,
|         |                                                  ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:244:52: error: unknown type name 'crypto_word'
|     244 |                                                    crypto_word a,
|         |                                                    ^~~~~~~~~~~
|   crypto/fipsmodule/aes/../../internal.h:245:52: error: unknown type name 'crypto_word'
|     245 |                                                    crypto_word b) {
|         |                                                    ^~~~~~~~~~~
|   thread 'main' panicked at 'execution failed', /home/bear/develop/oe-ada/build/tmp/work/riscv64-poky-linux/rustls/0.19.0.AUTOINC+c00aa17106-r0/cargo_home/registry/src/github.com-1ecc6299db9ec823/ring-0.17.0-alpha.10/build.rs:690:9
|   stack backtrace:
|      0: std::panicking::begin_panic
|      1: build_script_build::run_command
|      2: build_script_build::compile
|      3: build_script_build::build_library::{{closure}}
|      4: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
|      5: core::option::Option<T>::map
|      6: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
|      7: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
|      8: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
|      9: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
|     10: core::iter::traits::iterator::Iterator::collect
|     11: build_script_build::build_library
|     12: build_script_build::build_c_code::{{closure}}
|     13: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
|     14: build_script_build::build_c_code
|     15: build_script_build::ring_build_rs_main
|     16: build_script_build::main
|     17: core::ops::function::FnOnce::call_once
|   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@olof-nord
Copy link

I was trying to build https://github.com/prisma/prisma-engines .

Using the latest main branch, running Ubuntu Server with Linux 5.13.0-1019-generic.

openssl 1.1.1l is installed.

$ rustup show
Default host: riscv64gc-unknown-linux-gnu
rustup home:  /home/ubuntu/.rustup

installed targets for active toolchain
--------------------------------------

aarch64-unknown-linux-gnu
armv7-unknown-linux-gnueabihf
riscv64gc-unknown-linux-gnu
x86_64-unknown-linux-gnu

active toolchain
----------------

stable-riscv64gc-unknown-linux-gnu (default)
rustc 1.60.0 (7737e0b5c 2022-04-04)

Below is the error output from cargo test. Seems to me that the message "Unknown target CPU" is of most importance.

   Compiling ring v0.17.0-not-released-yet (/home/ubuntu/git/ring)
error: failed to run custom build command for `ring v0.17.0-not-released-yet (/home/ubuntu/git/ring)`

Caused by:
  process didn't exit successfully: `/home/ubuntu/git/ring/target/debug/build/ring-ff1d358f57b335b7/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_0_not_released_yet_
  OPT_LEVEL = Some("0")
  TARGET = Some("riscv64gc-unknown-linux-gnu")
  HOST = Some("riscv64gc-unknown-linux-gnu")
  CC_riscv64gc-unknown-linux-gnu = None
  CC_riscv64gc_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_riscv64gc-unknown-linux-gnu = None
  CFLAGS_riscv64gc_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = None

  --- stderr
  running "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-march=rv64gc" "-mabi=lp64d" "-mcmodel=medany" "-I" "include" "-I" "/home/ubuntu/git/ring/target/debug/build/ring-3d396754b09918c4/out" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-Werror" "-c" "-o/home/ubuntu/git/ring/target/debug/build/ring-3d396754b09918c4/out/curve25519.o" "crypto/curve25519/curve25519.c"
  In file included from include/ring-core/mem.h:60,
                   from crypto/curve25519/curve25519.c:22:
  include/ring-core/base.h:99:2: error: #error "Unknown target CPU"
     99 | #error "Unknown target CPU"
        |  ^~~~~
  In file included from crypto/curve25519/internal.h:20,
                   from crypto/curve25519/curve25519.c:24:
  crypto/curve25519/../internal.h:178:2: error: #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
    178 | #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
        |  ^~~~~
  crypto/curve25519/../internal.h:191:15: error: unknown type name ‘crypto_word’
    191 | static inline crypto_word value_barrier_w(crypto_word a) {
        |               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:191:43: error: unknown type name ‘crypto_word’
    191 | static inline crypto_word value_barrier_w(crypto_word a) {
        |                                           ^~~~~~~~~~~
  crypto/curve25519/../internal.h:216:15: error: unknown type name ‘crypto_word’
    216 | static inline crypto_word constant_time_msb_w(crypto_word a) {
        |               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:216:47: error: unknown type name ‘crypto_word’
    216 | static inline crypto_word constant_time_msb_w(crypto_word a) {
        |                                               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:221:15: error: unknown type name ‘crypto_word’
    221 | static inline crypto_word constant_time_is_zero_w(crypto_word a) {
        |               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:221:51: error: unknown type name ‘crypto_word’
    221 | static inline crypto_word constant_time_is_zero_w(crypto_word a) {
        |                                                   ^~~~~~~~~~~
  crypto/curve25519/../internal.h:236:15: error: unknown type name ‘crypto_word’
    236 | static inline crypto_word constant_time_is_nonzero_w(crypto_word a) {
        |               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:236:54: error: unknown type name ‘crypto_word’
    236 | static inline crypto_word constant_time_is_nonzero_w(crypto_word a) {
        |                                                      ^~~~~~~~~~~
  crypto/curve25519/../internal.h:241:15: error: unknown type name ‘crypto_word’
    241 | static inline crypto_word constant_time_eq_w(crypto_word a,
        |               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:241:46: error: unknown type name ‘crypto_word’
    241 | static inline crypto_word constant_time_eq_w(crypto_word a,
        |                                              ^~~~~~~~~~~
  crypto/curve25519/../internal.h:242:48: error: unknown type name ‘crypto_word’
    242 |                                                crypto_word b) {
        |                                                ^~~~~~~~~~~
  crypto/curve25519/../internal.h:249:15: error: unknown type name ‘crypto_word’
    249 | static inline crypto_word constant_time_select_w(crypto_word mask,
        |               ^~~~~~~~~~~
  crypto/curve25519/../internal.h:249:50: error: unknown type name ‘crypto_word’
    249 | static inline crypto_word constant_time_select_w(crypto_word mask,
        |                                                  ^~~~~~~~~~~
  crypto/curve25519/../internal.h:250:52: error: unknown type name ‘crypto_word’
    250 |                                                    crypto_word a,
        |                                                    ^~~~~~~~~~~
  crypto/curve25519/../internal.h:251:52: error: unknown type name ‘crypto_word’
    251 |                                                    crypto_word b) {
        |                                                    ^~~~~~~~~~~
  thread 'main' panicked at 'execution failed', build.rs:707:9
  stack backtrace:
     0: std::panicking::begin_panic
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:616:12
     1: build_script_build::run_command
               at ./build.rs:707:9
     2: build_script_build::compile
               at ./build.rs:556:9
     3: build_script_build::build_library::{{closure}}
               at ./build.rs:505:18
     4: core::iter::adapters::map::map_fold::{{closure}}
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/iter/adapters/map.rs:84:28
     5: core::iter::traits::iterator::Iterator::fold
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/iter/traits/iterator.rs:2285:21
     6: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/iter/adapters/chain.rs:122:19
     7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/iter/adapters/map.rs:124:9
     8: core::iter::traits::iterator::Iterator::for_each
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/iter/traits/iterator.rs:773:9
     9: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/vec/spec_extend.rs:40:17
    10: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
    11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/vec/spec_from_iter.rs:33:9
    12: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/vec/mod.rs:2552:9
    13: core::iter::traits::iterator::Iterator::collect
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/iter/traits/iterator.rs:1778:9
    14: build_script_build::build_library
               at ./build.rs:502:16
    15: build_script_build::build_c_code::{{closure}}
               at ./build.rs:485:13
    16: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/slice/iter/macros.rs:211:21
    17: build_script_build::build_c_code
               at ./build.rs:482:5
    18: build_script_build::ring_build_rs_main
               at ./build.rs:350:5
    19: build_script_build::main
               at ./build.rs:300:48
    20: core::ops::function::FnOnce::call_once
               at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed

@briansmith
Copy link
Owner

Check out PR #1436 which contains the changes to base.h that are needed after #1558.

@enh-google
Copy link

fwiw, we're using those changes in Android (https://android-review.googlesource.com/c/platform/external/rust/crates/ring/+/2408495/4)...

@tommythorn
Copy link

Note, this is regressing https://github.com/nextest-rs/nextest which worked on RISC-V before they pulled in ring :(

@ifsheldon
Copy link

do we have any updates? I see there are a few PRs trying to resolve this but they are all pending.

@kush930
Copy link

kush930 commented Jun 2, 2023

It does not explain how to contribute into RISC-V port and how (at least) to allow the compilation of the crate.

The work we're doing to enable all the features on wasm32, MIPS, etc. will enable ring to work on RISC-V. Then we can add CI/CD jobs that verify ring builds for RISC-V. Ideally we'd also have optimized assembly for RISC-V too, eventually.

Hi briansmith,

I am not able to build ring v0.16.20 on riscv64 platform, i added line from link-light4@4d5dde5#diff-a746f36ad550c7ba0b9d8557d26374079a51cccec2555a5e023129e32af6b789

After changing in source code from above link, i am not able to build successfully, can you look on output-

root@kush-Linux-1:~/ring# cargo build -v
       Fresh cc v1.0.79
       Fresh cfg-if v1.0.0
       Fresh untrusted v0.9.0
       Fresh libc v0.2.144
       Fresh getrandom v0.2.9
       Fresh ring v0.16.20 (/home/root/ring)
warning: unnecessary `unsafe` block
  --> src/arithmetic/bigint/bn_mul_mont_fallback.rs:39:17
   |
39 |         let n = unsafe { core::slice::from_raw_parts(n, num_limbs) };
   |                 ^^^^^^ unnecessary `unsafe` block
   |
  ::: src/prefixed.rs:55:17
   |
55 |                 $vis unsafe fn $name ( $( $arg_pat : $arg_ty ),* ) $body
   |                 -------------------------------------------------- because it's nested under this `unsafe` fn
   |
   = note: `#[warn(unused_unsafe)]` on by default
   = note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
   = note: `#[allow(unsafe_op_in_unsafe_fn)]` on by default

warning: unnecessary `unsafe` block
  --> src/arithmetic/bigint/bn_mul_mont_fallback.rs:44:30
   |
44 |             let a: &[Limb] = unsafe { core::slice::from_raw_parts(a, num_limbs) };
   |                              ^^^^^^ unnecessary `unsafe` block
   |
  ::: src/prefixed.rs:55:17
   |
55 |                 $vis unsafe fn $name ( $( $arg_pat : $arg_ty ),* ) $body
   |                 -------------------------------------------------- because it's nested under this `unsafe` fn
   |
   = note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`

warning: unnecessary `unsafe` block
  --> src/arithmetic/bigint/bn_mul_mont_fallback.rs:45:30
   |
45 |             let b: &[Limb] = unsafe { core::slice::from_raw_parts(b, num_limbs) };
   |                              ^^^^^^ unnecessary `unsafe` block
   |
  ::: src/prefixed.rs:55:17
   |
55 |                 $vis unsafe fn $name ( $( $arg_pat : $arg_ty ),* ) $body
   |                 -------------------------------------------------- because it's nested under this `unsafe` fn
   |
   = note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`

warning: unnecessary `unsafe` block
  --> src/arithmetic/bigint/bn_mul_mont_fallback.rs:48:30
   |
48 |         let r: &mut [Limb] = unsafe { core::slice::from_raw_parts_mut(r, num_limbs) };
   |                              ^^^^^^ unnecessary `unsafe` block
   |
  ::: src/prefixed.rs:55:17
   |
55 |                 $vis unsafe fn $name ( $( $arg_pat : $arg_ty ),* ) $body
   |                 -------------------------------------------------- because it's nested under this `unsafe` fn
   |
   = note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`

warning: field `mask` is never read
   --> src/cpu/arm.rs:201:5
    |
200 | pub(crate) struct Feature {
    |                   ------- field in this struct
201 |     mask: u32,
    |     ^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: associated function `available` is never used
   --> src/cpu/arm.rs:206:12
    |
206 |     pub fn available(&self, _: super::Features) -> bool {
    |            ^^^^^^^^^

warning: constant `ARMCAP_STATIC` is never used
   --> src/cpu/arm.rs:185:9
    |
185 |           const ARMCAP_STATIC: u32 = 0;
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
230 | / features! {
231 | |     // Keep in sync with `ARMV7_NEON`.
232 | |     NEON {
233 | |         mask: 1 << 0,
...   |
253 | |     },
254 | | }
    | |_- in this macro invocation
    |
    = note: this warning originates in the macro `features` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `ring` (lib) generated 7 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.26s

here if i am wrong , can you guide me to build ring v0.16.20 on target board on riscv64 platform.

T&R
luvkush

lypanov added a commit to lypanov/ncgopher that referenced this issue Aug 5, 2023
Remove cert generation and revert back from ring -> sha2

briansmith/ring#1182
antohami added a commit to altlinux/mkimage-profiles that referenced this issue Aug 22, 2023
warp cannot be built on riscv64 in the near future as it is rust
and its crate 'ring' does not support RISC-V:
briansmith/ring#1182

Reported-by: Ivan A. Melnikov <iv at altlinux.org>
@briansmith
Copy link
Owner

It works now. Because RISC-V doesn't have carry/borrow flags, the math probably is far from optimal. But it builds as of PR #1627.

@ub-tech
Copy link

ub-tech commented Apr 29, 2024

hi - i received this error "ring@0.17.8: include/ring-core/target.h:64:2: error: "Unknown target CPU"". Is there a version that I should use to resolve? I'm building on SP1 and encountered this issue at compile time.

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.

9 participants