7 ms·
Is Rust good for embedded? I thought the binaries they produced were too fat?
by jcranberry 5y ago
Is Rust good for embedded? I thought the binaries they produced were too fat?
- TingPing 5y agoEmbedded is a wide field. It's young but has promise.
- SAI_Peregrinus 5y agoIt statically links. But bare-metal embedded generally doesn't support dynamic linking at all, so that's not a real problem there. A lot of the rest of the fat is from things like debugging symbols bounds checks that aren't included when building in release mode.
- nicoburns 5y agoThe extra fat in Rust binaries compiled with default settings is things like: - the standard library - jemalloc (this is no longer the default, but is still a factor in people's perception about binary size because it used to be) - debug symbols - unwinding support for panics All of these can be turned off for use cases like embedded where binary size is important and you'll then get binaries of comparable size to those produced by C compilers.
- steveklabnik 5y agoYou just have to pay attention. I work in Rust on embedded, it’s not a problem. The smallest x86_64 binary rustc has ever produced is like, 145 bytes. I’m on Arm, we have space for a lot more, but still actively try to keep sizes down. Some tasks in our system are ~500 bytes, the larger ones are on the order of 10k. You can’t just use the broader ecosystem willy nilly, and if you want truly small stuff, you have to know how to coax the compiler from time to time. But that’s just always going to be the case.