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

ring on riscv64 platform #1612

Closed
kush930 opened this issue Jun 1, 2023 · 3 comments
Closed

ring on riscv64 platform #1612

kush930 opened this issue Jun 1, 2023 · 3 comments

Comments

@kush930
Copy link

kush930 commented Jun 1, 2023

Hi all,

I am using gcc-10.2.0 and glibc-3.2, and cloned ring version v0.16.20 from link:https://github.com/briansmith/ring

I am getting this output after modifying in source code from mentioned link- light4@4d5dde5#diff-a746f36ad550c7ba0b9d8557d26374079a51cccec2555a5e023129e32af6b789

root@kush-Linux-1:~/kush/ring# cargo build
warning: field `cpu_features` is never read
  --> src/digest.rs:50:5
   |
39 | pub(crate) struct BlockContext {
   |                   ------------ field in this struct
...
50 |     cpu_features: cpu::Features,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default
   = note: `BlockContext` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis

warning: `ring` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.30s

My doubt is here:

           1.  During building time i am not getting any error message, only one warning i am getting so here i am little bit confused that is it builded successfully or not.
           2.  if successfully builded then where binary will be present.
           3. if i am checking cargo --list:-
root@kush-Linux-1:~/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20# cargo --list
Installed Commands:
   add                  Add dependencies to a Cargo.toml manifest file
   b                    alias: build
   bench                Execute all benchmarks of a local package
   build                Compile a local package and all of its dependencies
   c                    alias: check
   check                Check a local package and all of its dependencies for errors
   clean                Remove artifacts that cargo has generated in the past
   clippy               Checks a package to catch common mistakes and improve your Rust code.
   config               Inspect configuration values
   d                    alias: doc
   doc                  Build a package's documentation
   fetch                Fetch dependencies of a package from the network
   fix                  Automatically fix lint warnings reported by rustc
   fmt                  Formats all bin and lib files of the current crate using rustfmt.
   generate-lockfile    Generate the lockfile for a package
   git-checkout         This command has been removed
   help                 Displays help for a cargo subcommand
   init                 Create a new cargo package in an existing directory
   install              Install a Rust binary. Default location is $HOME/.cargo/bin
   locate-project       Print a JSON representation of a Cargo.toml file's location
   login                Save an api token from the registry locally. If token is not specified, it will be read from stdin.
   logout               Remove an API token from the registry locally
   metadata             Output the resolved dependencies of a package, the concrete used versions including overrides, in machine-readable format
   miri
   new                  Create a new cargo package at <path>
   owner                Manage the owners of a crate on the registry
   package              Assemble the local package into a distributable tarball
   pkgid                Print a fully qualified package specification
   publish              Upload a package to the registry
   r                    alias: run
   read-manifest        Print a JSON representation of a Cargo.toml manifest.
   remove               Remove dependencies from a Cargo.toml manifest file
   report               Generate and display various kinds of reports
   rm                   alias: remove
   run                  Run a binary or example of the local package
   rustc                Compile a package, and pass extra options to the compiler
   rustdoc              Build a package's documentation, using specified custom flags.
   search               Search packages in crates.io
   t                    alias: test
   test                 Execute all unit and integration tests and build examples of a local package
   tree                 Display a tree visualization of a dependency graph
   uninstall            Remove a Rust binary
   update               Update dependencies as recorded in the local lock file
   vendor               Vendor all dependencies for a project locally
   verify-project       Check correctness of crate manifest
   version              Show version information
   yank                 Remove a pushed crate from the index

In above list i am not getting ring

Can anyone help me to build ring v0.16.20 on riscv64 platform.

T&R
luvkhush

@olof-nord
Copy link

Same here, I cannot build on riscv either. This is the log:

➜  ring git:(main) RUST_BACKTRACE=1 cargo build
   Compiling ring v0.17.0-not-released-yet (/home/olof/git/ring)
error: failed to run custom build command for `ring v0.17.0-not-released-yet (/home/olof/git/ring)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/home/olof/git/ring/target/debug/build/ring-b8e902a4256094c0/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")
  cargo:rerun-if-env-changed=CC_riscv64gc-unknown-linux-gnu
  CC_riscv64gc-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_riscv64gc_unknown_linux_gnu
  CC_riscv64gc_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CFLAGS_riscv64gc-unknown-linux-gnu
  CFLAGS_riscv64gc-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_riscv64gc_unknown_linux_gnu
  CFLAGS_riscv64gc_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = None

  --- stderr
  running "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-march=rv64gc" "-mabi=lp64d" "-mcmodel=medany" "-I" "include" "-I" "/home/olof/git/ring/target/debug/build/ring-6b3d1c554d067da5/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/olof/git/ring/target/debug/build/ring-6b3d1c554d067da5/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:710:9
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
     1: core::panicking::panic_fmt
               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
     2: build_script_build::run_command
     3: build_script_build::compile
     4: build_script_build::build_library::{{closure}}
     5: core::iter::adapters::map::map_fold::{{closure}}
     6: core::iter::traits::iterator::Iterator::fold
     7: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
     8: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
     9: core::iter::traits::iterator::Iterator::for_each
    10: alloc::vec::Vec<T,A>::extend_trusted
    11: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
    12: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
    13: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
    14: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
    15: core::iter::traits::iterator::Iterator::collect
    16: build_script_build::build_library
    17: build_script_build::build_c_code::{{closure}}
    18: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::for_each
    19: build_script_build::build_c_code
    20: build_script_build::ring_build_rs_main
    21: build_script_build::main
    22: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
➜  ring git:(main) 

@olof-nord
Copy link

Looking into open issues and pull requests, this one seems to be the most promising work so far.
#1436

Some info is also listed here: #1419

@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.

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

3 participants