[swift-users] Swift in bare-metal embedded programming/Swift runtime

Jens Alfke jens at mooseyard.com
Wed Aug 10 11:31:35 CDT 2016


> On Aug 9, 2016, at 1:10 PM, Rick Mann via swift-users <swift-users at swift.org> wrote:
> 
> For the smaller devices, runtime library overhead is a concern (mostly due to code size). Is it possible to write swift code with no runtime library? I think this is possible in Rust (came up on another list).

I have never seen the Swift source code, but I’d be surprised if Swift binaries didn’t require at least the standard C runtime library. (It’s pretty hard to get anything done without at least having malloc/free!)

Don’t forget that the binary will have to include the implementations of the standard Swift library classes, at least the ones used by your program. I’m sure String in particular is a significant chunk of code, since it has to do all kinds of Unicode stuff. (In fact it might have a dependency on ICU, which is a pretty hefty C library.)

> These devices usually have memory-mapped registers that are read and written to affect the operation of the device. Some can be quite small (e.g. 8-bit registers, simple single physical memory address space), and others quite robust (full 32- or 64-bit machines with MMUs, etc.).

Arduinos are probably right out, since there’s no way anyone’s going to port Swift to an 8-bit CPU!

If you’re going for something bigger than that, why not just use a Raspberry Pi or C.H.I.P. or one of the other tiny ARM PC boards? They all run Linux, and I believe people are already working on porting Swift to run on those. C.H.I.P. costs $9, and I saw a blurb somewhere about a competitor that’s only $5.

—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160810/d5bb6afa/attachment.html>


More information about the swift-users mailing list