diff --git a/README.md b/README.md index 5e31070..06fd454 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Alternatively, `clang-cl.exe` can be used to build Objective-C code directly in clang-cl -I C:\GNUstep\x64\Debug\include -fobjc-runtime=gnustep-2.0 -Xclang -fexceptions -Xclang -fobjc-exceptions -fblocks -DGNUSTEP -DGNUSTEP_WITH_DLL -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1 -D_NATIVE_OBJC_EXCEPTIONS /MDd /Z7 /c test.m # link object file into executable using the LLD linker - clang-cl test.obj gnustep-base.lib objc.lib dispatch.lib -fuse-ld=lld /MDd /Z7 -o test.exe /link /LIBPATH:C:\GNUstep\x64\Debug\lib + clang-cl test.obj gnustep-base.lib objc.lib BlocksRuntime.lib dispatch.lib -fuse-ld=lld /MDd /Z7 -o test.exe /link /LIBPATH:C:\GNUstep\x64\Debug\lib Specify `/MDd` for debug builds, and `/MD` for release builds, in order to link against the same runtime libraries as the DLLs in `C:\GNUstep\x64\Debug` and `C:\GNUstep\x64\Release` respectively. Adding `/Z7` [adds full debug symbols](https://learn.microsoft.com/cpp/build/reference/z7-zi-zi-debug-information-format#z7). diff --git a/patches/gnustep-base-blocksruntime.patch b/patches/gnustep-base-blocksruntime.patch new file mode 100644 index 0000000..0143de4 --- /dev/null +++ b/patches/gnustep-base-blocksruntime.patch @@ -0,0 +1,22 @@ +commit a6f07549b8ea67e107a9a2fb3edadc7412311188 (HEAD -> blocks-rt) +Author: Hugo Melder +Date: Mon Oct 20 13:38:44 2025 +0200 + + Use standard blocks runtime header + +diff --git a/Headers/GNUstepBase/GSBlocks.h b/Headers/GNUstepBase/GSBlocks.h +index 758b21130..bf745cb26 100644 +--- a/Headers/GNUstepBase/GSBlocks.h ++++ b/Headers/GNUstepBase/GSBlocks.h +@@ -112,8 +112,8 @@ typedef retTy(^name)() + #define CALL_BLOCK_NO_ARGS(block) ({if (NULL != block) CALL_NON_NULL_BLOCK_NO_ARGS(block);}) + #define CALL_BLOCK_RET_NO_ARGS(block, rettype) ((NULL != block) ? (rettype)CALL_NON_NULL_BLOCK_NO_ARGS(block) : (rettype)0) + +-#if __has_include() +-# include ++#if __has_include() ++# include + #else + + #ifdef __cplusplus + diff --git a/patches/libdispatch-ext-blocksruntime.patch b/patches/libdispatch-ext-blocksruntime.patch new file mode 100644 index 0000000..c941c3a --- /dev/null +++ b/patches/libdispatch-ext-blocksruntime.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 51f1f1b..564ddac 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -333,7 +333,7 @@ add_subdirectory(man) + add_subdirectory(os) + add_subdirectory(private) + if(NOT APPLE) +- add_subdirectory(src/BlocksRuntime) ++ include(cmake/modules/FindBlocksRuntime.cmake) + endif() + add_subdirectory(src) + if(BUILD_TESTING) +diff --git a/cmake/modules/FindBlocksRuntime.cmake b/cmake/modules/FindBlocksRuntime.cmake +index 111a5d6..3310b75 100644 +--- a/cmake/modules/FindBlocksRuntime.cmake ++++ b/cmake/modules/FindBlocksRuntime.cmake +@@ -17,7 +17,7 @@ if(BlocksRuntime_INCLUDE_DIR AND BlocksRuntime_LIBRARIES) + else() + find_path(BlocksRuntime_INCLUDE_DIR + NAMES +- Blocks.h ++ Block.h + HINTS + ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + find_library(BlocksRuntime_LIBRARIES diff --git a/patches/libdispatch-own-blocksruntime.patch b/patches/libdispatch-own-blocksruntime.patch deleted file mode 100644 index a634627..0000000 --- a/patches/libdispatch-own-blocksruntime.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 45461eb..7c954fb 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -178,6 +178,8 @@ if(NOT ANDROID) - find_package(LibRT) - endif() - -+find_package(BlocksRuntime QUIET) -+ - check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT) - check_function_exists(getprogname HAVE_GETPROGNAME) - check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME) -@@ -331,7 +333,7 @@ add_subdirectory(dispatch) - add_subdirectory(man) - add_subdirectory(os) - add_subdirectory(private) --if(NOT APPLE) -+if(NOT BlocksRuntime_FOUND) - add_subdirectory(src/BlocksRuntime) - endif() - add_subdirectory(src) -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index ed5d2f4..257b02d 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -80,9 +80,6 @@ function(add_unit_test name) - # to reduce probability of test failures due to machine load. - target_compile_options(${name} PRIVATE -DLENIENT_DEADLINES=1) - endif() -- target_include_directories(${name} -- SYSTEM BEFORE PRIVATE -- "${BlocksRuntime_INCLUDE_DIR}") - if("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC") - target_compile_options(${name} PRIVATE -Xclang -fblocks) - target_compile_options(${name} PRIVATE /W3 -Wno-deprecated-declarations) diff --git a/patches/libobjc2-blocksrt-detection.patch b/patches/libobjc2-blocksrt-detection.patch new file mode 100644 index 0000000..ed88290 --- /dev/null +++ b/patches/libobjc2-blocksrt-detection.patch @@ -0,0 +1,3843 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cleanup CMake configuration for external blocks runtime support by hmelder · Pull Request #355 · gnustep/libobjc2 · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ Skip to content + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+ + + + + +
+ + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + / + + libobjc2 + + + Public +
+ + +
+ +
+ + +
+
+ +
+
+ + + + +
+ + + + + + +
+ + + + + + +
+ +
+ + + +
+ + + +
+ + + + +
+ + + + + + + + +
+
+

