From 4d7935a31e170476503028832a159c51af126bcc Mon Sep 17 00:00:00 2001 From: leso-kn Date: Sat, 19 Aug 2023 17:47:03 +0200 Subject: [PATCH 1/5] Add support for riscv64 Co-authored-by: Alan Mock Co-authored-by: Patrick Elsen Signed-off-by: leso-kn --- mk/cargo.sh | 7 +++++++ mk/install-build-tools.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/mk/cargo.sh b/mk/cargo.sh index d990220279..6fa7e31aee 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 @@ -99,6 +100,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=clang-$llvm_version + export AR_riscv64gc_unknown_linux_gnu=llvm-ar-$llvm_version + export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=clang-$llvm_version + 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 234516f032..75b3a9fbd4 100755 --- a/mk/install-build-tools.sh +++ b/mk/install-build-tools.sh @@ -91,6 +91,13 @@ case $target in libc6-dev-mipsel-cross \ qemu-user ;; +--target=riscv64gc-unknown-linux-gnu) + use_clang=1 + 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 From 3ef19995994671325bad867cc9912b15ced08319 Mon Sep 17 00:00:00 2001 From: leso-kn Date: Sat, 19 Aug 2023 17:47:29 +0200 Subject: [PATCH 2/5] CI: Enable riscv64 build Co-authored-by: light4 Signed-off-by: leso-kn --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 971e28032c..56bc6d6ba7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -180,6 +180,7 @@ jobs: - i686-pc-windows-msvc - i686-unknown-linux-gnu - i686-unknown-linux-musl + - riscv64gc-unknown-linux-gnu - x86_64-pc-windows-gnu - x86_64-pc-windows-msvc - x86_64-apple-darwin @@ -246,6 +247,9 @@ jobs: - target: i686-unknown-linux-musl 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 From 32894b7e7cec5dd5fd4dcfa0746ae37de138e4bb Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 29 Sep 2023 22:52:36 -0700 Subject: [PATCH 3/5] CI: Use riscv64-linux-gnu-gcc as RISC-V linker. --- mk/cargo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/cargo.sh b/mk/cargo.sh index 6fa7e31aee..7964be701b 100755 --- a/mk/cargo.sh +++ b/mk/cargo.sh @@ -103,7 +103,7 @@ case $target in riscv64gc-unknown-linux-gnu) export CC_riscv64gc_unknown_linux_gnu=clang-$llvm_version export AR_riscv64gc_unknown_linux_gnu=llvm-ar-$llvm_version - export CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=clang-$llvm_version + 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) From e7b247731fedc15cea230764190c1d5fe84d64ce Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 29 Sep 2023 22:59:31 -0700 Subject: [PATCH 4/5] CI: Add riscv64gc-unknown-linux-gnu to the `coverage` target. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56bc6d6ba7..75d2b0d187 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -488,6 +488,7 @@ jobs: target: - aarch64-unknown-linux-gnu - i686-unknown-linux-gnu + - riscv64gc-unknown-linux-gnu - x86_64-unknown-linux-musl mode: @@ -511,6 +512,9 @@ jobs: - target: i686-unknown-linux-gnu host_os: ubuntu-22.04 + - target: riscv64gc-unknown-linux-gnu + host_os: ubuntu-22.04 + - target: x86_64-unknown-linux-musl host_os: ubuntu-22.04 From 16837d1f0d9585528b52fa06f9c37f260b3840d8 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 30 Sep 2023 07:28:52 -0700 Subject: [PATCH 5/5] Cherry-pick BoringSSL RISC-V target support (64-bit only). --- include/ring-core/target.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/ring-core/target.h b/include/ring-core/target.h index 5b46611550..9c9543a294 100644 --- a/include/ring-core/target.h +++ b/include/ring-core/target.h @@ -40,6 +40,9 @@ #elif defined(__MIPSEL__) && defined(__LP64__) #define OPENSSL_64_BIT #define OPENSSL_MIPS64 +#elif defined(__riscv) && __SIZEOF_POINTER__ == 8 +#define OPENSSL_64_BIT +#define OPENSSL_RISCV64 #elif defined(__wasm__) #define OPENSSL_32_BIT #else