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.

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
+}

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.


  1. Or is it Blazingly Fastâ„¢? I am not sure. I think I have seen both. Please confirm with your Rust sales representative. [return]