<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Dave,<div class=""><br class=""></div><div class="">Thanks for the update! It seems like you’ve really made great progress on this.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 3:05 PM, David P Grove via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><p class="">Hi again.  Sorry for my silence on this blocks/libdispatch conversation for over a week. <br class=""><br class="">I've been experimenting with taking the Swift and Objective C code from the Dispatch overlay (swift/stdlib/public/SDK/Dispatch/) and getting it built into libdispatch using libdispatch's existing autotools-based build system.  This is my understanding of the direction Tony suggested we pursue in pull request #974 [1].  I have a branch of libdispatch [2] which can produce a Dispatch.swiftmodule and libdispatch.so that can be used to satisfy an import Dispatch request from a Swift program and allow Swift blocks to be submitted to dispatch functions like dispatch_async.  The resulting executable runs successfully and uses libdispatch.  So perhaps this is getting close, but I had some questions.<br class=""><br class="">One of the not nice things is that just like the existing overlay, it uses @convention(block) to cause the compiler to generate code that bridges between Swift blocks and the Objective C compatible blocks that dispatch is expecting/using internally.  This (a) is less efficient than I would like and (b) forces the Swift program that imports Dispatch to be compiled with -Xcc -fblocks -Xlinker -lBlocksRuntime.   I don't see a good way of avoiding this absent some compiler work that allow all of the C code in dispatch &amp; its test suite to be compiled to use Swift compatible blocks.  I'm assuming this would take a while, so we should try to not gate progress on integrating dispatch with this compiler work.  Is this approach reasonable for now?  Can we do better?<br class=""><br class=""></p></div></div></blockquote><div><br class=""></div><div>I think we can absolutely do better — but I’m also a believer in incremental development. If we get this started by requiring Swift apps to put in the special flags and link the runtime, then we can tackle that problem separately.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><p class="">Another not nice thing is that the libdispatch build uses libtool to get portable compilation of C/C++ code. I tried and failed to get libtool to integrate reasonable with swiftc.  As a result the rules that produce Dispatch.o from Dispatch.swift so it can be linked into libdispatch.la is not going to be very portable.  If someone has better ideas, that would be good…<br class=""><br class=""></p></div></div></blockquote>Hm, not sure about this one. If we can get support for our two Ubuntu platforms though, then I think others will be happy to help jump in and help solve portability problems.<br class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><p class="">I have a little more work to do so that the install target includes DIspatch.swiftmodule and module.map in the set of things that are installed.  Is there more that needs to be done before a pull request to get this into libdisaptch makes sense?<br class=""><br class="">thanks,<br class=""><br class="">—dave<br class=""><br class=""></p></div></div></blockquote>Let’s get the PR started and then make improvements from there.</div><div><br class=""></div><div>Thanks again for your hard work on this! Swift on Linux will be much better with integrated support for dispatch. I can’t wait to remove some #ifdefs in Foundation.</div><div><br class=""></div><div>- Tony</div><div><blockquote type="cite" class=""><div class=""><div class=""><p class="">[1] <a href="https://github.com/apple/swift/pull/974" class="">https://github.com/apple/swift/pull/974</a><br class="">[2] <a href="https://github.com/dgrove-oss/swift-corelibs-libdispatch/tree/swift-overlay" class="">https://github.com/dgrove-oss/swift-corelibs-libdispatch/tree/swift-overlay</a><br class=""><br class="">
</p></div>
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></div></body></html>