Swift Bare Bones
Swift Bare Bones
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).
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: Swift Bare Bones
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.
-
- Member
- Posts: 58
- Joined: Sat Aug 01, 2015 9:05 pm
Re: Swift Bare Bones
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.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.
"That I'm in forum signatures is just a sign the invasion of sortie is nearing completion. Soon you'll all have to become me to defeat me." ~ Sortie
Re: Swift Bare Bones
Sorry for the delay. The official Swift runtime is implemented in C/C++ and Swift, so I don't think it's a problem.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.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: Swift Bare Bones
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.cheapskate01 wrote: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.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.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: Swift Bare Bones
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.
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.