@@ -116,6 +116,20 @@ def delete_rpath(rpath, binary, verbose):
116
116
if verbose :
117
117
print (stdout )
118
118
119
+ def add_rpath (rpath , binary , verbose ):
120
+ cmd = ['install_name_tool' , '-add_rpath' , rpath , binary ]
121
+ if verbose :
122
+ print (' ' .join (cmd ))
123
+ installToolProcess = subprocess .Popen (cmd ,
124
+ stdout = subprocess .PIPE ,
125
+ stderr = subprocess .PIPE )
126
+ stdout , stderr = installToolProcess .communicate ()
127
+ if installToolProcess .returncode != 0 :
128
+ print ('install_name_tool command failed: ' )
129
+ print (stderr )
130
+ if verbose :
131
+ print (stdout )
132
+
119
133
def should_test_parallel ():
120
134
if platform .system () == 'Linux' :
121
135
distro = platform .linux_distribution ()
@@ -209,18 +223,23 @@ def install_executables(args, build_dir, universal_bin_dir, toolchain_bin_dir):
209
223
# Fixup rpaths
210
224
for arch in macos_target_architectures :
211
225
exe_bin_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
212
- 'swift-driver' , 'bin' , exe )
213
- help_bin_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
214
- 'swift-driver' , 'bin' , 'swift-help' )
226
+ 'swift-driver' , 'bin' , exe )
215
227
driver_lib_dir_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
216
228
'swift-driver' , 'lib' )
229
+ tsc_lib_dir_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
230
+ 'swift-tools-support-core' , 'lib' )
217
231
delete_rpath (driver_lib_dir_path , exe_bin_path , args .verbose )
218
- # Only swift-driver requires libllbuild
232
+ delete_rpath (tsc_lib_dir_path , exe_bin_path , args .verbose )
233
+
234
+ # Only swift-driver relies libllbuild
219
235
if exe == 'swift-driver' :
220
236
llbuild_lib_dir_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
221
237
'llbuild' , 'lib' )
222
238
delete_rpath (llbuild_lib_dir_path , exe_bin_path , args .verbose )
223
239
240
+ # Point to the installed toolchain's lib
241
+ add_rpath ('@executable_path/../lib/swift/macosx' , exe_bin_path , args .verbose )
242
+
224
243
# Merge the multiple architecture binaries into a universal binary and install
225
244
output_bin_path = os .path .join (universal_bin_dir , exe )
226
245
lipo_cmd = ['lipo' ]
@@ -234,7 +253,7 @@ def install_executables(args, build_dir, universal_bin_dir, toolchain_bin_dir):
234
253
install_binary (exe , universal_bin_dir , toolchain_bin_dir , args .verbose )
235
254
236
255
def install_libraries (args , build_dir , universal_lib_dir , toolchain_lib_dir ):
237
- # Fixup the rpath for libSwiftDriver (libSwiftOptions does not link against these libraries)
256
+ # Fixup the llbuild and swift-driver rpath for libSwiftDriver
238
257
for arch in macos_target_architectures :
239
258
lib_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
240
259
'swift-driver' , 'lib' , 'libSwiftDriver' + shared_lib_ext )
@@ -245,18 +264,54 @@ def install_libraries(args, build_dir, universal_lib_dir, toolchain_lib_dir):
245
264
delete_rpath (driver_lib_dir_path , lib_path , args .verbose )
246
265
delete_rpath (llbuild_lib_dir_path , lib_path , args .verbose )
247
266
267
+ toolchain_relative_llbuild_rpath = os .path .join ()
268
+ add_rpath ('@executable_path/../lib/swift/macosx' , exe_bin_path , args .verbose )
269
+
270
+ # Fixup the TSC rpath for libSwiftDriver and libSwiftOptions
271
+ for lib in ['libSwiftDriver' , 'libSwiftOptions' ]:
272
+ for arch in macos_target_architectures :
273
+ lib_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
274
+ 'swift-driver' , 'lib' , lib + shared_lib_ext )
275
+ tsc_lib_dir_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
276
+ 'swift-tools-support-core' , 'lib' )
277
+ delete_rpath (tsc_lib_dir_path , lib_path , args .verbose )
278
+
248
279
# Install the libSwiftDriver and libSwiftOptions shared libraries into the toolchain lib
249
280
for lib in ['libSwiftDriver' , 'libSwiftOptions' ]:
250
- dylib_file = lib + shared_lib_ext
251
- output_dylib_path = os .path .join (universal_lib_dir , dylib_file )
281
+ shared_lib_file = lib + shared_lib_ext
282
+ output_dylib_path = os .path .join (universal_lib_dir , shared_lib_file )
252
283
lipo_cmd = ['lipo' ]
253
284
for arch in macos_target_architectures :
254
285
input_lib_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
255
- 'swift-driver' , 'lib' , dylib_file )
286
+ 'swift-driver' , 'lib' , shared_lib_file )
256
287
lipo_cmd .append (input_lib_path )
257
288
lipo_cmd .extend (['-create' , '-output' , output_dylib_path ])
258
289
subprocess .check_call (lipo_cmd )
259
- install_binary (dylib_file , universal_lib_dir , toolchain_lib_dir , args .verbose )
290
+ install_binary (shared_lib_file , universal_lib_dir , toolchain_lib_dir , args .verbose )
291
+
292
+ for lib in ['libTSCBasic' , 'libTSCLibc' , 'libTSCUtility' ]:
293
+ shared_lib_file = lib + shared_lib_ext
294
+ output_dylib_path = os .path .join (universal_lib_dir , shared_lib_file )
295
+ lipo_cmd = ['lipo' ]
296
+ for arch in macos_target_architectures :
297
+ input_lib_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
298
+ 'swift-tools-support-core' , 'lib' , shared_lib_file )
299
+ lipo_cmd .append (input_lib_path )
300
+ lipo_cmd .extend (['-create' , '-output' , output_dylib_path ])
301
+ subprocess .check_call (lipo_cmd )
302
+ install_binary (shared_lib_file , universal_lib_dir , toolchain_lib_dir , args .verbose )
303
+
304
+ def install_library (args , lib_name , ):
305
+ shared_lib_file = lib + shared_lib_ext
306
+ output_dylib_path = os .path .join (universal_lib_dir , shared_lib_file )
307
+ lipo_cmd = ['lipo' ]
308
+ for arch in macos_target_architectures :
309
+ input_lib_path = os .path .join (build_dir , arch + '-apple-macos' + macos_deployment_target ,
310
+ 'swift-driver' , 'lib' , shared_lib_file )
311
+ lipo_cmd .append (input_lib_path )
312
+ lipo_cmd .extend (['-create' , '-output' , output_dylib_path ])
313
+ subprocess .check_call (lipo_cmd )
314
+ install_binary (shared_lib_file , universal_lib_dir , toolchain_lib_dir , args .verbose )
260
315
261
316
def install_binary_swift_modules (args , build_dir , toolchain_lib_dir ):
262
317
# The common subpath from a project's build directory to where its build products are found
@@ -363,8 +418,7 @@ def build_tsc_using_cmake(args, target, swiftc_exec, cmake_target_dir, base_cmak
363
418
print ('Building TSC for target: %s' % target )
364
419
tsc_source_dir = os .path .join (os .path .dirname (args .package_path ), 'swift-tools-support-core' )
365
420
tsc_build_dir = os .path .join (cmake_target_dir , 'swift-tools-support-core' )
366
- tsc_flags = base_cmake_flags + ['-DBUILD_SHARED_LIBS=OFF' ]
367
- cmake_build (args , swiftc_exec , tsc_flags , tsc_source_dir , tsc_build_dir )
421
+ cmake_build (args , swiftc_exec , base_cmake_flags , tsc_source_dir , tsc_build_dir )
368
422
369
423
def build_yams_using_cmake (args , target , swiftc_exec , cmake_target_dir , base_cmake_flags ):
370
424
print ('Building Yams for target: %s' % target )
0 commit comments