On Sat, Dec 19, 2015 at 6:53 PM, Chaitanya Mannem via swift-users <
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). 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>*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151220/d733492d/attachment.html>