@@ -955,6 +955,7 @@ if run_vendor == 'apple':
955
955
config .target_codesign = make_path (config .swift_utils , "swift-darwin-postprocess.py" )
956
956
else :
957
957
config .target_codesign = "codesign -f -s -"
958
+ config .target_library_path_var = "DYLD_LIBRARY_PATH"
958
959
config .target_runtime = "objc"
959
960
960
961
config .available_features .add ('libdispatch' )
@@ -1453,6 +1454,7 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
1453
1454
config .target_shared_library_suffix = ".so"
1454
1455
config .target_sdk_name = "linux"
1455
1456
config .target_cc_options = "-fPIE"
1457
+ config .target_library_path_var = "LD_LIBRARY_PATH"
1456
1458
config .target_runtime = "native"
1457
1459
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
1458
1460
@@ -1579,6 +1581,7 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
1579
1581
config .target_runtime = "native"
1580
1582
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
1581
1583
config .target_sdk_name = "android"
1584
+ config .target_library_path_var = "LD_LIBRARY_PATH"
1582
1585
config .target_env_prefix = 'ANDROID_CHILD_'
1583
1586
config .resource_dir_opt = ("-resource-dir %s" % test_resource_dir )
1584
1587
# Since NDK r19, the headers and libraries are available in a unified
@@ -1792,24 +1795,51 @@ if run_vendor == 'apple':
1792
1795
if 'back_deploy_concurrency' in config .available_features :
1793
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 )
1794
1797
1795
- 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 ():
1796
1824
if 'remote_run_tmpdir' not in lit_config .params :
1797
1825
lit_config .fatal ("'remote_run_host' provided, but no "
1798
1826
"'remote_run_tmpdir'" )
1799
1827
1800
1828
remote_run_host = lit_config .params ['remote_run_host' ]
1801
1829
remote_tmp_dir = lit_config .params ['remote_run_tmpdir' ]
1802
1830
remote_lib_dir = os .path .join (remote_tmp_dir , 'stdlib' )
1803
- remote_run_lib_path = ''
1804
- if 'use_os_stdlib' not in lit_config .params :
1805
- remote_run_lib_path = remote_lib_dir
1806
- else :
1831
+ remote_run_lib_path = [remote_lib_dir ]
1832
+ if 'use_os_stdlib' in lit_config .params :
1807
1833
config .available_features .add ('use_os_stdlib' )
1808
- os_stdlib_path = ''
1809
- if run_vendor == 'apple' :
1810
- #If we get swift-in-the-OS for non-Apple platforms, add a condition here
1811
- os_stdlib_path = "/usr/lib/swift"
1812
- 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 )))
1813
1843
1814
1844
remote_run_extra_args_param = lit_config .params .get ('remote_run_extra_args' )
1815
1845
remote_run_extra_args = shlex .split (remote_run_extra_args_param or '' )
@@ -1858,16 +1888,14 @@ if 'remote_run_host' in lit_config.params:
1858
1888
1859
1889
config .target_env_prefix = 'REMOTE_RUN_CHILD_'
1860
1890
config .target_run = (
1861
- "/usr/bin/env "
1862
- "REMOTE_RUN_CHILD_DYLD_LIBRARY_PATH='{0}' " # Apple option
1863
- "REMOTE_RUN_CHILD_LD_LIBRARY_PATH='{0}' " # Linux option
1864
- "'{1}'/remote-run --input-prefix '{2}' --output-prefix %t "
1865
- "--remote-dir '{3}'%t {4} {5}" .format (remote_run_lib_path ,
1866
- config .swift_utils ,
1867
- config .swift_src_root ,
1868
- remote_tmp_dir ,
1869
- ' ' .join (remote_run_extra_args ),
1870
- remote_run_host ))
1891
+ "/usr/bin/env " +
1892
+ construct_library_path_env (remote_run_lib_path ) +
1893
+ "'{0}'/remote-run " .format (config .swift_utils ) +
1894
+ "--input-prefix '{0}' " .format (config .src_root ) +
1895
+ "--output-prefix %t " +
1896
+ "--remote-dir '{0}'%t " .format (remote_tmp_dir ) +
1897
+ "{0} " .format (' ' .join (remote_run_extra_args )) +
1898
+ "{0}" .format (remote_run_host ))
1871
1899
config .target_swift_reflection_test = os .path .join (
1872
1900
remote_tmp_dir , 'bin' , swift_reflection_test_name )
1873
1901
config .available_features .add ('remote_run' )
@@ -2048,42 +2076,40 @@ if 'concurrency' in config.available_features:
2048
2076
else :
2049
2077
config .available_features .add ('concurrency_runtime' )
2050
2078
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
2079
+ # Set up testing with the standard libraries coming from either the OS, the back
2080
+ # deployment runtime or the just-built libraries. By default, we run tests with
2081
+ # the just-built libraries.
2082
+ target_stdlib_path = [platform_dylib_dir ]
2083
+ if run_os == 'maccatalyst' :
2084
+ # Under macCatalyst we need to have the unzippered twin dylib dir come before
2085
+ # the zippered/macosx dylib dir so that unzippered twins are picked upload_dylibs
2086
+ # before the macOS variant.
2087
+ target_stdlib_path = [platform_module_dir , platform_dylib_dir ]
2088
+
2089
+ if run_vendor != 'apple' :
2090
+ libdispatch_path = getattr (config , 'libdispatch_artifact_dir' , None )
2091
+ if libdispatch_path is not None :
2092
+ target_stdlib_path .append (libdispatch_path )
2093
+
2094
+ if 'remote-run-host' in lit_config .params :
2095
+ configure_remote_run ()
2096
+ elif not kIsWindows :
2097
+ if 'use_os_stdlib' in lit_config .params :
2098
+ config .available_features .add ('use_os_stdlib' )
2099
+
2100
+ target_stdlib_path = os_stdlib_paths () + [concurrency_back_deploy_path ] + target_stdlib_path
2101
+
2102
+ lit_config .note ('Testing with the standard libraries in the OS' )
2103
+ elif 'back_deployment_runtime' in lit_config .params :
2104
+ lit_config .note ('Testing with back deployment runtime libraries' )
2105
+ else :
2106
+ lit_config .note ('Testing with the just-built libraries' )
2107
+
2108
+ lit_config .note ('Library load path: {0}' .format (os .path .pathsep .join (target_stdlib_path )))
2109
+ config .target_run = (
2110
+ "/usr/bin/env " +
2111
+ construct_library_path_env (target_stdlib_path ) +
2112
+ config .target_run )
2087
2113
2088
2114
# When running with the JIT on Darwin, force the usage of the just built stdlib
2089
2115
# when running the frontend. This is because we currently JIT in process
0 commit comments