Skip to content

Commit d3f7215

Browse files
authored
Merge pull request #29399 from compnerd/sk-rpath
build: move the RPATH handling to the executables
2 parents 9d8d013 + bc21d4f commit d3f7215

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,6 @@ macro(add_sourcekit_executable name)
240240
target_link_libraries(${name} PRIVATE ${LLVM_COMMON_LIBS})
241241

242242
set_target_properties(${name} PROPERTIES FOLDER "SourceKit executables")
243-
if (NOT SWIFT_ASAN_BUILD)
244-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
245-
set_target_properties(${name}
246-
PROPERTIES
247-
LINK_FLAGS "-Wl,-exported_symbol,_main")
248-
endif()
249-
if(SWIFT_ANALYZE_CODE_COVERAGE)
250-
set_property(TARGET "${name}" APPEND_STRING PROPERTY
251-
LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
252-
endif()
253-
endif()
254243
add_sourcekit_default_compiler_flags("${name}")
255244
endmacro()
256245

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
1313
BlocksRuntime)
1414
endif()
1515

16-
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
17-
set_target_properties(complete-test
18-
PROPERTIES
19-
LINK_FLAGS "-Wl,-rpath -Wl,@executable_path/../lib")
16+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
17+
set_target_properties(complete-test PROPERTIES
18+
INSTALL_RPATH "@executable_path/../lib")
19+
target_link_options(complete-test PRIVATE
20+
"LINKER:-exported_symbol,_main")
2021
endif()
21-
2222
if(SWIFT_ANALYZE_CODE_COVERAGE)
2323
set_property(TARGET complete-test APPEND_STRING PROPERTY
2424
LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
2525
endif()
2626

2727
add_dependencies(tools complete-test)
2828
swift_install_in_component(TARGETS complete-test
29-
RUNTIME
30-
DESTINATION bin
31-
COMPONENT tools)
29+
RUNTIME DESTINATION bin COMPONENT tools)

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ endif()
1515
target_link_libraries(sourcekitd-repl PRIVATE
1616
libedit)
1717

18-
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
19-
set_target_properties(sourcekitd-repl
20-
PROPERTIES
21-
LINK_FLAGS "-Wl,-rpath -Wl,@executable_path/../lib")
18+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
19+
set_target_properties(sourcekitd-repl PROPERTIES
20+
INSTALL_RPATH "@executable_path/../lib")
21+
target_link_options(sourcekitd-repl PRIVATE
22+
"LINKER:-exported_symbol,_main")
2223
endif()
2324
if(SWIFT_ANALYZE_CODE_COVERAGE)
2425
set_property(TARGET sourcekitd-repl APPEND_STRING PROPERTY
@@ -27,6 +28,4 @@ endif()
2728

2829
add_dependencies(tools sourcekitd-repl)
2930
swift_install_in_component(TARGETS sourcekitd-repl
30-
RUNTIME
31-
DESTINATION bin
32-
COMPONENT tools)
31+
RUNTIME DESTINATION bin COMPONENT tools)

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,17 @@ endif()
2525

2626
add_dependencies(sourcekitd-test sourcekitdTestOptionsTableGen)
2727

28-
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
29-
set_target_properties(sourcekitd-test
30-
PROPERTIES
31-
LINK_FLAGS "-Wl,-rpath -Wl,@executable_path/../lib")
28+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
29+
set_target_properties(sourcekitd-test PROPERTIES
30+
INSTALL_RPATH "@executable_path/../lib")
31+
target_link_options(sourcekitd-test PRIVATE
32+
"LINKER:-exported_symbol,_main")
3233
endif()
33-
3434
if(SWIFT_ANALYZE_CODE_COVERAGE)
3535
set_property(TARGET sourcekitd-test APPEND_STRING PROPERTY
3636
LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
3737
endif()
3838

3939
add_dependencies(tools sourcekitd-test)
4040
swift_install_in_component(TARGETS sourcekitd-test
41-
RUNTIME
42-
DESTINATION bin
43-
COMPONENT tools)
41+
RUNTIME DESTINATION bin COMPONENT tools)

0 commit comments

Comments
 (0)