Compiling Reth on Freebsd
I recently decided to try Reth, the latest Blazing Fastâ„¢1 Ethereum execution client. I encountered a few errors when compiling it on FreeBSD, and was able to solve them. This blog post is a simple documentation of the process, and is basically a copy of the Github ticket I submitted. Note that FreeBSD is not officially supported by Reth, so your mileage may vary.
These are the steps I took.
- Silent the compilation error of
metrics-process
with the following patch. It’s not really a fix in the sense that the library won’t provide metrics on FreeBSD (it’s just an empty implementation), but at least it compiles. It does not seem hard to add real support for FreeBSD either.
diff --git a/src/collector.rs b/src/collector.rs
index 3b47870..3fd11d2 100644
--- a/src/collector.rs
+++ b/src/collector.rs
@@ -8,6 +8,9 @@ mod linux;
#[path = "collector/windows.rs"]
mod win;
+#[cfg(target_os = "freebsd")]
+mod freebsd;
+
/// Process metrics
/// https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics
#[derive(Debug, Default, PartialEq)]
@@ -41,6 +44,9 @@ pub use linux::collect;
#[cfg(target_os = "windows")]
pub use win::collect;
+#[cfg(target_os = "freebsd")]
+pub use freebsd::collect;
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/collector/freebsd.rs b/src/collector/freebsd.rs
new file mode 100644
index 0000000..fd3d6ec
--- /dev/null
+++ b/src/collector/freebsd.rs
@@ -0,0 +1,6 @@
+use super::Metrics;
+
+pub fn collect() -> Metrics {
+ let mut metrics = Metrics::default();
+ metrics
+}
- After the previous step, all dependencies should compile. But when compiling the reth binary itself, linker will complain that it cannot find
__cpu_model
and another symbol whose name I forget now. The two missing symbols come fromlibgcc
, so I needed to install it (pkg install gcc12-devel
). - Somehow rust won’t try to link with
libgcc
, so I needed to addprintln!("cargo:rustc-link-lib=static=gcc");
to bin/reth/build.rs. - Rust will now complain that it cannot find
libgcc
, so I addedlinker = "gcc12"
to .cargo/config, and setRUSTFLAGS="-L/usr/lib"
when calling cargo.
As a side note, I also had to jump through a few hoops to compile Lighthouse, an Ethereum consensus client written in Rust. But the errors I encountered there were more straightforward to solve, so I will not document the solution here.
- Or is it Blazingly Fastâ„¢? I am not sure. I think I have seen both. Please confirm with your Rust sales representative. [return]