Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
22 changes: 22 additions & 0 deletions patches/gnustep-base-blocksruntime.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
commit a6f07549b8ea67e107a9a2fb3edadc7412311188 (HEAD -> blocks-rt)
Author: Hugo Melder <service@hugomelder.com>
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(<objc/blocks_runtime.h>)
-# include <objc/blocks_runtime.h>
+#if __has_include(<Block.h>)
+# include <Block.h>
#else

#ifdef __cplusplus

26 changes: 26 additions & 0 deletions patches/libdispatch-ext-blocksruntime.patch
Original file line number Diff line number Diff line change
@@ -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
36 changes: 0 additions & 36 deletions patches/libdispatch-own-blocksruntime.patch

This file was deleted.

3,843 changes: 3,843 additions & 0 deletions patches/libobjc2-blocksrt-detection.patch

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions phases/17-blocksruntime.bat
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions phases/18-libdispatch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions phases/11-libobjc2.bat → phases/19-libobjc2.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion phases/20-gnustep-make.sh → phases/21-gnustep-make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading