4 ms·
This is on point. I work on small-ish embedded Linux systems and I would really like to use Rust there, but a single Rust binary takes up enough space for 10 C
by ahlCVA 3y ago
This is on point. I work on small-ish embedded Linux systems and I would really like to use Rust there, but a single Rust binary takes up enough space for 10 C programs, so it's prohibitive. You can dynamically link your libraries (especially since these systems are usually built as full images, so ABI compatibility does not really matter) and it helps a little, but nowhere close to the order of magnitude you need.
Alas, there is little interest in/awareness of the middle ground between the no_std world and the "size doesn't matter" world in the Rust community right now. I've asked a bunch of people for pointers as to where to start working towards supporting those cases but I mainly got shrugs. There were attempts at more lightweight stdlibs and so on, but they all seem to have fizzled out.
I wonder how much of this is inherent in the language design. Rust heavily leans on monomorphization, so as a first approximation, you will always generate more code (before maybe optimizing that away again). Famously, the Swift people went to great lengths to avoid these problems: https://faultlore.com/blah/swift-abi/ https://faultlore.com/blah/swift-abi/. But while running Swift on Linux is possible, this is even more niche.
- mkj 3y agoThere's some interest in a binary size working group. https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Binary.20size.20working.20group https://rust-lang.zulipchat.com/#narrow/stream/131828-t-comp...
- synergy20 3y agototally agree,that's the same reason I gave up rust for embedded systems, beyond no_stb bare metal use case,it is way too big in size comparing to c and c++. golang has similar size issue,sadly.