Skip to content

Conversation

@hmelder
Copy link
Member

@hmelder hmelder commented Sep 29, 2025

Complexity of the Blocks Runtime in libdispatch is lower and only copies the block descriptor not the body. This means we do not need to mprotect a page as -W- and then R-X to execute copied instructions.

@hmelder
Copy link
Member Author

hmelder commented Sep 29, 2025

Because of this, there is no need for a thunk written in assembly to jump to the block body residing in the mprotected page.

@triplef
Copy link
Member

triplef commented Sep 30, 2025

Sounds great! Builds are currently failing with:

CMake Error at CMakeLists.txt:252 (message):
  libBlocksRuntime does not contain _Block_use_RR2().  Enable
  EMBEDDED_BLOCKS_RUNTIME to use the built-in blocks runtime.

@hmelder
Copy link
Member Author

hmelder commented Sep 30, 2025

I know. The header is not in the search path. So this is just a CMake Configuration issue :)

@hmelder hmelder force-pushed the use-libdispatch-blocksrt branch 3 times, most recently from cef4d41 to b609d7d Compare October 6, 2025 01:19
@hmelder
Copy link
Member Author

hmelder commented Oct 6, 2025

Arggh should build now :D

@hmelder
Copy link
Member Author

hmelder commented Oct 6, 2025

I will clean up the patches and upstream them into the respective repositories.

@hmelder hmelder marked this pull request as draft October 6, 2025 16:05
@hmelder hmelder force-pushed the use-libdispatch-blocksrt branch from b609d7d to 51fa164 Compare October 20, 2025 11:15
libBlocksRuntime does not export the symbols correctly when building on
Windows. Additionally, libobjc2 has some CMake configuration bugs.
@hmelder hmelder force-pushed the use-libdispatch-blocksrt branch from 51fa164 to 056c119 Compare October 20, 2025 11:17
@hmelder hmelder marked this pull request as ready for review October 20, 2025 11:17
@hmelder
Copy link
Member Author

hmelder commented Oct 20, 2025

Patches can be removed once swiftlang/swift-corelibs-libdispatch#916 and gnustep/libobjc2#355 are merged.

@hmelder
Copy link
Member Author

hmelder commented Oct 20, 2025

Hmm seems like GNUstep tries to use the GSBlocks compatibility layer, instead of libBlocksRuntime ...

gnustep-make requires patching as well.

@hmelder
Copy link
Member Author

hmelder commented Oct 24, 2025

Breaking Changes:

  • All Objective-C programs and shared libraries that use blocks need to explicitly link against BlocksRuntime.lib. Alternatively, we could also link the BlocksRuntime statically into libobjc and link libdispatch against libobjc.

Open Pull Requests (Patches can be removed once merged):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants