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

Joe Groff jgroff at apple.com
Mon Dec 21 15:45:22 CST 2015


> On 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) <http://www.ti.com/tool/ek-tm4c123gxl)>. Please tell me there's hope, I don't want to use C++  :(

The code that emits runtime calls in IRGen is fairly well-factored. One thing you might experiment with is adding an `-fstandalone` flag that causes the compiler to diagnose any time it has to generate code with a runtime call. If you're willing to forgo the standard library and build from LLVM primitives up and always use -Ounchecked, you might be able to generate standalone binaries without a runtime dependency. You're on your own if you go that road though.

-Joe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151221/0bf471d9/attachment.html>


More information about the swift-dev mailing list