Conversation

+
+ + + +
+ +
+ + + @hmelder +
+
+
+
+
+ + + + + + + + + + + + Copy link + +
+
+
+
+ +
+ + + + Member + + + + +
+ +

+
+ @hmelder + + + hmelder + + + + + + + commented + + + Oct 20, 2025 + + + +
+ +

+
+ +
+
+ + +
+

This pull request addresses the following issues:

+
    +
  • The check_symbol_exists check fails, when Block.h is located in the CMAKE_PREFIX_PATH.
  • +
  • Internal blocks runtime is always compiled, resulting in duplicate symbol errors on Windows and WebAssembly.
  • +
  • Internal blocks runtime test is always compiled and executed.
  • +
  • External symbols from the blocks runtime are incorrectly imported on Windows
  • +
+
+
+ +
+ +
+ +
+ + +

+ + + + + +

+ + + +
+
+
+ +
+ +
+
+
+ + + + +
+ + +
+ +
+ +
+
@hmelder + hmelder + + + requested a review + from davidchisnall + + + October 20, 2025 10:43 + +
+
+
+ +
+
@hmelder + hmelder + + + force-pushed + the + + + cmake-fix-include-dirs + + + + branch + from + f557cc1 to + 6a18e54 + Compare + + + + + October 20, 2025 10:49 + +
+
+
+
+ +
+ +
+ +
+ This was referenced Oct 20, 2025 +
+ + + + + + +
+
+ + + + + +
+
+ + + +
+ +
+ +
+
+ +
+
hmelder + + + added 6 commits + October 27, 2025 11:36
+
+
+ +
+
+
+
+ +
+
+ + @hmelder +
+
+ + + +
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + 2693fd4 + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + @hmelder +
+
+ + + +
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + 708e17f + +
+
+
+
+
This is a slightly modified version of the file found in swift-corelibs-libdispatch. Notabily, the non-existent HINTS are removed.
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + @hmelder +
+
+ + + +
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + 760eb37 + +
+
+
+
+
Use cmake/FindBlocksRuntime.cmake to locate the external blocks runtime,
+and do not compile the internal one.
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + @hmelder +
+
+ + + +
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + 2d88c0b + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + @hmelder +
+
+ + + +
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + 0708874 + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ + @hmelder +
+
+ + + +
+ + + + + + + + +
+ +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + fca3146 + +
+
+
+
+ +
+
+
+ + +
+ +
+ +
+ +
+
@hmelder + hmelder + + + force-pushed + the + + + cmake-fix-include-dirs + + + + branch + from + 6a18e54 to + fca3146 + Compare + + + + + October 27, 2025 10:37 + +
+
+
+ +
+
@hmelder + hmelder + + + requested review from + davidchisnall + + and removed request for + davidchisnall + + + October 27, 2025 10:52 + +
+
+ + +
+ +
+ + +
+ +
+ @hmelder + + +
+ + + +
+ +
+
+
+
+ + + + + + + + + + + + Copy link + +
+
+
+
+ +
+ + + + Member + + + + + Author + + +
+ +

+
+ + + + hmelder + + + + + + + commented + + + Oct 27, 2025 + + + +
+ +

+
+ + +
+ + + + + + + + + +
+

Rebased to latest master

+ +
+
+ + +
+ + + + +
+ +
+
+
+ +
+ + +

+ + + + + +

+ + + +
+
+
+ +
+ + +
+ + + + + + + +
+
+ +
+ + + +
+ +
+ +
+
+ +
+ + 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.

+ + + + + + + + +
+
+
+
+ +
+ + + + +
+
+

+ 1 participant +

+
+ + @hmelder +
+
+
+ + + + + + + + + + + + +
+ + +
+ +
+
+ + + +
+ + +
+ +
+ + +
+
+ +
+ +
+

Footer

