# Lighthouse

**URL:** https://collective.flashbots.net/t/lighthouse/4857
**Category:** References
**Tags:** software
**Created:** [April 3, 2025, 3:14pm UTC](https://collective.flashbots.net/t/lighthouse/4857 "2025-04-03T15:14:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![guayabyte](https://collective.flashbots.net/user_avatar/collective.flashbots.net/guayabyte/32/4008_2.png) [@guayabyte](https://collective.flashbots.net/u/guayabyte)
#### Post date: [April 3, 2025, 3:14pm UTC](https://collective.flashbots.net/t/lighthouse/4857/1 "2025-04-03T15:14:23Z")

</div>

> **[GitHub - sigp/lighthouse: Ethereum consensus client in Rust](https://github.com/sigp/lighthouse/)**
>
> Ethereum consensus client in Rust

# RISC-V support

Status: fails to build.

> <https://github.com/sigp/lighthouse/issues/6297>
>
> \## Description
> 
> To be able to build Lighthouse on a risc-v platform we found t…he following packages to be a problem. This ticket is meant as a reference to see what needs to be done and also coordinate with the upstream libraries.
> 
> \`cpufeatures\`
> Is used in about a dozen packages in lighthouse and needs to be fixed upstream. It does not have any support for RISC-V and fails building which prevents all these packages to be built.
> 
> \`ring\`
> 0.16 versions of the library do not build on riscv, the 0.17 versions do. Unfortunately this library is used a few levels deep in the following packages: 
> \* \`jsonwebtoken\` within lighthouse \`beacon\_node/execution\_layer\`. It can be updated from 8 to 9 which uses the newer ring package without issues and then builds.
> \* \`rcgen\` used in \`libp2p-tls\` depends on the 0.16 version. The newer version of \`rcgen\` (0.12.1 or 0.13) support riscv. ,
> 
> \`libp2p-tls\`
> As mentioned above this library needs to have its \`ring\` dependency updated through an update of the \`rcgen\` package to at least v0.12.1. Unfortunately v0.13 changes some function signatures and would therefore make a larger rework of libp2p necessary. Luckily version 0.12.1 of \`rcgen\` supports riscv with maybe only minimal changes in libp2p. So this might be the best option.
> 
> We fixed these packages locally in our own setup in a quick and dirty way and know that lighthouse builds and runs on a risc-v board. It can even sync to testnet/mainnet. 
> 
> We will try to make the necessary PRs to some of these packages in the coming weeks and will see with the upstream projects what the best solution will be. 
> 
> If anyone sees a different approach to updating these dependencies we can obviously go a different path.
> 
> \## Version
> We based our RISC-V builds on the 5.2.1 release of lighthouse.
> 
> \## Present Behaviour
> Builds and runs on RISC-V from our own forked repository.
> 
> \## Expected Behaviour
> Hopefully we will get the changes into the necessary packages such that lighthouse can be built on RISC-V architecture directly from the official repository.

## Log

- [july, 2024] [lazyprogrammerio](https://github.com/lazyprogrammerio) [reported](https://github.com/eth-educators/eth-docker/issues/1873#issuecomment-2230076446) that lighthouse fails to build because of the `cpufeatures` crate.
- [july, 2024] [haurog](https://github.com/haurog) and [michaelsproul](https://github.com/michaelsproul) [fixed the `cpufeatures` dependency in `ethereum_hashing`](https://github.com/sigp/ethereum_hashing/pull/8).
- [april, 2025] [haurog](https://github.com/haurog) [reports](https://github.com/eth-educators/eth-docker/issues/1873#issuecomment-2793519863) that lighthouse updated the problematic dependencies and is now almost ready to build in risc-v.

## Cross-compile

Install docker: [Install Docker Engine on Debian | Docker Docs](https://docs.docker.com/engine/install/debian/)

Add the user to the docker group: [Linux post-installation steps for Docker Engine | Docker Docs](https://docs.docker.com/engine/install/linux-postinstall/)

Install cross:

```auto
$ cargo install cross
$ cross build --bin lighthouse --target riscv64gc-unknown-linux-gnu
...
error: failed to run custom build command for `xdelta3 v0.1.5 (http://github.com/sigp/xdelta3-rs?rev=4db64086bb02e9febb584ba93b9d16bb2ae3825a#4db64086)`

Caused by:
  process didn't exit successfully: `/target/debug/build/xdelta3-089e54b56a437ecd/build-script-build` (exit status: 101)
  --- stdout
  OUT_DIR = Some(/target/riscv64gc-unknown-linux-gnu/debug/build/xdelta3-544b6295ff28cbaf/out)
  OPT_LEVEL = Some(0)
  TARGET = Some(riscv64gc-unknown-linux-gnu)
  HOST = Some(x86_64-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 = Some(riscv64-linux-gnu-gcc)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  CARGO_CFG_TARGET_FEATURE = Some(a,c,m)
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = 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_ENCODED_RUSTFLAGS = Some()
  cargo:rerun-if-env-changed=AR_riscv64gc-unknown-linux-gnu
  AR_riscv64gc-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=AR_riscv64gc_unknown_linux_gnu
  AR_riscv64gc_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  RUSTC_LINKER = Some(riscv64-linux-gnu-gcc)
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv64gc_unknown_linux_gnu
  ARFLAGS_riscv64gc_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=ARFLAGS_riscv64gc-unknown-linux-gnu
  ARFLAGS_riscv64gc-unknown-linux-gnu = None
  cargo:rustc-link-lib=static=xdelta3
  cargo:rustc-link-search=native=/target/riscv64gc-unknown-linux-gnu/debug/build/xdelta3-544b6295ff28cbaf/out
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_riscv64gc-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_riscv64gc_unknown_linux_gnu

  --- stderr

  thread 'main' panicked at /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bindgen-0.69.5/ir/context.rs:556:15:
  libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
...
DEBUG: CMAKECONFIGDIR = /target/riscv64gc-unknown-linux-gnu/release/build/openssl-sys-919d683837af7360/out/openssl-build/install/lib/cmake/OpenSSL => CMAKECONFIGDIR = /target/riscv64gc-unknown-linux-gnu/release/build/openssl-sys-919d683837af7360/out/openssl-build/install/lib/cmake/OpenSSL, CMAKECONFIGDIR_REL_LIBDIR = cmake/OpenSSL
  "my" variable $KEYP masks earlier declaration in same scope at crypto/aes/asm/aes-riscv64-zkn.pl line 279.
  "my" variable $T0 masks earlier declaration in same scope at crypto/aes/asm/aes-riscv64-zkn.pl line 282.
  "my" variable $T1 masks earlier declaration in same scope at crypto/aes/asm/aes-riscv64-zkn.pl line 282.
  crypto/riscv64cpuid.s: Assembler messages:
  crypto/riscv64cpuid.s:67: Error: Instruction csrr requires absolute expression
  make[1]: *** [crypto/libcrypto-lib-riscv64cpuid.o] Error 1
  make[1]: *** Waiting for unfinished jobs....
  make: *** [build_libs] Error 2

  Error building OpenSSL:
      'make' reported failure with exit status: 2
      Command failed: cd "/target/riscv64gc-unknown-linux-gnu/release/build/openssl-sys-919d683837af7360/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "make" "build_libs"

make: *** [Makefile:72: build-riscv64] Error 101

```
