From d258655d8adac93f7701d6c2c4e1dfb0e06905d0 Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 24 Oct 2025 02:00:41 -0700 Subject: [PATCH 1/5] Use BLOCK_EXPORT when exporting globals on Windows BLOCK_EXPORT expands to 'extern' or 'extern "C"'. --- src/BlocksRuntime/Block.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/BlocksRuntime/Block.h b/src/BlocksRuntime/Block.h index 32f27f4..d24bbdc 100644 --- a/src/BlocksRuntime/Block.h +++ b/src/BlocksRuntime/Block.h @@ -52,13 +52,8 @@ BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int); BLOCK_EXPORT void _Block_object_dispose(const void *, const int); // Used by the compiler. Do not use these variables yourself. -#if defined(_WIN32) -extern void * _NSConcreteGlobalBlock[32]; -extern void * _NSConcreteStackBlock[32]; -#else BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]; BLOCK_EXPORT void * _NSConcreteStackBlock[32]; -#endif #if __cplusplus } From 396187ecfb6d27fab2cb766163347627ec3313fa Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 24 Oct 2025 02:07:16 -0700 Subject: [PATCH 2/5] Fix path to BlocksRuntime.def --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8603c6a..32d9ff3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ add_library(BlocksRuntime if(WIN32) target_sources(BlocksRuntime PRIVATE - BlocksRuntime.def) + src/BlocksRuntime/BlocksRuntime.def) if(NOT BUILD_SHARED_LIBS) target_compile_definitions(BlocksRuntime PUBLIC BlocksRuntime_STATIC) From 2db1cb20cf541a1adfba34bbd03150171c0fa2ea Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 24 Oct 2025 02:08:01 -0700 Subject: [PATCH 3/5] Add missing globals to BlocksRuntime.def NSConcrete* globals need to be exported for runtime integration (libobjc2 for example). --- src/BlocksRuntime/BlocksRuntime.def | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BlocksRuntime/BlocksRuntime.def b/src/BlocksRuntime/BlocksRuntime.def index a3b1aab..a4142b2 100644 --- a/src/BlocksRuntime/BlocksRuntime.def +++ b/src/BlocksRuntime/BlocksRuntime.def @@ -2,3 +2,7 @@ LIBRARY BlocksRuntime EXPORTS _NSConcreteGlobalBlock CONSTANT _NSConcreteStackBlock CONSTANT + _NSConcreteMallocBlock CONSTANT + _NSConcreteAutoBlock CONSTANT + _NSConcreteFinalizingBlock CONSTANT + _NSConcreteWeakBlockVariable CONSTANT From 9ab305d172c4cc094cc20c0efe7a94a90c6f48f7 Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 24 Oct 2025 02:09:39 -0700 Subject: [PATCH 4/5] Remove unused CMakeLists.txt --- src/BlocksRuntime/CMakeLists.txt | 43 -------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 src/BlocksRuntime/CMakeLists.txt diff --git a/src/BlocksRuntime/CMakeLists.txt b/src/BlocksRuntime/CMakeLists.txt deleted file mode 100644 index 2301ffe..0000000 --- a/src/BlocksRuntime/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ - -add_library(BlocksRuntime - data.c - runtime.c) -if(WIN32) - target_sources(BlocksRuntime PRIVATE - BlocksRuntime.def) - - if(NOT BUILD_SHARED_LIBS) - target_compile_definitions(BlocksRuntime PUBLIC - BlocksRuntime_STATIC) - target_compile_options(BlocksRuntime PUBLIC - "$<$:SHELL:$<$:-Xclang >-static-libclosure>" - $<$:SHELL:-Xcc -static-libclosure>) - endif() -endif() - -target_include_directories(BlocksRuntime PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}) -if(HAVE_OBJC AND CMAKE_DL_LIBS) - target_link_libraries(BlocksRuntime PUBLIC - ${CMAKE_DL_LIBS}) -endif() - -export(TARGETS BlocksRuntime - FILE cmake/export/BlocksRuntime.cmake) - -if(LINKER_SUPPORTS_BUILD_ID) - target_link_options(BlocksRuntime PRIVATE "LINKER:--build-id=sha1") -endif() - -add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime) - -install(FILES Block.h - DESTINATION ${INSTALL_BLOCK_HEADERS_DIR}) -install(FILES Block_private.h - DESTINATION ${INSTALL_BLOCK_HEADERS_DIR}/BlocksRuntime) -set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS BlocksRuntime) -install(TARGETS BlocksRuntime - EXPORT BlocksRuntime - ARCHIVE DESTINATION ${INSTALL_TARGET_DIR} - LIBRARY DESTINATION ${INSTALL_TARGET_DIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) From b77dc2d7b41104aa4dfbf1b946139b3fa31cd767 Mon Sep 17 00:00:00 2001 From: hmelder Date: Fri, 31 Oct 2025 03:53:01 -0700 Subject: [PATCH 5/5] Remove BlocksRuntime.def --- CMakeLists.txt | 5 +---- src/BlocksRuntime/BlocksRuntime.def | 8 -------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 src/BlocksRuntime/BlocksRuntime.def diff --git a/CMakeLists.txt b/CMakeLists.txt index 32d9ff3..9f3aff8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,10 +57,7 @@ add_library(BlocksRuntime src/BlocksRuntime/runtime.c) if(WIN32) - target_sources(BlocksRuntime PRIVATE - src/BlocksRuntime/BlocksRuntime.def) - - if(NOT BUILD_SHARED_LIBS) + if (NOT BUILD_SHARED_LIBS) target_compile_definitions(BlocksRuntime PUBLIC BlocksRuntime_STATIC) target_compile_options(BlocksRuntime PUBLIC "$<$:SHELL:$<$:-Xclang >-static-libclosure>" diff --git a/src/BlocksRuntime/BlocksRuntime.def b/src/BlocksRuntime/BlocksRuntime.def deleted file mode 100644 index a4142b2..0000000 --- a/src/BlocksRuntime/BlocksRuntime.def +++ /dev/null @@ -1,8 +0,0 @@ -LIBRARY BlocksRuntime -EXPORTS - _NSConcreteGlobalBlock CONSTANT - _NSConcreteStackBlock CONSTANT - _NSConcreteMallocBlock CONSTANT - _NSConcreteAutoBlock CONSTANT - _NSConcreteFinalizingBlock CONSTANT - _NSConcreteWeakBlockVariable CONSTANT