helje5/SwiftSockets

Support the new Swift package manager

Closed this issue · 9 comments

I was wondering if there are any plans to support the new Swift package manager. I'd love to contribute to the effort, but wanted to check in with the team before putting together any PRs.

Something I just noticed is that SwiftSockets has a C source file, which SPM can't build. Not sure what to do about that.

Ya I noticed that as well. I'm gonna poke around tomorrow and see what can be done.

On Dec 9, 2015, 5:51 PM -0800, Dan Appelnotifications@github.com, wrote:

Something I just noticed is that SwiftSockets has a C source file, which SPM can't build. Not sure what to do about that.


Reply to this email directly orview it on GitHub(#20 (comment)).

There already is a Linux feature branch which kinda includes this. Need to check whether the C shims for the varargs functions are still required in the current Swift version, maybe we can drop them.

Nope, they still don't import fnctl() in the 2.2 2015-12-01a snapshot.

OK, I replaced the C file with a dlsym() hack. However, building the linux branch crashes swiftc (swift-2.2-SNAPSHOT-2015-12-01-a).

It looks like fnctl is available as of the 2015-12-10a build as seen by this search of the swift codebase: https://github.com/apple/swift/search?utf8=✓&q=fcntl. Please correct me if I'm wrong as I'm pretty new to this low level of working with the compiler.

Also, it doesn't appear that a compiled version of GCD/Dispatch is shipping with the ubuntu build yet. I'm only seeing the following precompiled static libraries in the usr/lib/swift_static/linux folder

libswiftCore.a
libswiftGlibc.a
libswiftRuntime.a
libswiftStdlibStubs.a
helge@SwiftyUbuntu:~$ swift --version
Swift version 2.2-dev (LLVM 7bae82deaa, Clang 53d04af5ce, Swift 5995ef2acd)
Target: x86_64-unknown-linux-gnu

helge@SwiftyUbuntu:~$ swift
 10> Glibc.fcntl(0, 10, 10)
repl.swift:10:7: error: 'fcntl' is unavailable: Variadic function is unavailable
Glibc.fcntl(0, 10, 10)
      ^~~~~
SwiftGlibc.fcntl:2:13: note: 'fcntl' has been explicitly marked unavailable here
public func fcntl(__fd: Int32, _ __cmd: Int32, _ varargs: Any...) -> Int32
            ^

But that shouldn't be an issue for now, as mentioned I replaced those calls with dlsym()'s.

Well well, Glibc.fcntl now seems to work with the 2016-01-11-a snapshot:

swift
Welcome to Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 42591f7cba). Type :help for assistance.
  1> import Glibc
  2> Glibc.fcntl(0, 10, 10) 
$R0: CInt = 0

The linux branch has a working SPM version. Also works on OSX.