GNUstep's libobjc2 runtime provides blocks support as well. It would be nice if this worked with your tree out of box. This is what I need to do to get things working:
LIBS="-l:libobjc.so.4" CFLAGS="-D__BLOCKS__ -O2 -fblocks" ./configure
(-D__BLOCKS__ may not be needed, I added that just to be sure).
then you need to replace
Given that libdispatch is most likely to be used by cross-platform apps, it is very likely that it's users will have GNUstep installed when on Linux.
I'm not familiar with GNUStep, and I'm not even terribly familiar with the Autotools build system that libdispatch uses, but I should have time to look into this in a few weeks.
In the meantime, you're welcome to submit a pull request.
Yeah, I hate Autotools too :-( Never really managed to do anything useful with it.
You could include a script that will make symlinks to "pose" GNUstep libobjc2 as libBlockRuntime as well as required header files. I will fork this project to do all the needed changes. This will break the requirement of libBlocksRuntime (or clang's compiler-rt) but add requirements of GNUstep-make and GNUstep's libobjc2.
Well because the blocks ABI is a bit different between GNUstep and Apple.
Apple used their C-level CoreFoundation technologies to implement blocks but GNUstep used GSBlock, an Objective-C class.
Simpler cross-use the ABI is okay, but when any copying is involved, the difference in ABI will break the program and corrupt memory structure.
Ah okay, that's interesting. Is this ABI difference documented anywhere?
I have no idea, but I know the API is identical. So pretty much it is link-against thing. Just drop the libBlocksRuntime header files and library and use libobjc2 ones.
The ABI of GNUstep's Blocks should be identical to Apple's Blocks. I don't know why they chose different header file names, but now that you've switched to CMake, it should be much easier to support it.
See https://github.com/LubosD/darling-overlay/blob/master/dev-libs/libdispatch/files/gnustep-blocks.patch for the patch I currently use.
So I think the best way forward is to use the same approach as GNUstep: weak linking.
Explanation - there are only two situations possible: