@@ -20,6 +20,16 @@ endfunction()
20
20
21
21
function (add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES )
22
22
set (RPATH_LIST )
23
+
24
+ # If we are linking in the Swift Swift parser, we at least need host tools
25
+ # to do it.
26
+ set (ASKD_BOOTSTRAPPING_MODE ${BOOTSTRAPPING_MODE} )
27
+ if (NOT ASKD_BOOTSTRAPPING_MODE )
28
+ if (SWIFT_SWIFT_PARSER )
29
+ set (ASKD_BOOTSTRAPPING_MODE HOSTTOOLS )
30
+ endif ()
31
+ endif ()
32
+
23
33
if (${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS )
24
34
25
35
# Lists of rpaths that we are going to add to our executables.
@@ -31,9 +41,9 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
31
41
# If we found a swift compiler and are going to use swift code in swift
32
42
# host side tools but link with clang, add the appropriate -L paths so we
33
43
# find all of the necessary swift libraries on Darwin.
34
- if (HAS_SWIFT_MODULES AND BOOTSTRAPPING_MODE )
44
+ if (HAS_SWIFT_MODULES AND ASKD_BOOTSTRAPPING_MODE )
35
45
36
- if (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
46
+ if (ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
37
47
# Add in the toolchain directory so we can grab compatibility libraries
38
48
get_filename_component (TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
39
49
get_filename_component (TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR} /../lib/swift/macosx" ABSOLUTE )
@@ -45,7 +55,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
45
55
# Include the abi stable system stdlib in our rpath.
46
56
list (APPEND RPATH_LIST "/usr/lib/swift" )
47
57
48
- elseif (BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS" )
58
+ elseif (ASKD_BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS" )
49
59
50
60
# Intentinally don't add the lib dir of the cross-compiled compiler, so that
51
61
# the stdlib is not picked up from there, but from the SDK.
@@ -59,7 +69,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
59
69
# Include the abi stable system stdlib in our rpath.
60
70
list (APPEND RPATH_LIST "/usr/lib/swift" )
61
71
62
- elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
72
+ elseif (ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
63
73
# Add the SDK directory for the host platform.
64
74
target_link_directories (${target} PRIVATE "${sdk_dir} " )
65
75
@@ -70,7 +80,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
70
80
# Include the abi stable system stdlib in our rpath.
71
81
list (APPEND RPATH_LIST "/usr/lib/swift" )
72
82
73
- elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
83
+ elseif (ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
74
84
# At build time link against the built swift libraries from the
75
85
# previous bootstrapping stage.
76
86
get_bootstrapping_swift_lib_dir (bs_lib_dir "" )
@@ -85,7 +95,7 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
85
95
file (RELATIVE_PATH relative_rtlib_path "${path} " "${SWIFTLIB_DIR} /${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
86
96
list (APPEND RPATH_LIST "@loader_path/${relative_rtlib_path} " )
87
97
else ()
88
- message (FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE } '" )
98
+ message (FATAL_ERROR "Unknown ASKD_BOOTSTRAPPING_MODE '${ASKD_BOOTSTRAPPING_MODE } '" )
89
99
endif ()
90
100
91
101
# Workaround to make lldb happy: we have to explicitly add all swift compiler modules
@@ -104,11 +114,11 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
104
114
set_property (TARGET ${target} APPEND_STRING PROPERTY
105
115
LINK_FLAGS " -lobjc " )
106
116
107
- endif () # HAS_SWIFT_MODULES AND BOOTSTRAPPING_MODE
117
+ endif () # HAS_SWIFT_MODULES AND ASKD_BOOTSTRAPPING_MODE
108
118
109
- elseif (SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD" AND HAS_SWIFT_MODULES AND BOOTSTRAPPING_MODE )
119
+ elseif (SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD" AND HAS_SWIFT_MODULES AND ASKD_BOOTSTRAPPING_MODE )
110
120
set (swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH} " )
111
- if (${BOOTSTRAPPING_MODE } MATCHES "HOSTTOOLS|CROSSCOMPILE" )
121
+ if (${ASKD_BOOTSTRAPPING_MODE } MATCHES "HOSTTOOLS|CROSSCOMPILE" )
112
122
# At build time and and run time, link against the swift libraries in the
113
123
# installed host toolchain.
114
124
get_filename_component (swift_bin_dir ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY )
@@ -119,14 +129,14 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
119
129
target_link_libraries (${target} PRIVATE "swiftCore" )
120
130
121
131
target_link_directories (${target} PRIVATE ${host_lib_dir} )
122
- if (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
132
+ if (ASKD_BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" )
123
133
list (APPEND RPATH_LIST "${host_lib_dir} " )
124
134
else ()
125
135
file (RELATIVE_PATH relative_rtlib_path "${path} " "${SWIFTLIB_DIR} /${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
126
136
list (APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path} " )
127
137
endif ()
128
138
129
- elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
139
+ elseif (ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING" )
130
140
get_bootstrapping_swift_lib_dir (bs_lib_dir "" )
131
141
target_link_directories (${target} PRIVATE ${bs_lib_dir} )
132
142
target_link_libraries (${target} PRIVATE ${swiftrt} )
@@ -137,10 +147,10 @@ function(add_sourcekitd_swifrt_linking target path HAS_SWIFT_MODULES)
137
147
file (RELATIVE_PATH relative_rtlib_path "${path} " "${SWIFTLIB_DIR} /${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK} _LIB_SUBDIR}" )
138
148
list (APPEND RPATH_LIST "$ORIGIN/${relative_rtlib_path} " )
139
149
140
- elseif (BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
141
- message (FATAL_ERROR "BOOTSTRAPPING_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux" )
150
+ elseif (ASKD_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS" )
151
+ message (FATAL_ERROR "ASKD_BOOTSTRAPPING_MODE 'BOOTSTRAPPING-WITH-HOSTLIBS' not supported on Linux" )
142
152
else ()
143
- message (FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${BOOTSTRAPPING_MODE } '" )
153
+ message (FATAL_ERROR "Unknown ASKD_BOOTSTRAPPING_MODE '${ASKD_BOOTSTRAPPING_MODE } '" )
144
154
endif ()
145
155
endif ()
146
156
set (RPATH_LIST ${RPATH_LIST} PARENT_SCOPE )
0 commit comments