libdispatch/GCD for Swift 3.0 on Linux


(Joe Bell) #1

Howdy all,

While working to convert some NSThread code over to GCD on Linux I noticed
that (to my dismay) GCD wasn't included in the Swift 3.0 preview build, nor
is it apart of the buildbot for Linux. Scouring through the repository and
mailing lists I can see where it is possible to build, but there are no
downstream instructions on how to make a line like this:

let queue = DispatchQueue(label: "com.app.queue")

work with the swiftc compiler on Linux.

A couple of questions:

* are there any timelines that the principals of GCD with Swift 3 on Linux
can share; i.e., is the plan to have it included in time for the Swift 3 GA
release later this year?
* are there any follow-up instructions past getting it built on how to use
it (or will make install DESTDIR place it in the right spots in the Swift 3
toolchain hierarchy?)

Any useful tips or pointers would be helpful!

Cheers,
Joe

···

--
Joseph Bell
http://dev.iachieved.it/iachievedit/
@iachievedit


(Dave Grove) #2

Hi Joe,

  TL;DR: right now the Swift 3.0 overlay for libdispatch is not
available on Linux.

  But, a variety of activities are kicking off to get it there. There
should be visible progress (and opportunities to help if you are so
inclined) over the next few weeks.

While working to convert some NSThread code over to GCD on Linux I
noticed that (to my dismay) GCD wasn't included in the Swift 3.0
preview build, nor is it apart of the buildbot for Linux. Scouring
through the repository and mailing lists I can see where it is
possible to build, but there are no downstream instructions on how
to make a line like this:

let queue = DispatchQueue(label: "com.app.queue")

work with the swiftc compiler on Linux.

A couple of questions:

* are there any timelines that the principals of GCD with Swift 3 on
Linux can share; i.e., is the plan to have it included in time for
the Swift 3 GA release later this year?

I certainly hope so; but cannot speak for official plans.

* are there any follow-up instructions past getting it built on how
to use it (or will make install DESTDIR place it in the right spots
in the Swift 3 toolchain hierarchy?)

I expect when things are done, it will be similar to how building the
current Swift-2 dispatch overlay works on Linux. To build from source you
use swift/utils/build-script with --libdispatch and it takes care of all
the details (ie, it just works...).

--dave


(Joe Bell) #3

Dave,

Thanks for the details, I appreciate it. I have seen the term "Swift
overlay" used, particularly in the context of libdispatch. What does that
mean exactly in this regard (searching for it returns tutorials on overlay
UIViews which I doubt is appropriate here).

I certainly hope GCD is included in Swift 3.0 on Linux too!

Joe

···

On Tue, Jun 21, 2016 at 7:59 AM, David P Grove <groved@us.ibm.com> wrote:

Hi Joe,

TL;DR: right now the Swift 3.0 overlay for libdispatch is not available on
Linux.

But, a variety of activities are kicking off to get it there. There
should be visible progress (and opportunities to help if you are so
inclined) over the next few weeks.

>
> While working to convert some NSThread code over to GCD on Linux I
> noticed that (to my dismay) GCD wasn't included in the Swift 3.0
> preview build, nor is it apart of the buildbot for Linux. Scouring
> through the repository and mailing lists I can see where it is
> possible to build, but there are no downstream instructions on how
> to make a line like this:
>
> let queue = DispatchQueue(label: "com.app.queue")
>
> work with the swiftc compiler on Linux.
>
> A couple of questions:
>
> * are there any timelines that the principals of GCD with Swift 3 on
> Linux can share; i.e., is the plan to have it included in time for
> the Swift 3 GA release later this year?

I certainly hope so; but cannot speak for official plans.

> * are there any follow-up instructions past getting it built on how
> to use it (or will make install DESTDIR place it in the right spots
> in the Swift 3 toolchain hierarchy?)
>

