Hi has anyone ever tried to run to run a rust binary on a Router which is running Openwrt or Lede?
Especially I want to know if:
- it is possible to even get it so small that it would fit on a less than 8MB free space device
- Openwrt would have everything needed (in terms of required libs etc)
- Rust does require lots of CPU power or anything other that would be to heavy for a router.
As Routers in terms of hardware I think about routers like the TP-Link 1043 ND (eu version)
I tried ripgrep
on my Linksys WRT1900ACv2 with LEDE, just to see how cross-compiling would go.
rustup target add armv7-unknown-linux-musleabihf
cargo build --release --target armv7-unknown-linux-musleabihf
... and I get a 21MB rg
binary, ouch. But most of that is actually debuginfo from libstd, so eu-strip rg
got it down to 2.1MB. (edit: actually, ripgrep/Cargo.toml
has [profile.release] debug = true
, so it was debuginfo from everything.)
To your points:
- My router has around 32MB rootfs, but 2.1MB for one binary is still uncomfortably large.
- If you use musl as I did, then everything is static, no extra libs required. That's probably part of the size problem, but it sure makes cross-compiling easier.
- The compiler itself (
rustc
) is rather heavy for a router, but it's rare to do native compilation in these environments even with gcc
, always cross compiling instead. The resulting Rust binaries should fine.
cross compiling would of course be needed. I asked because me I want to port parts of Lede to rust just for testing #forSience I think I will report here if it works. Reasoin is that I heared that Rust should in parts be more powerfull or faster.
Nice to hear it at least works. As soon as I got time I will try it myself.