Suitability of Rust for embedded development


#1

Continuing the discussion from Welcome to the new Rust forum:

@VK3TXD, it’s all good. A separate topic might be better than the intro, so I made one :smile:

You might want to check out projects like http://zinc.rs/. Rust is certainly appropriate for the embedded/OS space, but we could probably do some things to make it easier.


Embedded programming in Rust
#2

It should be noted that the standard library is quite inappropriate for embedded development as I understand it. It allocates quite liberally, and provides no hooks for handling things like OOM. The stdlibs will just abort (not even panic) on OOM.

Personally this seems like totally reasonable behaviour for userland applications on non-embedded platforms where OOM is considered rare or just impractical to handle. Having ever operation that allocates bubble up a Result that you need to handle would be super annoying IMHO. Maybe you disagree, though.

Anyway, libcore doesn’t allocate, so that’s totally fine to use.


#3

In my opinion, compiling for anything else than Windows/Linux/Mac is yet to be handled “properly” by Rust. Sure you can do embedded development, but:

  • Most libraries in the ecosystem, even ones which don’t interact with the O/S like the ones encoding/decoding various formats, don’t have the #![no_std] attribute.
  • Custom build targets are clumbsy. They store the relative path to the JSON file in the produced binaries, which may produce libraries/binaries that are incompatible between them, even when you use the same file twice. They also lack error detection for the format, and according to an open issue plugins don’t work correctly with them.
  • No precompiled rustc for various targets. This will probably be fixed after the 1.0 release.
  • The LLVM version used by rustc is still volatile ; this is problematic for “exotic” targets like emscripten which use custom LLVM backends.
  • To support other operating systems it should be possible to build the stdlib if you provide a custom replacement for the alloc and sys parts.
  • A way for Cargo to run post-build command for specific targets would be good too.

#4

Anyone know if there are plans to support the exotic backends? It would be great to have the various ARM versions and 8-bit AVR support but I would settle for rust that works right on desktop first :smile: