[swift-users] [swift-dev] Cross Compiling Swift for Bare Metal?

William Dillon wdillon at coas.oregonstate.edu
Sun Dec 20 17:03:20 CST 2015

Though it might sound a little silly (because why not run linux), but starting with a beagle bone black would not be a terrible way to begin with bare metal work.  It has plenty of RAM, you know that LLVM writes good machine code for it, it has JTAG accessible, it’s inexpensive, etc...

This would be an amazing achievement.  I admit that was one of the first things I thought of when open source swift was announced.  I loath programming in anything else. I’m spoiled.

- Will

> On Dec 20, 2015, at 12:22 AM, Dmitri Gribenko via swift-dev <swift-dev at swift.org> wrote:
> On Sat, Dec 19, 2015 at 6:53 PM, Chaitanya Mannem via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
> Hi,
> I wanted to know if it is possible to compile swift code for bare metal. I know there is a runtime but does swift depend on it to execute even if I don't use those features?, can I disable them somehow. I was hoping that since you can produce LLVM Bytecode that you can cross compile using the arm-none-eabi toolchain for an embedded use-case (http://www.ti.com/tool/ek-tm4c123gxl) <http://www.ti.com/tool/ek-tm4c123gxl)>. Please tell me there's hope, I don't want to use C++  :(
> It is a goal of Swift to be a systems programming language, but nobody has yet compiled a program using Swift for a bare-metal target, so a significant amount of work would be required.
> The Swift runtime is required to support basic features such as object allocation, casts and generics, so you can't just omit it.
> Regarding the microcontroller that you referenced, I think it would be an overly ambitious goal to try to make everything work with 256 Kb of flash and 32 Kb of RAM.  I would recommend to start with a more powerful bare-metal target, and get things working without an OS and memory protection, measure RAM and flash consumption, and try to fit everything into a smaller MCU.
> Dmitri 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com <mailto:gribozavr at gmail.com>>*/
>  _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151220/dcc93c25/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1428 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151220/dcc93c25/attachment.p7s>

More information about the swift-users mailing list