File tree Expand file tree Collapse file tree 5 files changed +19
-28
lines changed
tools/SourceKit/cmake/modules Expand file tree Collapse file tree 5 files changed +19
-28
lines changed Original file line number Diff line number Diff line change @@ -1387,9 +1387,6 @@ if(SWIFT_INCLUDE_TOOLS)
1387
1387
1388
1388
add_subdirectory (lib )
1389
1389
1390
- # SwiftCompilerSources must come before "tools".
1391
- # It adds swift module names to the global property "swift_compiler_modules"
1392
- # which is used in add_swift_host_tool for the lldb workaround.
1393
1390
add_subdirectory (SwiftCompilerSources )
1394
1391
1395
1392
# Always include this after including stdlib/!
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ function(add_swift_compiler_modules_library name)
157
157
158
158
set (all_obj_files )
159
159
set (all_module_targets )
160
+ set (all_module_files )
160
161
get_property (modules GLOBAL PROPERTY "swift_compiler_modules" )
161
162
foreach (module ${modules} )
162
163
@@ -180,7 +181,7 @@ function(add_swift_compiler_modules_library name)
180
181
181
182
set (module_obj_file "${build_dir} /${module} .o" )
182
183
set (module_file "${build_dir} /${module} .swiftmodule" )
183
- set_property ( TARGET ${module_target} PROPERTY "module_file" " ${module_file} " )
184
+ list ( APPEND all_module_files ${module_file} )
184
185
185
186
set (all_obj_files ${all_obj_files} ${module_obj_file} )
186
187
set (c_include_paths
@@ -231,6 +232,14 @@ function(add_swift_compiler_modules_library name)
231
232
add_library (${name} STATIC ${all_obj_files} )
232
233
add_dependencies (${name} ${all_module_targets} )
233
234
set_target_properties (${name} PROPERTIES LINKER_LANGUAGE CXX )
235
+
236
+ # Downstream linking should include the swiftmodules to allow lldb to work correctly.
237
+ set (public_link_flags )
238
+ foreach (module_file ${all_module_files} )
239
+ list (APPEND public_link_flags "SHELL:-Xlinker -add_ast_path -Xlinker ${module_file} " )
240
+ endforeach ()
241
+ target_link_options (${name} PUBLIC ${public_link_flags} )
242
+
234
243
set_property (GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${name} )
235
244
endfunction ()
236
245
Original file line number Diff line number Diff line change @@ -229,8 +229,17 @@ function(add_pure_swift_host_library name)
229
229
-emit-module-source-info-path;${module_sourceinfo_file};
230
230
-emit-module-interface-path;${module_interface_file}
231
231
> )
232
+ else ()
233
+ # Emit a swiftmodule in the current directory.
234
+ set_target_properties (${name} PROPERTIES
235
+ Swift_MODULE_NAME ${name}
236
+ Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
237
+ set (module_file "${CMAKE_CURRENT_BINARY_DIR} /${name} .swiftmodule" )
232
238
endif ()
233
239
240
+ # Downstream linking should include the swiftmodule to allow lldb to work correctly.
241
+ target_link_options (${name} PUBLIC "SHELL:-Xlinker -add_ast_path -Xlinker ${module_file} " )
242
+
234
243
if (LLVM_USE_LINKER )
235
244
target_link_options (${name} PRIVATE
236
245
"-use-ld=${LLVM_USE_LINKER} "
Original file line number Diff line number Diff line change @@ -522,18 +522,6 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
522
522
message(FATAL_ERROR " Unknown BOOTSTRAPPING_MODE '${ASRLF_BOOTSTRAPPING_MODE}' ")
523
523
endif()
524
524
525
- # Workaround to make lldb happy: we have to explicitly add all swift compiler modules
526
- # to the linker command line.
527
- set(swift_ast_path_flags " -Wl ")
528
- get_property(modules GLOBAL PROPERTY swift_compiler_modules)
529
- foreach(module ${modules} )
530
- get_target_property(module_file " SwiftModule${module} " " module_file ")
531
- string(APPEND swift_ast_path_flags " ,-add_ast_path,${module_file} ")
532
- endforeach()
533
-
534
- set_property(TARGET ${target} APPEND_STRING PROPERTY
535
- LINK_FLAGS ${swift_ast_path_flags} )
536
-
537
525
# Workaround for a linker crash related to autolinking: rdar://77839981
538
526
set_property(TARGET ${target} APPEND_STRING PROPERTY
539
527
LINK_FLAGS " -lobjc ")
Original file line number Diff line number Diff line change @@ -98,18 +98,6 @@ function(add_sourcekit_swift_runtime_link_flags target path HAS_SWIFT_MODULES)
98
98
message (FATAL_ERROR "Unknown ASKD_BOOTSTRAPPING_MODE '${ASKD_BOOTSTRAPPING_MODE} '" )
99
99
endif ()
100
100
101
- # Workaround to make lldb happy: we have to explicitly add all swift compiler modules
102
- # to the linker command line.
103
- set (swift_ast_path_flags "-Wl" )
104
- get_property (modules GLOBAL PROPERTY swift_compiler_modules )
105
- foreach (module ${modules} )
106
- get_target_property (module_file "SwiftModule${module} " "module_file" )
107
- string (APPEND swift_ast_path_flags ",-add_ast_path,${module_file} " )
108
- endforeach ()
109
-
110
- set_property (TARGET ${target} APPEND_STRING PROPERTY
111
- LINK_FLAGS " ${swift_ast_path_flags} " )
112
-
113
101
# Workaround for a linker crash related to autolinking: rdar://77839981
114
102
set_property (TARGET ${target} APPEND_STRING PROPERTY
115
103
LINK_FLAGS " -lobjc " )
You can’t perform that action at this time.
0 commit comments