From 95b576427c50da9776464fd2c5d2a84fab215fdd Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Thu, 10 Apr 2025 13:19:25 +0200 Subject: [PATCH 1/5] Add riscv64 build support --- lighthouse/src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index 66dae053269..7ddf04db017 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -68,6 +68,9 @@ fn bls_hardware_acceleration() -> bool { #[cfg(target_arch = "aarch64")] return std::arch::is_aarch64_feature_detected!("neon"); + + #[cfg(target_arch = "riscv64")] + return false; } fn allocator_name() -> String { From 91b1d7c245058213569c9b02e9432a66f6a7be49 Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Mon, 14 Apr 2025 14:00:03 +0000 Subject: [PATCH 2/5] Add riscv64 support to Makefile --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index f621f38a63e..03bf33a6d85 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ X86_64_TAG = "x86_64-unknown-linux-gnu" BUILD_PATH_X86_64 = "target/$(X86_64_TAG)/release" AARCH64_TAG = "aarch64-unknown-linux-gnu" BUILD_PATH_AARCH64 = "target/$(AARCH64_TAG)/release" +RISCV64_TAG = "riscv64gc-unknown-linux-gnu" +BUILD_PATH_RISCV64 = "target/$(RISCV64_TAG)/release" PINNED_NIGHTLY ?= nightly @@ -67,6 +69,8 @@ build-aarch64: # pages, which are commonly used by aarch64 systems. # See: https://github.com/sigp/lighthouse/issues/5244 JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked +build-riscv64: + cross build --bin lighthouse --target riscv64gc-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked build-lcli-x86_64: cross build --bin lcli --target x86_64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked @@ -75,6 +79,8 @@ build-lcli-aarch64: # pages, which are commonly used by aarch64 systems. # See: https://github.com/sigp/lighthouse/issues/5244 JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked +build-lcli-riscv64: + cross build --bin lcli --target riscv64gc-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked # Create a `.tar.gz` containing a binary for a specific target. define tarball_release_binary @@ -95,6 +101,9 @@ build-release-tarballs: $(call tarball_release_binary,$(BUILD_PATH_X86_64),$(X86_64_TAG),"") $(MAKE) build-aarch64 $(call tarball_release_binary,$(BUILD_PATH_AARCH64),$(AARCH64_TAG),"") + $(MAKE) build-riscv64 + $(call tarball_release_binary,$(BUILD_PATH_RISCV64),$(RISCV64_TAG),"") + # Runs the full workspace tests in **release**, without downloading any additional # test vectors. From 9a59c6c0a445c4c83be59faa73a7093e3e76e81e Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Mon, 14 Apr 2025 15:27:12 +0000 Subject: [PATCH 3/5] Cross compile fix for riscv64 --- Cross.toml | 3 +++ Makefile | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Cross.toml b/Cross.toml index 8181967f327..f806d9f167d 100644 --- a/Cross.toml +++ b/Cross.toml @@ -4,6 +4,9 @@ pre-build = ["apt-get install -y cmake clang-5.0"] [target.aarch64-unknown-linux-gnu] pre-build = ["apt-get install -y cmake clang-5.0"] +[target.riscv64gc-unknown-linux-gnu] +pre-build = ["apt-get install -y cmake clang"] + # Allow setting page size limits for jemalloc at build time: # For certain architectures (like aarch64), we must compile # jemalloc with support for large page sizes, otherwise the host's diff --git a/Makefile b/Makefile index 03bf33a6d85..1e8556ffd3b 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,8 @@ build-aarch64: # See: https://github.com/sigp/lighthouse/issues/5244 JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked build-riscv64: + # cross release v0.2.5 is to old, build from sources + cargo install cross --git https://github.com/cross-rs/cross cross build --bin lighthouse --target riscv64gc-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked build-lcli-x86_64: @@ -80,6 +82,8 @@ build-lcli-aarch64: # See: https://github.com/sigp/lighthouse/issues/5244 JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked build-lcli-riscv64: + # cross release v0.2.5 is to old, build from sources + cargo install cross --git https://github.com/cross-rs/cross cross build --bin lcli --target riscv64gc-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked # Create a `.tar.gz` containing a binary for a specific target. From 448ffcaa1cdc1547ecb3127379a2e60dc3273e1b Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Tue, 22 Apr 2025 12:28:05 +0200 Subject: [PATCH 4/5] add 'build-riscv64' to docs 'Cross-compiling/Targets' --- book/src/installation_cross_compiling.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/book/src/installation_cross_compiling.md b/book/src/installation_cross_compiling.md index 4f6ba9af38a..59fa3762c2e 100644 --- a/book/src/installation_cross_compiling.md +++ b/book/src/installation_cross_compiling.md @@ -18,7 +18,8 @@ project. The `Makefile` in the project contains two targets for cross-compiling: - `build-x86_64`: builds an optimized version for x86_64 processors (suitable for most users). -- `build-aarch64`: builds an optimized version for 64-bit ARM processors (suitable for Raspberry Pi 4). +- `build-aarch64`: builds an optimized version for 64-bit ARM processors (suitable for Raspberry Pi 4/5). +- `build-riscv64`: builds an optimized version for 64-bit RISC-V processors. ### Example From 18871997f8baf957351fb2c82e5d9014e9de1192 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 23 Apr 2025 09:16:20 +1000 Subject: [PATCH 5/5] Use new cross image with stable cross binary --- Cross.toml | 2 ++ Makefile | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cross.toml b/Cross.toml index f806d9f167d..391e8751c8a 100644 --- a/Cross.toml +++ b/Cross.toml @@ -6,6 +6,8 @@ pre-build = ["apt-get install -y cmake clang-5.0"] [target.riscv64gc-unknown-linux-gnu] pre-build = ["apt-get install -y cmake clang"] +# Use the most recent Cross image for RISCV because the stable 0.2.5 image doesn't work +image = "ghcr.io/cross-rs/riscv64gc-unknown-linux-gnu:main" # Allow setting page size limits for jemalloc at build time: # For certain architectures (like aarch64), we must compile diff --git a/Makefile b/Makefile index 1e8556ffd3b..03bf33a6d85 100644 --- a/Makefile +++ b/Makefile @@ -70,8 +70,6 @@ build-aarch64: # See: https://github.com/sigp/lighthouse/issues/5244 JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lighthouse --target aarch64-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked build-riscv64: - # cross release v0.2.5 is to old, build from sources - cargo install cross --git https://github.com/cross-rs/cross cross build --bin lighthouse --target riscv64gc-unknown-linux-gnu --features "portable,$(CROSS_FEATURES)" --profile "$(CROSS_PROFILE)" --locked build-lcli-x86_64: @@ -82,8 +80,6 @@ build-lcli-aarch64: # See: https://github.com/sigp/lighthouse/issues/5244 JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin lcli --target aarch64-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked build-lcli-riscv64: - # cross release v0.2.5 is to old, build from sources - cargo install cross --git https://github.com/cross-rs/cross cross build --bin lcli --target riscv64gc-unknown-linux-gnu --features "portable" --profile "$(CROSS_PROFILE)" --locked # Create a `.tar.gz` containing a binary for a specific target.