I expect when things are done, it will be similar to how building the
current Swift-2 dispatch overlay works on Linux. To build from source you
use swift/utils/build-script with --libdispatch and it takes care of all
the details (ie, it just works...).

--dave

--
Joseph Bell
http://dev.iachieved.it/iachievedit/
@iachievedit


(Dave Grove) #4

Hi,

  There's a layer of Swift code that sits on top of the non-Swift
implementation of libdispatch to provide the Swift-level API for the
library. This is called the overlay.

  In Swift 2, the overlay for libdispatch was relatively thin. In
Swift 3 it became thicker and on Darwin platforms more reliant on compiler
support for importing Objective-C API declarations in a "Swifty" way. The
main work item for getting the libdispatch Swift 3 APIs on Linux is to
compensate for the lack of Objective-C by manually writing a layer (in
Swift) that sits between the basic C-level APIs libdispatch provides on
Linux and the desired user-visible Swift-3 APIs.

--dave

···

Joseph Bell <joe@iachieved.it> wrote on 06/21/2016 09:15:00 AM:

Thanks for the details, I appreciate it. I have seen the term
"Swift overlay" used, particularly in the context of libdispatch.
What does that mean exactly in this regard (searching for it returns
tutorials on overlay UIViews which I doubt is appropriate here).


(Chris Bailey) #5

Joe:

FYI, if you want to be able to use the Swift 2.2 APIs for Dispatch,
there's some instructions on how to build a toolchain with Dispatch
included here:
        https://gist.github.com/seabaylea/cad7808615c52cfd2fc9d1debcad832f

The third step uses a fork of Foundation from (based on master from a
couple of weeks ago) that enables the use of Dispatch by Foundation
itself, and adds NSURLSession support. If you just want to use Dispatch
directly, you can ignore that step.

As Dave says, we're working on adding Dispatch into the toolchain on
Linux, and uplifting it to the new Swift 3.0 APIs - if you want to get
involved, your definitely welcome!

Chris

<swift-corelibs-dev@swift.org>

···

From: David P Grove via swift-corelibs-dev
To: swift-corelibs-dev@swift.org
Date: 21/06/2016 14:02
Subject: Re: [swift-corelibs-dev] libdispatch/GCD for Swift 3.0 on
Linux
Sent by: swift-corelibs-dev-bounces@swift.org

Hi Joe,

TL;DR: right now the Swift 3.0 overlay for libdispatch is not available on
Linux.

But, a variety of activities are kicking off to get it there. There
should be visible progress (and opportunities to help if you are so
inclined) over the next few weeks.

While working to convert some NSThread code over to GCD on Linux I
noticed that (to my dismay) GCD wasn't included in the Swift 3.0
preview build, nor is it apart of the buildbot for Linux. Scouring
through the repository and mailing lists I can see where it is
possible to build, but there are no downstream instructions on how
to make a line like this:

let queue = DispatchQueue(label: "com.app.queue")

work with the swiftc compiler on Linux.

A couple of questions:

* are there any timelines that the principals of GCD with Swift 3 on
Linux can share; i.e., is the plan to have it included in time for
the Swift 3 GA release later this year?

I certainly hope so; but cannot speak for official plans.

* are there any follow-up instructions past getting it built on how
to use it (or will make install DESTDIR place it in the right spots
in the Swift 3 toolchain hierarchy?)

I expect when things are done, it will be similar to how building the
current Swift-2 dispatch overlay works on Linux. To build from source you
use swift/utils/build-script with --libdispatch and it takes care of all
the details (ie, it just works...).

--dave
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(Joe Bell) #6

David, Chris,

