Page 1 of 1
Swift Bare Bones
Posted: Sun Dec 06, 2015 6:20 pm
by Roman
Apple has made Swift open source. These great news made me interested in the language and particularly in porting
the good old Bare Bones tutorial. It turned out, that it's possible.
Here's the source code. Actually, I only needed to add some stub functions and do a hack with compiler options (see Makefile).
Re: Swift Bare Bones
Posted: Sun Dec 06, 2015 6:51 pm
by Nable
It looks like a nice attempt but is it possible to avoid C files? There are too many languages (and maybe tools) used in your example.
Re: Swift Bare Bones
Posted: Thu Dec 10, 2015 8:07 pm
by cheapskate01
Nable wrote:It looks like a nice attempt but is it possible to avoid C files? There are too many languages (and maybe tools) used in your example.
I don't see why it matters. It may be a bit complicated (and thus the makefile was born), but the c stub is all you need in that language. Everything else is in swift.
Re: Swift Bare Bones
Posted: Sat Dec 12, 2015 8:57 am
by Roman
Nable wrote:It looks like a nice attempt but is it possible to avoid C files? There are too many languages (and maybe tools) used in your example.
Sorry for the delay. The official Swift runtime is implemented in C/C++ and Swift, so I don't think it's a problem.
Re: Swift Bare Bones
Posted: Sat Dec 12, 2015 9:10 am
by Roman
cheapskate01 wrote:Nable wrote:It looks like a nice attempt but is it possible to avoid C files? There are too many languages (and maybe tools) used in your example.
I don't see why it matters. It may be a bit complicated (and thus the makefile was born), but the c stub is all you need in that language. Everything else is in swift.
Actually, it's just an example. The real language needs more support. The (clang/llc)+swiftc hack can be avoided by adding a --target option to the compiler. That shouldn't be difficult because: 1) it's open source; 2) I guess, it's just some work of wiring the option parser with one of LLVM's methods.
Re: Swift Bare Bones
Posted: Sun Dec 13, 2015 10:41 pm
by klange
Hey Roman, I set out to build a Swift kernel shortly after the announcement was made using the same method as you - having swiftc output LLVM IR. My efforts are
here.
There's a lot of stuff standing between Swift and a bare metal target - building a runtime for a kernel is going to be a rather complicated process.