-
Notifications
You must be signed in to change notification settings - Fork 471
Initial integration of Swift overlay into libdispatch build #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In Dispatch.swift,
should be this instead...
|
Do we have a plan yet for how to get the -fblocks flag added when appropriate for Swift? For the -lBlocksRuntime argument, you may be able to deal with this by adding a link declaration to your module map: |
It's unfortunate that all the C-defines need computed variables to be shimmed over but it looks like that's also a direct mirror of the stdlib version of this code. |
I mirror ddunbar's suggestion about using the module link line to try including BlocksRuntime. I'm not in a position to check if that works on Linux myself though. |
@billabt associatedtype doesn't work in this context (not sure if this is by design, or a bug). Using a swiftc I built from git as of this morning, I get: error: associated types can only be defined in a protocol; define a type or introduce a 'typealias' to satisfy an associated type requirement |
Thanks @mwwa and @ddunbar for the linker suggestion. I had missed that I could have multiple linker directives in the module.map file. I had tried putting both dispatch and BlocksRuntime into a single linker directive, which didn't work. Updated module.map.in to have two linker directives, which does work. |
fc4618c
to
502c617
Compare
Squashed changes into a single commit and updated commit comment to reflect now only needing -Xcc -fblocks. |
This commit adds a src/swift directory that contains Dispatch.swift and Dispatch.c (based on existing files in swift/stdlib/public/SDK/Dispatch) and a module.map.in template. We made some initial changes to Dispatch.swift and Dispatch.c to adapt them to Linux by dropping MACH API functions/adapters. The libdispatch build process is extended to include Dispatch.o in libdispatch.so and to generate Dispatch.swiftmodule, Dispatch.swiftdoc and a module.map file when configure is given a --with-swift-toolchain argument. Swift programs that import Dispatch can be compiled, linked, and run against the generated files. However, because of the use of @convention(block) to bridge from Swift blocks to the -fblocks expected by dispatch, swiftc must be given the extra command line arguments -Xcc -fblocks
502c617
to
67450cb
Compare
Updated & squashed with a change to the command line argument of configure to --with-swift-toolchain as requested in the review of swiftlang/swift#1212 |
No I'm happy, I'll merge momentarily. |
Initial integration of Swift overlay into libdispatch build
Initial integration of Swift overlay into libdispatch build Signed-off-by: Daniel A. Steffen <[email protected]>
This commit adds a src/swift directory that contains
Dispatch.swift and Dispatch.c (based on existing files in
swift/stdlib/public/SDK/Dispatch) and a module.map.in template.
We made some initial changes to Dispatch.swift and Dispatch.c to
adapt them to Linux by dropping MACH API functions/adapters.
The libdispatch build process is extended to include Dispatch.o
in libdispatch.so and to generate Dispatch.swiftmodule,
Dispatch.swiftdoc and a module.map file when configure is
given a --with-swift-sdk argument.
Swift programs that import Dispatch can be compiled, linked,
and run against the generated files, but must include some
extra command line arguments due to the use of @convention(block)
to bridge from Swift blocks to the -fblocks expected by dispatch.
In particular, the following flags are currently needed to compile
a Swift program: -Xcc -fblocks -Xlinker -lBlocksRuntime