[PATCH] Support for the GNUstep Objective-C/Blocks runtime
Hi all, the GNUstep project maintains an Objective-C runtime library [0] that also features support for blocks. Until very recently, we were exposing quite a bit less about the block data structures than the blocks runtime from compiler-rt, but I just got around to adding them to a public header. Now it works like a charm with libdispatch and I was hoping that you might be willing to include the attached patch, which enables the configure script to detect the presence of a blocks-enabled Objective-C runtime. Best regards, Niels [0] http://svn.gna.org/svn/gnustep/libs/libobjc2/trunk/
Hi Niels, On Sun, Mar 11, 2012 at 6:10 PM, Niels Grewe <niels.grewe@halbordnung.de>wrote:
Hi all,
the GNUstep project maintains an Objective-C runtime library [0] that also features support for blocks. Until very recently, we were exposing quite a bit less about the block data structures than the blocks runtime from compiler-rt, but I just got around to adding them to a public header. Now it works like a charm with libdispatch and I was hoping that you might be willing to include the attached patch, which enables the configure script to detect the presence of a blocks-enabled Objective-C runtime.
While I am glad to hear you are working on getting blocks support added to GNUstep, I am not sure it makes sense to have a completely different blocks runtime for Objective-C v.s. ordinary C. Judging by the headers in libobjc2, it looks like you reimplemented the blocks runtime rather than copying it verbatim from compiler-rt. That has me somewhat worried about possible differences and incompatibilities, and I would prefer to use the "official" blocks runtime if possible. As an alternative, I have repackaged the blocks runtime found in compiler-rt, and made a standalone library named libBlocksRuntime [1]. This is currently used for C/C++ programs that use libdispatch, and I would hope that Objective-C programs could also link against this library. Any thoughts? Regards, - Mark [1] http://mark.heily.com/project/libblocksruntime
Hi Mark, On Tue, Mar 13, 2012 at 11:46:39PM -0400, Mark Heily wrote:
While I am glad to hear you are working on getting blocks support added to GNUstep, I am not sure it makes sense to have a completely different blocks runtime for Objective-C v.s. ordinary C. Judging by the headers in libobjc2, it looks like you reimplemented the blocks runtime rather than copying it verbatim from compiler-rt. That has me somewhat worried about possible differences and incompatibilities, and I would prefer to use the "official" blocks runtime if possible.
First of all: We don't expect people to use different runtimes for C and Objective-C programmes. C programmes will work just fine with libobjc2 as the blocks runtime (without the need to link the Objective-C Foundation library and all), as libdispatch clearly demonstrates. Furthermore, I don't think that GNUstep having its own implementation of the blocks runtime is a real issue. After all, both the compiler-rt blocks runtime and the GNUstep one work with blocks generated by clang. Also, if incompatibilities did arise (which I think they won't), we could always have a look at the specification and decide who get things wrong ;-)
As an alternative, I have repackaged the blocks runtime found in compiler-rt, and made a standalone library named libBlocksRuntime [1]. This is currently used for C/C++ programs that use libdispatch, and I would hope that Objective-C programs could also link against this library.
Well, the problem is that Blocks are first class objects in Objective-C. The compiler-rt blocks runtime has some shims for this that the Foundation library is required to patch up afterwards. By having blocks support directly in the runtime, we avoid these troubles. I hope this clears a few things up. I've also CCed David Chisnall, the maintainer of the GNUstep Objective-C runtime, who might have some more insights into this. Cheers, Niels
On Tue, Mar 13, 2012 at 11:46:39PM -0400, Mark Heily wrote:
While I am glad to hear you are working on getting blocks support added to GNUstep
Oh, and by the way: We've had blocks support for time immemorial, it's just recently that I happened to want to play with libdispatch… Cheers, Niels
On 03/11/2012 06:10 PM, Niels Grewe wrote:
Hi all,
the GNUstep project maintains an Objective-C runtime library [0] that also features support for blocks. Until very recently, we were exposing quite a bit less about the block data structures than the blocks runtime from compiler-rt, but I just got around to adding them to a public header. Now it works like a charm with libdispatch and I was hoping that you might be willing to include the attached patch, which enables the configure script to detect the presence of a blocks-enabled Objective-C runtime.
The next release of the BlocksRuntime library will be designed to work in harmony with libobjc2. This will be achieved by making all of the exported ELF symbols weak. This means you can link with both -lBlocksRuntime and -lobjc, and the strong symbols in libobjc2 will take precedence. I've done some testing using the libdispatch testsuite, and it seems to work fine. So, what I'm suggesting is that libdispatch continue to use the BlocksRuntime library, and Objective-C programs that link against libobjc2 will be automatically switched over to the Objective-C blocks runtime. Here is the URL if anyone wants to test it prior to the release: svn://mark.heily.com/libBlocksRuntime/branches/objc2 Regards, - Mark
participants (2)
-
Mark Heily
-
Niels Grewe