← Back to context

Comment by dcrazy

6 days ago

Whether the code compiles to assembly is orthogonal to whether the program can function without runtime support.

Compiled Rust code that relies on syscalls will not function on a “bare metal” microcontroller.

Oh, thank you. I didn't know that. Sorry about my ignorance. Really thought that it defaulted to a direct machine code without library assistance.

  • Rust does not rely on syscalls or libraries on embedded targets, which is what the #![no_std] marker at the top of the project indicates. On some platforms, like ESP32, Rust can make calls into the RTOS and don't need that marker, but other embedded targets don't provide access to the std crate and you need to interact with peripherals from Rust or by interfacing with C or assembly.

    Rust's only requirement is that memcpy, memmove, memset, memcmp, bcmp, and strlen are available, and it can provide them if needed: https://github.com/rust-lang/compiler-builtins