Thanks again for the responses regarding libdispatch (GCD) on Linux with
Swift 3.0. I took a stab at building what was there and indeed, I see
there are missing components to the overlay. For example, I see where
Dispatch.swift contains things like "public extension DispatchGroup" but
there is no actual DispatchGroup defined anywhere (just extensions to it).
The same goes for DispatchSemaphore, DispatchQueue, DispatchWorkItem, etc.
Unless I am offbase and that is defined (I certainly couldn't find it).

At any rate, thanks again for the work you're doing bringing GCD to Linux;
I'm looking forward to it.

Joe

···

On Tue, Jun 21, 2016 at 10:24 AM, David P Grove <groved@us.ibm.com> wrote:

Joseph Bell <joe@iachieved.it> wrote on 06/21/2016 09:15:00 AM:

>
> Thanks for the details, I appreciate it. I have seen the term
> "Swift overlay" used, particularly in the context of libdispatch.
> What does that mean exactly in this regard (searching for it returns
> tutorials on overlay UIViews which I doubt is appropriate here).
>

Hi,

There's a layer of Swift code that sits on top of the non-Swift
implementation of libdispatch to provide the Swift-level API for the
library. This is called the overlay.

In Swift 2, the overlay for libdispatch was relatively thin. In Swift 3
it became thicker and on Darwin platforms more reliant on compiler support
for importing Objective-C API declarations in a "Swifty" way. The main
work item for getting the libdispatch Swift 3 APIs on Linux is to
compensate for the lack of Objective-C by manually writing a layer (in
Swift) that sits between the basic C-level APIs libdispatch provides on
Linux and the desired user-visible Swift-3 APIs.

--dave

--
Joseph Bell
http://dev.iachieved.it/iachievedit/
@iachievedit


(Dave Grove) #7

Hi,

  I've been making some progress on the Swift 3 overlay for dispatch on
a branch [1]. It builds, but doesn't do much more beyond that yet. I
expect to raise a pull request within a week (once basic programs are
working).
--dave

[1]
https://github.com/dgrove-oss/swift-corelibs-libdispatch/tree/wrapping-overlay-stage-1

···

From: Joseph Bell <joe@iachieved.it>
To: David P Grove/Watson/IBM@IBMUS, Chris Bailey
            <BAILEYC@uk.ibm.com>
Cc: swift-corelibs-dev@swift.org
Date: 06/26/2016 05:30 PM
Subject: Re: [swift-corelibs-dev] libdispatch/GCD for Swift 3.0 on Linux

David, Chris,

Thanks again for the responses regarding libdispatch (GCD) on Linux with
Swift 3.0. I took a stab at building what was there and indeed, I see
there are missing components to the overlay. For example, I see where
Dispatch.swift contains things like "public extension DispatchGroup" but
there is no actual DispatchGroup defined anywhere (just extensions to it).
The same goes for DispatchSemaphore, DispatchQueue, DispatchWorkItem, etc.
Unless I am offbase and that is defined (I certainly couldn't find it).

At any rate, thanks again for the work you're doing bringing GCD to Linux;
I'm looking forward to it.

Joe

On Tue, Jun 21, 2016 at 10:24 AM, David P Grove <groved@us.ibm.com> wrote:
  Joseph Bell <joe@iachieved.it> wrote on 06/21/2016 09:15:00 AM:

  >
  > Thanks for the details, I appreciate it. I have seen the term
  > "Swift overlay" used, particularly in the context of libdispatch.
  > What does that mean exactly in this regard (searching for it returns
  > tutorials on overlay UIViews which I doubt is appropriate here).
  >

  Hi,

  There's a layer of Swift code that sits on top of the non-Swift
  implementation of libdispatch to provide the Swift-level API for the
  library. This is called the overlay.

  In Swift 2, the overlay for libdispatch was relatively thin. In Swift 3
  it became thicker and on Darwin platforms more reliant on compiler
  support for importing Objective-C API declarations in a "Swifty" way.
  The main work item for getting the libdispatch Swift 3 APIs on Linux is
  to compensate for the lack of Objective-C by manually writing a layer (in
  Swift) that sits between the basic C-level APIs libdispatch provides on
  Linux and the desired user-visible Swift-3 APIs.

  --dave

--
Joseph Bell
http://dev.iachieved.it/iachievedit/
@iachievedit