briansmith / ring

Safe, fast, small crypto using Rust
Other
3.75k stars 704 forks source link

Bug:"Unknown target CPU" & "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT" #1878

Closed gcp-development closed 10 months ago

gcp-development commented 10 months ago

Hello,

My target is "riscv32imac-esp-espidf" and I am using the riscv64-unknown-elf-gcc to compile the ring library.

But I am getting the error below :

warning: ring@0.17.5: In file included from include/ring-core/base.h:74,
warning: ring@0.17.5:                  from include/ring-core/mem.h:60,
warning: ring@0.17.5:                  from crypto/curve25519/curve25519.c:22:
warning: ring@0.17.5: include/ring-core/target.h:63:2: error: #error "Unknown target CPU"
warning: ring@0.17.5:    63 | #error "Unknown target CPU"
warning: ring@0.17.5:       |  ^~~~~
warning: ring@0.17.5: In file included from crypto/curve25519/internal.h:20,
warning: ring@0.17.5:                  from crypto/curve25519/curve25519.c:24:
warning: ring@0.17.5: crypto/curve25519/../internal.h:210:2: error: #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"
warning: ring@0.17.5:   210 | #error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT"

I am assuming that the current ring crate does not have the target "riscv32imac-esp-espidf".

There is any plan in the future to add this target or any riscv32 target ?

Thanks

briansmith commented 10 months ago

I am happy to accept a PR that adds riscv32 support. I suggest we start with riscv32gc-unknown-linux-gnu since we can just copy-paste-edit the changes from PR #1627, at least for for target.h, mk/cargo.sh, mk/install-build-tools.sh.

As for espidf, that probably needs a couple of additional tweaks for getrandom. If there's a way to use qemu-user to target espidf then that would help.

briansmith commented 10 months ago

Closing as a duplicate of #1765.

gcp-development commented 10 months ago

Fair enough.

Nevertheless, the "riscv32imac-esp-espidf" is more similar the way the "armv7-unknown-linux-musleabihf" (With the emu setup for riscv32) was setup in your code than the current "riscv64gc-unknown-linux-gnu".

Thanks.