+ + + + +
+
+ + + + + © 2025 GitHub, Inc. + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + +
+
+
+ + + diff --git a/phases/16-libxml2.bat b/phases/15-libxml2.bat similarity index 100% rename from phases/16-libxml2.bat rename to phases/15-libxml2.bat diff --git a/phases/17-libxslt.bat b/phases/16-libxslt.bat similarity index 100% rename from phases/17-libxslt.bat rename to phases/16-libxslt.bat diff --git a/phases/17-blocksruntime.bat b/phases/17-blocksruntime.bat new file mode 100644 index 0000000..0f30b2b --- /dev/null +++ b/phases/17-blocksruntime.bat @@ -0,0 +1,33 @@ +@echo off +setlocal + +set PROJECT=blocksruntime +set GITHUB_REPO=hmelder/swift-corelibs-blocksruntime +set TAG=blocks-rt-win32 + +:: load environment and prepare project +call "%~dp0\..\scripts\common.bat" prepare_project || exit /b 1 + +set BUILD_DIR="%SRCROOT%\%PROJECT%\build-%ARCH%-%BUILD_TYPE%" +if exist "%BUILD_DIR%" (rmdir /S /Q "%BUILD_DIR%" || exit /b 1) +mkdir "%BUILD_DIR%" || exit /b 1 +cd "%BUILD_DIR%" || exit /b 1 + +echo. +echo ### Running cmake +:: CXX and linker flags below are to produce PDBs for release builds. +cmake .. %CMAKE_OPTIONS% ^ + -D CMAKE_CXX_FLAGS_RELWITHDEBINFO="/Zi" ^ + -D CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO="/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF" ^ + || exit /b 1 + +echo. +echo ### Building +ninja || exit /b 1 + +echo. +echo ### Installing +ninja install || exit /b 1 + +:: install PDB file +xcopy /Y /F BlocksRuntime.pdb "%INSTALL_PREFIX%\bin\" || exit /b 1 diff --git a/phases/18-libdispatch.bat b/phases/18-libdispatch.bat index 37f3ccf..3827223 100644 --- a/phases/18-libdispatch.bat +++ b/phases/18-libdispatch.bat @@ -22,17 +22,15 @@ cd "%BUILD_DIR%" || exit /b 1 echo. echo ### Running cmake :: CXX and linker flags below are to produce PDBs for release builds. -:: BlocksRuntime parameters provided to use blocks runtime from libobjc2 with libdispatch-own-blocksruntime.patch. :: libdispatch only supports building with clang-cl frontend. cmake .. %CMAKE_OPTIONS% ^ -D BUILD_SHARED_LIBS=YES ^ -D INSTALL_PRIVATE_HEADERS=YES ^ -D CMAKE_CXX_FLAGS_RELWITHDEBINFO="/Zi" ^ -D CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO="/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF" ^ - -D BlocksRuntime_INCLUDE_DIR=%INSTALL_PREFIX%\include ^ - -D BlocksRuntime_LIBRARIES=%INSTALL_PREFIX%\lib\objc.lib ^ -D CMAKE_C_COMPILER=clang-cl ^ -D CMAKE_CXX_COMPILER=clang-cl ^ + -D BlocksRuntime_INCLUDE_DIR="%INSTALL_PREFIX%\include\BlocksRuntime" ^ || exit /b 1 echo. diff --git a/phases/11-libobjc2.bat b/phases/19-libobjc2.bat similarity index 89% rename from phases/11-libobjc2.bat rename to phases/19-libobjc2.bat index 4b8784b..ab31b9e 100644 --- a/phases/11-libobjc2.bat +++ b/phases/19-libobjc2.bat @@ -18,6 +18,8 @@ echo ### Running cmake :: GNUSTEP_CONFIG is set to empty string to prevent CMake from finding it in install root. cmake .. %CMAKE_OPTIONS% ^ -D GNUSTEP_CONFIG= ^ + -D EMBEDDED_BLOCKS_RUNTIME=OFF ^ + -D BlocksRuntime_INCLUDE_DIR="%INSTALL_PREFIX%\include\BlocksRuntime" ^ || exit /b 1 echo. diff --git a/phases/19-libcurl.bat b/phases/20-libcurl.bat similarity index 100% rename from phases/19-libcurl.bat rename to phases/20-libcurl.bat diff --git a/phases/20-gnustep-make.sh b/phases/21-gnustep-make.sh similarity index 86% rename from phases/20-gnustep-make.sh rename to phases/21-gnustep-make.sh index e9d0258..298c5e2 100755 --- a/phases/20-gnustep-make.sh +++ b/phases/21-gnustep-make.sh @@ -32,7 +32,8 @@ fi --prefix="$UNIX_INSTALL_PREFIX" \ --with-library-combo=ng-gnu-gnu \ --with-runtime-abi=gnustep-2.2 \ - CFLAGS="$CFLAGS" \ + CFLAGS="$CFLAGS -I$UNIX_INSTALL_PREFIX/include/BlocksRuntime" \ + LDFLAGS="$LDFLAGS -lBlocksRuntime -L$UNIX_INSTALL_PREFIX/lib" \ $CONFIGURE_OPTS echo