@@ -940,6 +940,7 @@ config.target_cxx_lib = '-lc++'
940
940
config .target_msvc_runtime_opt = ''
941
941
config .target_static_library_prefix = 'lib'
942
942
config .target_static_library_suffix = '.a'
943
+ config .target_env_prefix = ''
943
944
944
945
if run_vendor == 'apple' :
945
946
target_specific_module_triple = '{}-apple-{}' .format (
@@ -954,6 +955,7 @@ if run_vendor == 'apple':
954
955
config .target_codesign = make_path (config .swift_utils , "swift-darwin-postprocess.py" )
955
956
else :
956
957
config .target_codesign = "codesign -f -s -"
958
+ config .target_library_path_var = "DYLD_LIBRARY_PATH"
957
959
config .target_runtime = "objc"
958
960
959
961
config .available_features .add ('libdispatch' )
@@ -1080,6 +1082,8 @@ if run_vendor == 'apple':
1080
1082
xcrun_sdk_name = "watchos"
1081
1083
target_future_version = "9.99.0"
1082
1084
1085
+ config .target_env_prefix = 'IOS_CHILD_'
1086
+
1083
1087
config .target_cc_options = (
1084
1088
"-target %s %s" %
1085
1089
(config .variant_triple , clang_mcp_opt ))
@@ -1122,6 +1126,8 @@ if run_vendor == 'apple':
1122
1126
1123
1127
target_specific_module_triple += "-simulator"
1124
1128
1129
+ config .target_env_prefix = 'SIMCTL_CHILD_'
1130
+
1125
1131
config .target_cc_options = (
1126
1132
"-target %s %s" %
1127
1133
(config .variant_triple , clang_mcp_opt ))
@@ -1330,6 +1336,7 @@ elif run_os in ['windows-msvc']:
1330
1336
config .target_msvc_runtime_opt = '-%s -D_MT' % config .swift_stdlib_msvc_runtime
1331
1337
if 'D' in config .swift_stdlib_msvc_runtime :
1332
1338
config .target_msvc_runtime_opt += ' -D_DLL'
1339
+ config .target_env_prefix = ''
1333
1340
1334
1341
config .target_build_swift = \
1335
1342
('%r -target %s %s %s %s %s -libc %s' % \
@@ -1439,13 +1446,15 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
1439
1446
config .target_shared_library_suffix = ".so"
1440
1447
config .target_sdk_name = "android"
1441
1448
config .target_cc_options = "-fPIE"
1449
+ config .target_env_prefix = 'ANDROID_CHILD_'
1442
1450
else :
1443
1451
lit_config .note ("Testing Linux " + config .variant_triple )
1444
1452
config .target_object_format = "elf"
1445
1453
config .target_shared_library_prefix = 'lib'
1446
1454
config .target_shared_library_suffix = ".so"
1447
1455
config .target_sdk_name = "linux"
1448
1456
config .target_cc_options = "-fPIE"
1457
+ config .target_library_path_var = "LD_LIBRARY_PATH"
1449
1458
config .target_runtime = "native"
1450
1459
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
1451
1460
@@ -1572,6 +1581,8 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
1572
1581
config .target_runtime = "native"
1573
1582
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
1574
1583
config .target_sdk_name = "android"
1584
+ config .target_library_path_var = "LD_LIBRARY_PATH"
1585
+ config .target_env_prefix = 'ANDROID_CHILD_'
1575
1586
config .resource_dir_opt = ("-resource-dir %s" % test_resource_dir )
1576
1587
# Since NDK r19, the headers and libraries are available in a unified
1577
1588
# sysroot at $NDK_PATH/toolchains/llvm/prebuilt/$prebuilt_directory/sysroot,
@@ -1775,19 +1786,6 @@ config.substitutions.append(('%string_processing_module', string_processing_modu
1775
1786
config .substitutions .append (('%/string_processing_module' ,
1776
1787
'/' .join (os .path .normpath (string_processing_module ).split (os .sep ))))
1777
1788
1778
- # Different OS's require different prefixes for the environment variables to be
1779
- # propagated to the calling contexts.
1780
- # In order to make tests OS-agnostic, names of environment variables should be
1781
- # prefixed with `%env-`, which is then expanded to the appropriate prefix.
1782
- SIMULATOR_ENV_PREFIX = 'SIMCTL_CHILD_'
1783
- ENV_VAR_PREFIXES = {
1784
- 'iphonesimulator' : SIMULATOR_ENV_PREFIX ,
1785
- 'watchsimulator' : SIMULATOR_ENV_PREFIX ,
1786
- 'appletvsimulator' : SIMULATOR_ENV_PREFIX ,
1787
- 'android' : 'ANDROID_CHILD_'
1788
- }
1789
- TARGET_ENV_PREFIX = ENV_VAR_PREFIXES .get (config .target_sdk_name , "" ) if not kIsAndroid else ""
1790
-
1791
1789
back_deployment_runtime = lit_config .params .get ('back_deployment_runtime' , None )
1792
1790
if back_deployment_runtime is not None :
1793
1791
config .available_features .add ('back_deployment_runtime' )
@@ -1797,24 +1795,51 @@ if run_vendor == 'apple':
1797
1795
if 'back_deploy_concurrency' in config .available_features :
1798
1796
concurrency_back_deploy_path = os .path .join (os .path .dirname (swift_obj_root ), os .path .basename (swift_obj_root ).replace ("swift-" , "backdeployconcurrency-" ), 'lib' , 'swift-5.5' , run_os )
1799
1797
1800
- if 'remote_run_host' in lit_config .params :
1798
+ def os_stdlib_paths ():
1799
+ if run_vendor == 'apple' :
1800
+ if run_os == 'maccatalyst' :
1801
+ return ["/System/iOSSupport/usr/lib/swift" , "/usr/lib/swift" ]
1802
+ else :
1803
+ return ["/usr/lib/swift" ]
1804
+ else :
1805
+ lit_config .fatal ("Unsupported platform for os_stdlib_paths" )
1806
+
1807
+ # This returns a shell variable assignment of the form <LIBRARY_PATH>=<VALUE>
1808
+ # where <LIBRARY_PATH> is whatever environment variable we need to set to
1809
+ # override dynamic library locations. (Usually DYLD_LIBRARY_PATH or
1810
+ # LD_LIBRARY_PATH, sometimes prefixed by a special annotation to tunnel the
1811
+ # setting through a helper tool.)
1812
+ #
1813
+ # The return value is designed to be passed to `/usr/bin/env` when executing a
1814
+ # binary on the test target.
1815
+ #
1816
+ # The single parameter is an array of directory paths that hold the libraries.
1817
+ def construct_library_path_env (dirs ):
1818
+ return "{0}{1}='{2}' " .format (
1819
+ config .target_env_prefix ,
1820
+ config .target_library_path_var ,
1821
+ os .path .pathsep .join (dirs ))
1822
+
1823
+ def configure_remote_run ():
1801
1824
if 'remote_run_tmpdir' not in lit_config .params :
1802
1825
lit_config .fatal ("'remote_run_host' provided, but no "
1803
1826
"'remote_run_tmpdir'" )
1804
1827
1805
1828
remote_run_host = lit_config .params ['remote_run_host' ]
1806
1829
remote_tmp_dir = lit_config .params ['remote_run_tmpdir' ]
1807
1830
remote_lib_dir = os .path .join (remote_tmp_dir , 'stdlib' )
1808
- remote_run_lib_path = ''
1809
- if 'use_os_stdlib' not in lit_config .params :
1810
- remote_run_lib_path = remote_lib_dir
1811
- else :
1831
+ remote_run_lib_path = [remote_lib_dir ]
1832
+ if 'use_os_stdlib' in lit_config .params :
1812
1833
config .available_features .add ('use_os_stdlib' )
1813
- os_stdlib_path = ''
1814
- if run_vendor == 'apple' :
1815
- #If we get swift-in-the-OS for non-Apple platforms, add a condition here
1816
- os_stdlib_path = "/usr/lib/swift"
1817
- remote_run_lib_path = os .path .pathsep .join ((os_stdlib_path , remote_lib_dir ))
1834
+ remote_run_lib_path = os_stdlib_paths () + [remote_lib_dir ]
1835
+ lit_config .note ('Remote testing with the standard libraries in the OS' )
1836
+ elif 'back_deployment_runtime' in lit_config .params :
1837
+ lit_config .note ('Remote testing with back deployment libraries' )
1838
+ else :
1839
+ lit_config .note ('Remote testing with the just-built libraries' )
1840
+
1841
+ lit_config .note (
1842
+ 'Remote library load path: {0}' .format (os .path .pathsep .join (remote_run_lib_path )))
1818
1843
1819
1844
remote_run_extra_args_param = lit_config .params .get ('remote_run_extra_args' )
1820
1845
remote_run_extra_args = shlex .split (remote_run_extra_args_param or '' )
@@ -1861,23 +1886,38 @@ if 'remote_run_host' in lit_config.params:
1861
1886
os .path .dirname (local_swift_reflection_test ),
1862
1887
'bin/' )
1863
1888
1889
+ print ("Contents of {0} on {1} after upload:" .format (
1890
+ remote_lib_dir , remote_run_host ))
1891
+ subprocess .check_call (
1892
+ [
1893
+ os .path .join (config .swift_utils , 'remote-run' ),
1894
+ '--remote-dir' , remote_tmp_dir ,
1895
+ ] + remote_run_extra_args + [
1896
+ remote_run_host ,
1897
+ '--' ,
1898
+ 'ls' , '-l' , remote_lib_dir
1899
+ ])
1900
+
1901
+ config .target_env_prefix = 'REMOTE_RUN_CHILD_'
1864
1902
config .target_run = (
1865
- "/usr/bin/env "
1866
- "REMOTE_RUN_CHILD_DYLD_LIBRARY_PATH='{0}' " # Apple option
1867
- "REMOTE_RUN_CHILD_LD_LIBRARY_PATH='{0}' " # Linux option
1868
- "'{1}'/remote-run --input-prefix '{2}' --output-prefix %t "
1869
- "--remote-dir '{3}'%t {4} {5}" .format (remote_run_lib_path ,
1870
- config .swift_utils ,
1871
- config .swift_src_root ,
1872
- remote_tmp_dir ,
1873
- ' ' .join (remote_run_extra_args ),
1874
- remote_run_host ))
1903
+ "/usr/bin/env " +
1904
+ construct_library_path_env (remote_run_lib_path ) +
1905
+ "'{0}'/remote-run " .format (config .swift_utils ) +
1906
+ "--input-prefix '{0}' " .format (config .src_root ) +
1907
+ "--output-prefix %t " +
1908
+ "--remote-dir '{0}'%t " .format (remote_tmp_dir ) +
1909
+ "{0} " .format (' ' .join (remote_run_extra_args )) +
1910
+ "{0}" .format (remote_run_host ))
1875
1911
config .target_swift_reflection_test = os .path .join (
1876
1912
remote_tmp_dir , 'bin' , swift_reflection_test_name )
1877
- TARGET_ENV_PREFIX = 'REMOTE_RUN_CHILD_'
1878
1913
config .available_features .add ('remote_run' )
1879
1914
1880
- config .substitutions .append (('%env-' , TARGET_ENV_PREFIX ))
1915
+ # Different OS's require different prefixes for the environment variables to be
1916
+ # propagated to the calling contexts.
1917
+ # In order to make tests OS-agnostic, names of environment variables should be
1918
+ # prefixed with `%env-`, which is then expanded to the appropriate prefix.
1919
+ config .substitutions .append (('%env-' , config .target_env_prefix ))
1920
+
1881
1921
config .substitutions .append (("%target-sdk-name" , config .target_sdk_name ))
1882
1922
1883
1923
simulator_sdks = [
@@ -2048,42 +2088,40 @@ if 'concurrency' in config.available_features:
2048
2088
else :
2049
2089
config .available_features .add ('concurrency_runtime' )
2050
2090
2051
- # Set up testing with the standard libraries coming from the OS / just-built libraries
2052
- # default Swift tests to use the just-built libraries
2053
- target_stdlib_path = platform_dylib_dir
2054
- if not kIsWindows :
2055
- libdispatch_path = getattr (config , 'libdispatch_artifact_dir' , '' )
2056
- if 'use_os_stdlib' not in lit_config .params :
2057
- if run_os == 'maccatalyst' :
2058
- # Under macCatalyst we need to have the unzippered twin dylib dir come before
2059
- # the zippered/macosx dylib dir so that unzippered twins are picked upload_dylibs
2060
- # before the macOS variant.
2061
- target_stdlib_path = "{0}:{1}" .format (platform_module_dir , target_stdlib_path )
2062
- lit_config .note ('Testing with the just-built libraries at ' + target_stdlib_path )
2063
- config .target_run = (
2064
- "/usr/bin/env "
2065
- "DYLD_LIBRARY_PATH='{0}' " # Apple option
2066
- "LD_LIBRARY_PATH='{0}:{1}' " # Linux option
2067
- "SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
2068
- .format (target_stdlib_path , libdispatch_path )) + config .target_run
2069
- else :
2070
- config .available_features .add ('use_os_stdlib' )
2071
- os_stdlib_path = ''
2072
- if run_vendor == 'apple' :
2073
- #If we get swift-in-the-OS for non-Apple platforms, add a condition here
2074
- os_stdlib_path = "/usr/lib/swift"
2075
- if run_os == 'maccatalyst' :
2076
- os_stdlib_path = "/System/iOSSupport/usr/lib/swift:/usr/lib/swift"
2077
-
2078
- all_stdlib_path = os .path .pathsep .join ((os_stdlib_path , concurrency_back_deploy_path , target_stdlib_path ))
2079
-
2080
- lit_config .note ('Testing with the standard libraries coming from the OS ' + all_stdlib_path )
2081
- config .target_run = (
2082
- "/usr/bin/env "
2083
- "DYLD_LIBRARY_PATH='{0}' " # Apple option
2084
- "LD_LIBRARY_PATH='{0}:{1}' " # Linux option
2085
- "SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
2086
- .format (all_stdlib_path , libdispatch_path )) + config .target_run
2091
+ # Set up testing with the standard libraries coming from either the OS, the back
2092
+ # deployment runtime or the just-built libraries. By default, we run tests with
2093
+ # the just-built libraries.
2094
+ target_stdlib_path = [platform_dylib_dir ]
2095
+ if run_os == 'maccatalyst' :
2096
+ # Under macCatalyst we need to have the unzippered twin dylib dir come before
2097
+ # the zippered/macosx dylib dir so that unzippered twins are picked upload_dylibs
2098
+ # before the macOS variant.
2099
+ target_stdlib_path = [platform_module_dir , platform_dylib_dir ]
2100
+
2101
+ if run_vendor != 'apple' :
2102
+ libdispatch_path = getattr (config , 'libdispatch_artifact_dir' , None )
2103
+ if libdispatch_path is not None :
2104
+ target_stdlib_path .append (libdispatch_path )
2105
+
2106
+ if 'remote-run-host' in lit_config .params :
2107
+ configure_remote_run ()
2108
+ elif not kIsWindows :
2109
+ if 'use_os_stdlib' in lit_config .params :
2110
+ config .available_features .add ('use_os_stdlib' )
2111
+
2112
+ target_stdlib_path = os_stdlib_paths () + [concurrency_back_deploy_path ] + target_stdlib_path
2113
+
2114
+ lit_config .note ('Testing with the standard libraries in the OS' )
2115
+ elif 'back_deployment_runtime' in lit_config .params :
2116
+ lit_config .note ('Testing with back deployment runtime libraries' )
2117
+ else :
2118
+ lit_config .note ('Testing with the just-built libraries' )
2119
+
2120
+ lit_config .note ('Library load path: {0}' .format (os .path .pathsep .join (target_stdlib_path )))
2121
+ config .target_run = (
2122
+ "/usr/bin/env " +
2123
+ construct_library_path_env (target_stdlib_path ) +
2124
+ config .target_run )
2087
2125
2088
2126
# When running with the JIT on Darwin, force the usage of the just built stdlib
2089
2127
# when running the frontend. This is because we currently JIT in process
@@ -2410,7 +2448,7 @@ config.substitutions.append(('%import-static-libdispatch', getattr(config, 'impo
2410
2448
config .environment ['SWIFT_DEBUG_ENABLE_COW_CHECKS' ] = 'false'
2411
2449
2412
2450
# Add this to the command which runs an executable to enable COW checks in the swift runtime.
2413
- config .substitutions .append (('%enable-cow-checking' , TARGET_ENV_PREFIX + 'SWIFT_DEBUG_ENABLE_COW_CHECKS=true;' ))
2451
+ config .substitutions .append (('%enable-cow-checking' , config . target_env_prefix + 'SWIFT_DEBUG_ENABLE_COW_CHECKS=true;' ))
2414
2452
2415
2453
# We add an expansion to ensure that migrator tests can search for the api diff
2416
2454
# data dir from the host compiler toolchain instead of the resource dir of the
@@ -2445,10 +2483,10 @@ if config.lldb_build_root != "":
2445
2483
# Disable randomized hash seeding by default. Tests need to manually opt in to
2446
2484
# random seeds by unsetting the SWIFT_DETERMINISTIC_HASHING environment
2447
2485
# variable.
2448
- config .environment [TARGET_ENV_PREFIX + 'SWIFT_DETERMINISTIC_HASHING' ] = '1'
2486
+ config .environment [config . target_env_prefix + 'SWIFT_DETERMINISTIC_HASHING' ] = '1'
2449
2487
2450
2488
# Enable malloc scribble during tests by default.
2451
- config .environment [TARGET_ENV_PREFIX + 'SWIFT_DEBUG_ENABLE_MALLOC_SCRIBBLE' ] = 'YES'
2489
+ config .environment [config . target_env_prefix + 'SWIFT_DEBUG_ENABLE_MALLOC_SCRIBBLE' ] = 'YES'
2452
2490
2453
2491
# Run lsb_release on the target to be tested and return the results.
2454
2492
def linux_get_lsb_release ():
0 commit comments