Skip to content

Commit a32c74e

Browse files
committed
libdispatch: use blocks runtime from libobjc2
Using patch from: swiftlang/swift-corelibs-libdispatch#534
1 parent 834dcc2 commit a32c74e

File tree

2 files changed

+92
-5
lines changed

2 files changed

+92
-5
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
From f49931127fe7673931c6550194c593923b2fbfd7 Mon Sep 17 00:00:00 2001
2+
From: Niels Grewe <[email protected]>
3+
Date: Sun, 24 Nov 2019 08:24:56 +0100
4+
Subject: [PATCH 1/2] build: search for system-supplied libBlocksRuntime
5+
6+
This allows the user to provide a version of libBlocksRuntime on
7+
systems other than Darwin.
8+
9+
https://github.com/apple/swift-corelibs-libdispatch/pull/534
10+
---
11+
CMakeLists.txt | 2 ++
12+
cmake/modules/FindBlocksRuntime.cmake | 2 ++
13+
src/CMakeLists.txt | 3 +--
14+
3 files changed, 5 insertions(+), 2 deletions(-)
15+
16+
diff --git a/CMakeLists.txt b/CMakeLists.txt
17+
index 75c419c13..458c1cd95 100644
18+
--- a/CMakeLists.txt
19+
+++ b/CMakeLists.txt
20+
@@ -115,6 +115,8 @@ endif()
21+
22+
find_package(LibRT)
23+
24+
+find_package(BlocksRuntime QUIET)
25+
+
26+
check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT)
27+
check_function_exists(getprogname HAVE_GETPROGNAME)
28+
check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
29+
diff --git a/cmake/modules/FindBlocksRuntime.cmake b/cmake/modules/FindBlocksRuntime.cmake
30+
index 111a5d634..eb3f539e9 100644
31+
--- a/cmake/modules/FindBlocksRuntime.cmake
32+
+++ b/cmake/modules/FindBlocksRuntime.cmake
33+
@@ -45,4 +45,6 @@ if(BlocksRuntime_FOUND)
34+
INTERFACE_INCLUDE_DIRECTORIES
35+
${BlocksRuntime_INCLUDE_DIR})
36+
endif()
37+
+else()
38+
+ set(BlocksRuntime_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/BlocksRuntime")
39+
endif()
40+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
41+
index c88b430de..e2da3aaa8 100644
42+
--- a/src/CMakeLists.txt
43+
+++ b/src/CMakeLists.txt
44+
@@ -1,5 +1,4 @@
45+
-
46+
-if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
47+
+if(NOT BlocksRuntime_FOUND)
48+
add_subdirectory(BlocksRuntime)
49+
endif()
50+
51+
52+
From 18ef62595830ce69ccfc9353457e5efd1b64f54e Mon Sep 17 00:00:00 2001
53+
From: Niels Grewe <[email protected]>
54+
Date: Sun, 24 Nov 2019 21:54:36 +0100
55+
Subject: [PATCH 2/2] build: Remove a superfluous include path
56+
57+
---
58+
cmake/modules/FindBlocksRuntime.cmake | 2 --
59+
tests/CMakeLists.txt | 3 ---
60+
2 files changed, 5 deletions(-)
61+
62+
diff --git a/cmake/modules/FindBlocksRuntime.cmake b/cmake/modules/FindBlocksRuntime.cmake
63+
index eb3f539e9..111a5d634 100644
64+
--- a/cmake/modules/FindBlocksRuntime.cmake
65+
+++ b/cmake/modules/FindBlocksRuntime.cmake
66+
@@ -45,6 +45,4 @@ if(BlocksRuntime_FOUND)
67+
INTERFACE_INCLUDE_DIRECTORIES
68+
${BlocksRuntime_INCLUDE_DIR})
69+
endif()
70+
-else()
71+
- set(BlocksRuntime_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src/BlocksRuntime")
72+
endif()
73+
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
74+
index a27603559..0af5aac87 100644
75+
--- a/tests/CMakeLists.txt
76+
+++ b/tests/CMakeLists.txt
77+
@@ -78,9 +78,6 @@ function(add_unit_test name)
78+
# to reduce probability of test failures due to machine load.
79+
target_compile_options(${name} PRIVATE -DLENIENT_DEADLINES=1)
80+
endif()
81+
- target_include_directories(${name}
82+
- SYSTEM BEFORE PRIVATE
83+
- "${BlocksRuntime_INCLUDE_DIR}")
84+
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
85+
target_compile_options(${name} PRIVATE -Xclang -fblocks)
86+
target_compile_options(${name} PRIVATE /W3 -Wno-deprecated-declarations)

phases/18-libdispatch.bat

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ cd "%BUILD_DIR%" || exit /b 1
1818

1919
echo.
2020
echo ### Running cmake
21-
:: CXX and linker flags below are to produce PDBs for release builds
21+
:: CXX and linker flags below are to produce PDBs for release builds.
22+
:: BlocksRuntime parameters provided to use blocks runtime from libobjc2 with libdispatch-own-blocksruntime.patch.
2223
cmake .. %CMAKE_OPTIONS% ^
2324
-D BUILD_SHARED_LIBS=YES ^
2425
-D INSTALL_PRIVATE_HEADERS=YES ^
2526
-D CMAKE_CXX_FLAGS_RELWITHDEBINFO="/Zi" ^
2627
-D CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO="/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF" ^
28+
-D BlocksRuntime_INCLUDE_DIR=%INSTALL_PREFIX%\include ^
29+
-D BlocksRuntime_LIBRARIES=%INSTALL_PREFIX%\lib\objc.lib ^
2730
|| exit /b 1
2831

2932
echo.
@@ -34,10 +37,8 @@ echo.
3437
echo ### Installing
3538
ninja install || exit /b 1
3639

37-
:: Install PDB files
38-
xcopy /Y /F BlocksRuntime.pdb "%INSTALL_PREFIX%\lib\"
40+
:: Install PDB file
3941
xcopy /Y /F dispatch.pdb "%INSTALL_PREFIX%\lib\"
4042

41-
:: Move DLLs from bin to lib directory.
42-
move /Y "%INSTALL_PREFIX%\bin\BlocksRuntime.dll" "%INSTALL_PREFIX%\lib\"
43+
:: Move DLL from bin to lib directory.
4344
move /Y "%INSTALL_PREFIX%\bin\dispatch.dll" "%INSTALL_PREFIX%\lib\"

0 commit comments

Comments
 (0)