[swift-dev] Porting swift to FreeBSD

Dmitri Gribenko gribozavr at gmail.com
Sat Dec 12 22:45:39 CST 2015


On Sat, Dec 12, 2015 at 8:29 PM, Davide Italiano via swift-dev
<swift-dev at swift.org> wrote:
> Hi,
> I'm a FreeBSD developer who has been working on porting swift to FreeBSD.
> I'm at a point where with a local patch (
> https://people.freebsd.org/~davide/swift/build_freebsd.diff ) to fix
> build errors I'm able to build the compiler itself on FreeBSD 11
> (-CURRENT).

+Doug for this patch.

> The compiler itself seems to work fine (at least semantic analysis is
> able to produce the correct result for toy examples).
> Example:
>
> % cat hello.swift
> let number = 4
> println(number)
>
> % ./swiftc hello.swift -o hello
> hello.swift:2:1: error: 'println' has been renamed to 'print'
> println(number)
> ^~~~~~~
> [...]
>
> The executables generated seem to have some problems, though.
> This is what I see:
>
> % cat hello2.swift
> let number = 4
> print(number)
> % ./swiftc hello2.swift -o hello2
>  % ./hello2
> Int(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(String(Stri

The reason is that the program can't find the protocol conformance
tables.  On Linux, we are using a linker script to collect all
conformances into one section, and insert symbols at the beginning and
at the end, see stdlib/public/runtime/swift.ld.  The code that reads
these sections is in stdlib/public/runtime/Casting.cpp.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-dev mailing list