[GSoC 2017] Porting the Swift Programming Language to Haiku
Hello everyone! I'm Joseph 'Calvin' Hill, (irc nick: return0e) a third year computer science student at the University of Hull and one of the 7 GSoC students participating with Haiku. I'm also a active contributor to the HaikuPorts organisation, by porting over useful cross-platform software found on other platforms, to be made available on Haiku. This summer, I'll be porting the Swift programming language to Haiku with my mentors Jérôme Duval 'Korli' and Julian Harnath 'jua', with the intention of merging these changes upstream.
Haiku has ports for several modern programming languages available to developers, but some of them are in the form of version specific patches, which haven't been upstreamed yet. As new releases of programming languages come by, maintenance of platform support through patches becomes increasingly difficult and Haiku misses out on official support for those languages. By working directly with the Swift community, this task aims to add Haiku support specifically for Swift and its sub-projects in the effort to not only improve Haiku's programming language diversity for future developers, but to make swift a possible alternative programming language to develop Haiku apps in.
Once the compiler and its standard library is built, it will be possible to compile and run Swift code on Haiku which will then allow developers to build libraries and applications that are written in Swift. If this is achieved early, the other utilities Swift uses such as debugging/REPL support (LLDB), package management and its testing frameworks will follow afterwards. The following will be done within the duration of the GSoC:
- Building swiftc and its standard library.
- Porting the core libraries to Haiku.
- Ability to compile/run simple swift programs.
- Run tests against the newly built standard library and swiftc.
As this task only focuses on the bare-minimum needed to get swift functional, I will further maintain Haiku support after GSoC and include:
- Porting libdispatch.
- Package Manager support on Haiku. (requires llbuild)
- Support for LLDB debugging.
Swift is a general-purpose programming language built using a modern approach to safety, performance and modern software design patterns . It was recently open-sourced by Apple in 2015 with goals such as being a C/C++ and Objective-C alternative, maintaining source compatibility with future releases and increasing portability with various platforms by leveraging the LLVM compiler for code generation and optimisation of source code. Swift is commonly used in the iOS/macOS communities for writing GUI apps, but it is also suitable for other scenarios, from teaching programming to server-side development.
It has several language features such as:
- Closures (unified with function pointers)
- Built-in REPL for debugging (LLDB)
- Functional programming patterns support
- C and Objective-C interoperability via ClangImporter
Swift also provides additional libraries for functionality not included in the standard library. More information about them can be found here: 
Goals for next week
During the community bonding period, I will be in contact with the Swift team about which version I should port, as Swift 4 is scheduled to be released in late 2017. I'll also be discussing with my mentors on adding slight changes to the existing LLVM port in order for Clang to build itself, as using g++ to compile Swift is not supported. In the first two weeks (May 4th - May 18th) the following will be achieved:
- Add initial x86-64 platform recognition in the build script.
- Add Haiku as a standard library target.
- Haiku support for validation tests.
- Complete build-script support for Haiku. (Includes building only with LLVM and Clang)
I’ll be continuing to patch the build-script for initial Haiku support and I aim to get the build-script patches upstreamed in late May / early June.
References https://swift.org/about GSoC Proposal Swift GitHub Repository Swift Compiler Architecture Swift Core Libraries
- NVMe Driver Now Available
- Most long-standing XHCI (USB 3.0+) issues resolved!
- Haiku monthly activity report - 02/2019
- Haiku monthly activity report, January 2019
- Haiku monthly activity report - 12/2018
- Haiku monthly activity report - 11/2018
- Haiku R1/beta1 in Vagrant
- Report of BeGeistert 031 in Hamburg
- Partial Outage
- Haiku monthly activity report, September/October 2018