@@ -656,6 +656,10 @@ if run_vendor == 'apple':
656
656
config .target_codesign = "codesign -f -s -"
657
657
config .target_runtime = "objc"
658
658
659
+ config .available_features .add ('libdispatch' )
660
+ config .available_features .add ('foundation' )
661
+ config .available_features .add ('objc_interop' )
662
+
659
663
xcrun_prefix = (
660
664
"xcrun --toolchain %s --sdk %r" %
661
665
(config .darwin_xcrun_toolchain , config .variant_sdk ))
@@ -905,6 +909,21 @@ elif run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'wi
905
909
config .target_sdk_name = "linux"
906
910
config .target_runtime = "native"
907
911
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
912
+
913
+ libdispatch_build_dir = make_path (config .swift_obj_root , os .pardir ,
914
+ 'libdispatch%s' % config .variant_suffix , 'src' )
915
+ libdispatch_build_artifacts = [
916
+ make_path (libdispatch_build_dir , 'libdispatch.so' ),
917
+ make_path (libdispatch_build_dir , 'libswiftDispatch.so' ),
918
+ make_path (libdispatch_build_dir , 'swift' , 'Dispatch.swiftmodule' )]
919
+ if (all (os .path .exists (p ) for p in libdispatch_build_artifacts )):
920
+ config .available_features .add ('libdispatch' )
921
+ config .libdispatch_build_dir = libdispatch_build_dir
922
+ libdispatch_source_dir = make_path (config .swift_src_root , os .pardir , 'swift-corelibs-libdispatch' )
923
+ libdispatch_swift_module_dir = make_path (libdispatch_build_dir , 'swift' )
924
+ config .import_libdispatch = ('-I %s -I %s -L %s'
925
+ % (libdispatch_source_dir , libdispatch_swift_module_dir , libdispatch_build_dir ))
926
+
908
927
config .target_build_swift = (
909
928
'%s -target %s %s %s %s %s %s'
910
929
% (config .swiftc , config .variant_triple , resource_dir_opt , mcp_opt ,
@@ -1214,7 +1233,7 @@ runtime_libs = {
1214
1233
'fuzzer' : 'fuzzer_runtime'
1215
1234
}
1216
1235
1217
- if run_ptrsize != "32" :
1236
+ if run_ptrsize == '64' and 'libdispatch' in config . available_features :
1218
1237
runtime_libs ['tsan' ] = 'tsan_runtime'
1219
1238
1220
1239
check_runtime_libs (runtime_libs )
@@ -1312,14 +1331,15 @@ if os.path.exists(static_libswiftCore_path):
1312
1331
# default Swift tests to use the just-built libraries
1313
1332
target_stdlib_path = platform_module_dir
1314
1333
if not kIsWindows :
1334
+ libdispatch_path = getattr (config , 'libdispatch_build_dir' , '' )
1315
1335
if 'use_os_stdlib' not in lit_config .params :
1316
1336
lit_config .note ('Testing with the just-built libraries at ' + target_stdlib_path )
1317
1337
config .target_run = (
1318
1338
"/usr/bin/env "
1319
1339
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1320
- "LD_LIBRARY_PATH='{0}' " # Linux option
1340
+ "LD_LIBRARY_PATH='{0}:{1} ' " # Linux option
1321
1341
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1322
- .format (target_stdlib_path )) + config .target_run
1342
+ .format (target_stdlib_path , libdispatch_path )) + config .target_run
1323
1343
else :
1324
1344
os_stdlib_path = ''
1325
1345
if run_vendor == 'apple' :
@@ -1330,9 +1350,9 @@ if not kIsWindows:
1330
1350
config .target_run = (
1331
1351
"/usr/bin/env "
1332
1352
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1333
- "LD_LIBRARY_PATH='{0}' " # Linux option
1353
+ "LD_LIBRARY_PATH='{0}:{1} ' " # Linux option
1334
1354
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1335
- .format (all_stdlib_path )) + config .target_run
1355
+ .format (all_stdlib_path , libdispatch_path )) + config .target_run
1336
1356
1337
1357
if not getattr (config , 'target_run_simple_swift' , None ):
1338
1358
config .target_run_simple_swift_parameterized = \
@@ -1376,7 +1396,7 @@ if not getattr(config, 'target_run_simple_swift', None):
1376
1396
% (config .target_build_swift , mcp_opt , config .target_codesign , config .target_run ))
1377
1397
1378
1398
#
1379
- # When changing substitutions, update docs/Testing.rst .
1399
+ # When changing substitutions, update docs/Testing.md .
1380
1400
#
1381
1401
1382
1402
config .substitutions .append (('%target-runtime' , config .target_runtime ))
@@ -1498,6 +1518,7 @@ config.substitutions.append(('%FileCheck',
1498
1518
config .filecheck ,
1499
1519
'--enable-windows-compatibility' if kIsWindows else '' )))
1500
1520
config .substitutions .append (('%raw-FileCheck' , pipes .quote (config .filecheck )))
1521
+ config .substitutions .append (('%import-libdispatch' , getattr (config , 'import_libdispatch' , '' )))
1501
1522
1502
1523
if config .lldb_build_root != "" :
1503
1524
config .available_features .add ('lldb' )
@@ -1526,25 +1547,5 @@ if platform.system() == 'Linux':
1526
1547
config .available_features .add ("LinuxDistribution=" + distributor + '-' + release )
1527
1548
lit_config .note ('Running tests on %s-%s' % (distributor , release ))
1528
1549
1529
- if run_vendor == 'apple' :
1530
- config .available_features .add ('libdispatch' )
1531
- config .available_features .add ('foundation' )
1532
- config .available_features .add ('objc_interop' )
1533
- else :
1534
- # TODO(yln): Works with the packaged swift distribution, but not during build.
1535
- # We need to make libdispatch/foundation available in the test resource directory
1536
- # or pass along the proper library include paths in the compiler invocations that are used
1537
- # to build the tests.
1538
- def has_lib (name ):
1539
- return False
1540
-
1541
- if has_lib ('dispatch' ):
1542
- config .available_features .add ('libdispatch' )
1543
- else :
1544
- # TSan runtime requires libdispatch on non-Apple platforms
1545
- config .available_features .discard ('tsan_runtime' )
1546
-
1547
- if has_lib ('Foundation' ):
1548
- config .available_features .add ('foundation' )
1549
1550
1550
1551
lit_config .note ("Available features: " + ", " .join (sorted (config .available_features )))
0 commit comments