[libdispatch-dev] GCD libdispatch w/Blocks support working on Free (f

Robert Watson rwatson at FreeBSD.org
Sun Sep 27 10:41:22 UTC 2009

Dear all--

Those of you at the Cambridge devsummit are already aware of the port of 
Apple's Grand Central Dispatch (GCD), a.k.a. libdispatch, to FreeBSD by Stacey 
Son and I, in collaboration with Apple.  I've now uploaded my GCD talk slides 
to the wiki:


We now have a devel/libdispatch port, which works out-of-the-box on FreeBSD 
9-CURRENT.  libdispatch requires modest changes to kqueue, which we will merge 
to 8.x once the code freeze lifts.

As of yesterday, I have libdispatch working with Apple's "Blocks" C languae 
extension as found in clang, the last major architecture component required to 
use GCD-based applications FreeBSD.  Jordan Hubbard at Apple has kindly 
provided the necessary bits bundled up in a clang/llvm/compiler-rt package for 
FreeBSD until the clang port is updated.  Some details in the attached e-mail.

As I mentioned at the FreeBSD developer summit, this is a work-in-progress (in 
particular, we don't support pthread work queues, which allow the kernel 
schedule to get involved in expanding the size of the thread worker pool 
dynamically), but it should now be more than adequate to use in practice.

Robert N M Watson
Computer Laboratory
University of Cambridge

---------- Forwarded message ----------
Date: Sat, 26 Sep 2009 20:37:51 +0100 (BST)
From: Robert Watson <robert at fledge.watson.org>
To: libdispatch-dev at lists.macosforge.org
Subject: [libdispatch-dev] GCD libdispatch w/Blocks support working on	FreeBSD

Dear all:

This is a quick update for those interested in the general portability of 
libdispatch, and perhaps specifically FreeBSD.

With a bit of help from Jordan Hubbard, I now have libdispatch working with 
Blocks on FreeBSD.  Jordan has put up a FreeBSD clang-devel package that 
includes Blocks parts and the C runtime bits here:


I've updated the libdispatch build parts to detect and use Blocks when compiled 
with clang, and fixed a few nits in libdispatch that I ran into along the way 
(and one apparent clang bug).  With Jordan's package as a starting point, 
Blocks pretty much "just worked", so I'm optimistic that people will be able to 
reproduce this on other platforms able to run the non-Blocks libdispatch 
without much difficulty.

If you update to at least r45 of libdispatch, you should now be able to do:

   CC=clang ./configure --with-blocks-runtime=/usr/local/lib

and get a libdispatch with Blocks support.

The reason for the configure argument is that the current clang-devel package 
doesn't automatically add libBlocksRuntime dependency for binaries compiled 
with -fblocks.  Once Blocks support shakes out a bit more in clang/FreeBSD, 
this should go away.

I am able to run basic Blocks-based test tools with GCD on FreeBSD without 
difficulty.  The FreeBSD port should be updated to reflect this shortly.

Robert N M Watson
Computer Laboratory
University of Cambridge
libdispatch-dev mailing list
libdispatch-dev at lists.macosforge.org

More information about the freebsd-current mailing list