Swift Bare Bones

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Swift Bare Bones

Post 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).
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Swift Bare Bones

Post 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.
cheapskate01
Member
Member
Posts: 58
Joined: Sat Aug 01, 2015 9:05 pm

Re: Swift Bare Bones

Post 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.
"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
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Swift Bare Bones

Post 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.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Swift Bare Bones

Post 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.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Swift Bare Bones

Post 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.
Post Reply