@@ -728,6 +728,10 @@ if run_vendor == 'apple':
728
728
config .target_codesign = "codesign -f -s -"
729
729
config .target_runtime = "objc"
730
730
731
+ config .available_features .add ('libdispatch' )
732
+ config .available_features .add ('foundation' )
733
+ config .available_features .add ('objc_interop' )
734
+
731
735
xcrun_prefix = (
732
736
"xcrun --toolchain %s --sdk %r" %
733
737
(config .darwin_xcrun_toolchain , config .variant_sdk ))
@@ -986,6 +990,20 @@ elif run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'wi
986
990
config .target_sdk_name = "linux"
987
991
config .target_runtime = "native"
988
992
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
993
+
994
+ libdispatch_artifact_dir = make_path (config .libdispatch_build_path , 'src' )
995
+ libdispatch_artifacts = [
996
+ make_path (libdispatch_artifact_dir , 'libdispatch.so' ),
997
+ make_path (libdispatch_artifact_dir , 'libswiftDispatch.so' ),
998
+ make_path (libdispatch_artifact_dir , 'swift' , 'Dispatch.swiftmodule' )]
999
+ if (all (os .path .exists (p ) for p in libdispatch_artifacts )):
1000
+ config .available_features .add ('libdispatch' )
1001
+ config .libdispatch_artifact_dir = libdispatch_artifact_dir
1002
+ libdispatch_source_dir = make_path (config .swift_src_root , os .pardir , 'swift-corelibs-libdispatch' )
1003
+ libdispatch_swift_module_dir = make_path (libdispatch_artifact_dir , 'swift' )
1004
+ config .import_libdispatch = ('-I %s -I %s -L %s'
1005
+ % (libdispatch_source_dir , libdispatch_swift_module_dir , libdispatch_artifact_dir ))
1006
+
989
1007
config .target_build_swift = (
990
1008
'%s -target %s %s %s %s %s %s'
991
1009
% (config .swiftc , config .variant_triple , resource_dir_opt , mcp_opt ,
@@ -1302,7 +1320,7 @@ runtime_libs = {
1302
1320
'fuzzer' : 'fuzzer_runtime'
1303
1321
}
1304
1322
1305
- if run_ptrsize != "32" :
1323
+ if run_ptrsize == '64' and 'libdispatch' in config . available_features :
1306
1324
runtime_libs ['tsan' ] = 'tsan_runtime'
1307
1325
1308
1326
check_runtime_libs (runtime_libs )
@@ -1401,14 +1419,15 @@ if os.path.exists(static_libswiftCore_path):
1401
1419
# default Swift tests to use the just-built libraries
1402
1420
target_stdlib_path = platform_module_dir
1403
1421
if not kIsWindows :
1422
+ libdispatch_path = getattr (config , 'libdispatch_artifact_dir' , '' )
1404
1423
if 'use_os_stdlib' not in lit_config .params :
1405
1424
lit_config .note ('Testing with the just-built libraries at ' + target_stdlib_path )
1406
1425
config .target_run = (
1407
1426
"/usr/bin/env "
1408
1427
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1409
- "LD_LIBRARY_PATH='{0}' " # Linux option
1428
+ "LD_LIBRARY_PATH='{0}:{1} ' " # Linux option
1410
1429
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1411
- .format (target_stdlib_path )) + config .target_run
1430
+ .format (target_stdlib_path , libdispatch_path )) + config .target_run
1412
1431
else :
1413
1432
os_stdlib_path = ''
1414
1433
if run_vendor == 'apple' :
@@ -1419,9 +1438,9 @@ if not kIsWindows:
1419
1438
config .target_run = (
1420
1439
"/usr/bin/env "
1421
1440
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1422
- "LD_LIBRARY_PATH='{0}' " # Linux option
1441
+ "LD_LIBRARY_PATH='{0}:{1} ' " # Linux option
1423
1442
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1424
- .format (all_stdlib_path )) + config .target_run
1443
+ .format (all_stdlib_path , libdispatch_path )) + config .target_run
1425
1444
1426
1445
if not getattr (config , 'target_run_simple_swift' , None ):
1427
1446
config .target_run_simple_swift_parameterized = \
@@ -1465,7 +1484,7 @@ if not getattr(config, 'target_run_simple_swift', None):
1465
1484
% (config .target_build_swift , mcp_opt , config .target_codesign , config .target_run ))
1466
1485
1467
1486
#
1468
- # When changing substitutions, update docs/Testing.rst .
1487
+ # When changing substitutions, update docs/Testing.md .
1469
1488
#
1470
1489
1471
1490
config .substitutions .append (('%target-runtime' , config .target_runtime ))
@@ -1588,6 +1607,7 @@ config.substitutions.append(('%FileCheck',
1588
1607
config .filecheck ,
1589
1608
'--enable-windows-compatibility' if kIsWindows else '' )))
1590
1609
config .substitutions .append (('%raw-FileCheck' , pipes .quote (config .filecheck )))
1610
+ config .substitutions .append (('%import-libdispatch' , getattr (config , 'import_libdispatch' , '' )))
1591
1611
1592
1612
if config .lldb_build_root != "" :
1593
1613
config .available_features .add ('lldb' )
@@ -1616,25 +1636,5 @@ if platform.system() == 'Linux':
1616
1636
config .available_features .add ("LinuxDistribution=" + distributor + '-' + release )
1617
1637
lit_config .note ('Running tests on %s-%s' % (distributor , release ))
1618
1638
1619
- if run_vendor == 'apple' :
1620
- config .available_features .add ('libdispatch' )
1621
- config .available_features .add ('foundation' )
1622
- config .available_features .add ('objc_interop' )
1623
- else :
1624
- # TODO(yln): Works with the packaged swift distribution, but not during build.
1625
- # We need to make libdispatch/foundation available in the test resource directory
1626
- # or pass along the proper library include paths in the compiler invocations that are used
1627
- # to build the tests.
1628
- def has_lib (name ):
1629
- return False
1630
-
1631
- if has_lib ('dispatch' ):
1632
- config .available_features .add ('libdispatch' )
1633
- else :
1634
- # TSan runtime requires libdispatch on non-Apple platforms
1635
- config .available_features .discard ('tsan_runtime' )
1636
-
1637
- if has_lib ('Foundation' ):
1638
- config .available_features .add ('foundation' )
1639
1639
1640
1640
lit_config .note ("Available features: " + ", " .join (sorted (config .available_features )))
0 commit comments