Skip to content

Commit e109cb8

Browse files
briancroomjpsim
authored andcommitted
[SourceKit] Add libdispatch as a dependency for some SourceKit products
sourcekitdInProc, sourcekitd-test, and complete-test need to be explicitly linked with libdispatch on Linux to build properly.
1 parent 3b378f7 commit e109cb8

File tree

6 files changed

+28
-6
lines changed

6 files changed

+28
-6
lines changed

tools/SourceKit/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,5 +506,15 @@ include_directories(BEFORE
506506
${SOURCEKIT_SOURCE_DIR}/include
507507
)
508508

509+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
510+
include_directories(AFTER ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
511+
512+
add_library(dispatch SHARED IMPORTED)
513+
set_target_properties(dispatch PROPERTIES
514+
IMPORTED_LOCATION ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so)
515+
516+
set(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH TRUE)
517+
endif()
518+
509519
add_subdirectory(lib)
510520
add_subdirectory(tools)

tools/SourceKit/lib/Support/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ set(SourceKitSupport_sources
77
UIDRegistry.cpp
88
)
99

10-
set(SourceKitSupport_Darwin_sources
11-
Concurrency-Mac.cpp)
12-
set(LLVM_OPTIONAL_SOURCES ${SourceKitSupport_Darwin_sources})
13-
if(APPLE)
14-
list(APPEND SourceKitSupport_sources ${SourceKitSupport_Darwin_sources})
10+
set(SOURCEKIT_SUPPORT_DEPEND swiftBasic clangBasic clangRewrite)
11+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
12+
list(APPEND SOURCEKIT_SUPPORT_DEPEND dispatch BlocksRuntime)
1513
endif()
1614

1715
add_sourcekit_library(SourceKitSupport
1816
${SourceKitSupport_sources}
19-
DEPENDS swiftBasic clangBasic clangRewrite
17+
DEPENDS ${SOURCEKIT_SUPPORT_DEPEND}
2018
)

tools/SourceKit/tools/complete-test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ else()
44
set(SOURCEKITD_TEST_DEPEND sourcekitd)
55
endif()
66

7+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
8+
set(SOURCEKITD_TEST_DEPEND ${SOURCEKITD_TEST_DEPEND} dispatch)
9+
endif()
10+
711
add_sourcekit_executable(complete-test
812
complete-test.cpp
913
DEPENDS ${SOURCEKITD_TEST_DEPEND}

tools/SourceKit/tools/sourcekitd-test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ else()
88
set(SOURCEKITD_TEST_DEPEND sourcekitd)
99
endif()
1010

11+
if(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH)
12+
set(SOURCEKITD_TEST_DEPEND ${SOURCEKITD_TEST_DEPEND} dispatch)
13+
endif()
14+
1115
add_sourcekit_executable(sourcekitd-test
1216
sourcekitd-test.cpp
1317
TestOptions.cpp

tools/SourceKit/tools/sourcekitd/bin/InProc/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ else()
2323
)
2424
endif()
2525

26+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
27+
target_link_libraries(sourcekitdInProc PUBLIC BlocksRuntime)
28+
endif()
29+
2630
if (SOURCEKIT_BUILT_STANDALONE)
2731
# Create the symlinks necessary to find the swift runtime.
2832
add_custom_command(TARGET sourcekitdInProc PRE_BUILD

utils/build-script-impl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,8 @@ for host in "${ALL_HOSTS[@]}"; do
19871987
-DSWIFT_PATH_TO_LLVM_BUILD:PATH="${llvm_build_dir}"
19881988
-DSWIFT_PATH_TO_CMARK_SOURCE:PATH="${CMARK_SOURCE_DIR}"
19891989
-DSWIFT_PATH_TO_CMARK_BUILD:PATH="$(build_directory ${host} cmark)"
1990+
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH="${LIBDISPATCH_SOURCE_DIR}"
1991+
-DSWIFT_PATH_TO_LIBDISPATCH_BUILD:PATH="$(build_directory ${host} libdispatch)"
19901992
)
19911993

19921994
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then

0 commit comments

Comments
 (0)