diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5f121f215..071cfdd644 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -181,6 +181,7 @@ jobs: - i686-unknown-linux-gnu - i686-unknown-linux-musl - mipsel-unknown-linux-gnu + - riscv64gc-unknown-linux-gnu - x86_64-pc-windows-gnu - x86_64-pc-windows-msvc - x86_64-apple-darwin @@ -249,6 +250,9 @@ jobs: - target: mipsel-unknown-linux-gnu host_os: ubuntu-22.04 + - target: riscv64gc-unknown-linux-gnu + host_os: ubuntu-22.04 + - target: x86_64-pc-windows-gnu host_os: windows-latest diff --git a/build.rs b/build.rs index cdc5dd783c..69d5b903f6 100644 --- a/build.rs +++ b/build.rs @@ -30,6 +30,8 @@ const X86: &str = "x86"; const X86_64: &str = "x86_64"; const AARCH64: &str = "aarch64"; const ARM: &str = "arm"; +const RISCV64: &str = "riscv64"; +const RISCV32: &str = "riscv32"; #[rustfmt::skip] const RING_SRCS: &[(&[&str], &str)] = &[ @@ -45,7 +47,7 @@ const RING_SRCS: &[(&[&str], &str)] = &[ (&[], "crypto/mem.c"), (&[], "crypto/poly1305/poly1305.c"), - (&[AARCH64, ARM, X86_64, X86], "crypto/crypto.c"), + (&[AARCH64, ARM, X86_64, X86, RISCV64, RISCV32], "crypto/crypto.c"), (&[X86_64, X86], "crypto/cpu_intel.c"), diff --git a/include/ring-core/base.h b/include/ring-core/base.h index f1a027d1a4..a73f927983 100644 --- a/include/ring-core/base.h +++ b/include/ring-core/base.h @@ -89,6 +89,14 @@ #elif defined(__MIPSEL__) && defined(__LP64__) #define OPENSSL_64_BIT #define OPENSSL_MIPS64 +#elif defined(__riscv) && __riscv_xlen == 64 +#define OPENSSL_64_BIT +#define OPENSSL_RISCV64 +#define OPENSSL_NO_ASM +#elif defined(__riscv) && __riscv_xlen == 32 +#define OPENSSL_32_BIT +#define OPENSSL_RISCV32 +#define OPENSSL_NO_ASM #elif defined(__wasm__) #define OPENSSL_32_BIT #else diff --git a/mk/cargo.sh b/mk/cargo.sh index 48ac92d711..d883af9632 100755 --- a/mk/cargo.sh +++ b/mk/cargo.sh @@ -21,6 +21,7 @@ rustflags_self_contained="-Clink-self-contained=yes -Clinker=rust-lld" qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu" qemu_arm="qemu-arm -L /usr/arm-linux-gnueabihf" qemu_mipsel="qemu-mipsel -L /usr/mipsel-linux-gnu" +qemu_riscv64="qemu-riscv64 -L /usr/riscv64-linux-gnu" # Avoid putting the Android tools in `$PATH` because there are tools in this # directory like `clang` that would conflict with the same-named tools that may @@ -98,6 +99,12 @@ case $target in export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc export CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER="$qemu_mipsel" ;; + riscv64gc-unknown-linux-gnu) + export CC_riscv64gc_unknown_linux_gnu=riscv64-linux-gnu-gcc + export AR_riscv64gc_unknown_linux_gnu=riscv64-linux-gnu-gcc-ar + export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc + export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="$qemu_riscv64" + ;; x86_64-unknown-linux-musl) export CC_x86_64_unknown_linux_musl=clang-$llvm_version export AR_x86_64_unknown_linux_musl=llvm-ar-$llvm_version diff --git a/mk/install-build-tools.sh b/mk/install-build-tools.sh index 2b578dd4fd..f68c3d5a8f 100755 --- a/mk/install-build-tools.sh +++ b/mk/install-build-tools.sh @@ -78,6 +78,12 @@ case $target in libc6-dev-mipsel-cross \ qemu-user ;; +--target=riscv64gc-unknown-linux-gnu) + install_packages \ + gcc-riscv64-linux-gnu \ + libc6-dev-riscv64-cross \ + qemu-user + ;; --target=wasm32-unknown-unknown) cargo install wasm-bindgen-cli --bin wasm-bindgen-test-runner use_clang=1