@@ -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,16 @@ 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
+ config .libdispatch_build_dir = make_path (config .swift_obj_root , os .pardir ,
914
+ 'libdispatch%s' % config .variant_suffix , 'src' )
915
+ if os .path .exists (config .libdispatch_build_dir ):
916
+ config .available_features .add ('libdispatch' )
917
+ source_dir = make_path (config .swift_src_root , os .pardir , 'swift-corelibs-libdispatch' )
918
+ swift_module_dir = make_path (config .libdispatch_build_dir , 'swift' )
919
+ config .import_libdispatch = ('-I %s -I %s -L %s'
920
+ % (source_dir , swift_module_dir , config .libdispatch_build_dir ))
921
+
908
922
config .target_build_swift = (
909
923
'%s -target %s %s %s %s %s %s'
910
924
% (config .swiftc , config .variant_triple , resource_dir_opt , mcp_opt ,
@@ -1214,7 +1228,7 @@ runtime_libs = {
1214
1228
'fuzzer' : 'fuzzer_runtime'
1215
1229
}
1216
1230
1217
- if run_ptrsize != "32" :
1231
+ if run_ptrsize != "32" and 'libdispatch' in config . available_features :
1218
1232
runtime_libs ['tsan' ] = 'tsan_runtime'
1219
1233
1220
1234
check_runtime_libs (runtime_libs )
@@ -1312,14 +1326,15 @@ if os.path.exists(static_libswiftCore_path):
1312
1326
# default Swift tests to use the just-built libraries
1313
1327
target_stdlib_path = platform_module_dir
1314
1328
if not kIsWindows :
1329
+ libdispatch_path = getattr (config , 'libdispatch_build_dir' , '' )
1315
1330
if 'use_os_stdlib' not in lit_config .params :
1316
1331
lit_config .note ('Testing with the just-built libraries at ' + target_stdlib_path )
1317
1332
config .target_run = (
1318
1333
"/usr/bin/env "
1319
1334
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1320
- "LD_LIBRARY_PATH='{0}' " # Linux option
1335
+ "LD_LIBRARY_PATH='{0}:{1} ' " # Linux option
1321
1336
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1322
- .format (target_stdlib_path )) + config .target_run
1337
+ .format (target_stdlib_path , libdispatch_path )) + config .target_run
1323
1338
else :
1324
1339
os_stdlib_path = ''
1325
1340
if run_vendor == 'apple' :
@@ -1330,9 +1345,9 @@ if not kIsWindows:
1330
1345
config .target_run = (
1331
1346
"/usr/bin/env "
1332
1347
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1333
- "LD_LIBRARY_PATH='{0}' " # Linux option
1348
+ "LD_LIBRARY_PATH='{0}:{1} ' " # Linux option
1334
1349
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1335
- .format (all_stdlib_path )) + config .target_run
1350
+ .format (all_stdlib_path , libdispatch_path )) + config .target_run
1336
1351
1337
1352
if not getattr (config , 'target_run_simple_swift' , None ):
1338
1353
config .target_run_simple_swift_parameterized = \
@@ -1376,7 +1391,7 @@ if not getattr(config, 'target_run_simple_swift', None):
1376
1391
% (config .target_build_swift , mcp_opt , config .target_codesign , config .target_run ))
1377
1392
1378
1393
#
1379
- # When changing substitutions, update docs/Testing.rst .
1394
+ # When changing substitutions, update docs/Testing.md .
1380
1395
#
1381
1396
1382
1397
config .substitutions .append (('%target-runtime' , config .target_runtime ))
@@ -1498,6 +1513,7 @@ config.substitutions.append(('%FileCheck',
1498
1513
config .filecheck ,
1499
1514
'--enable-windows-compatibility' if kIsWindows else '' )))
1500
1515
config .substitutions .append (('%raw-FileCheck' , pipes .quote (config .filecheck )))
1516
+ config .substitutions .append (('%import-libdispatch' , getattr (config , 'import_libdispatch' , '' )))
1501
1517
1502
1518
if config .lldb_build_root != "" :
1503
1519
config .available_features .add ('lldb' )
@@ -1526,25 +1542,5 @@ if platform.system() == 'Linux':
1526
1542
config .available_features .add ("LinuxDistribution=" + distributor + '-' + release )
1527
1543
lit_config .note ('Running tests on %s-%s' % (distributor , release ))
1528
1544
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
1545
1550
1546
lit_config .note ("Available features: " + ", " .join (sorted (config .available_features )))
0 commit comments