@@ -938,18 +938,24 @@ if run_vendor == 'apple':
938938 # The "freestanding" tests will link against the static libswiftCore.a and
939939 # cannot use any of Obj-C / Dispatch / Foundation.
940940 if "-freestanding" in config .variant_suffix :
941- config .target_runtime = "native"
942- config .available_features .remove ('libdispatch' )
943- config .available_features .remove ('foundation' )
944- config .available_features .remove ('objc_interop' )
941+ if not config .swift_freestanding_is_darwin :
942+ config .target_runtime = "native"
943+ if not config .swift_enable_dispatch :
944+ config .available_features .remove ('libdispatch' )
945+ if not config .swift_freestanding_is_darwin :
946+ config .available_features .remove ('foundation' )
947+ if not config .swift_stdlib_enable_objc_interop :
948+ config .available_features .remove ('objc_interop' )
945949 config .available_features .add ('freestanding' )
946950
947951 # Build all "freestanding" tests with -disable-objc-interop
948- swift_execution_tests_extra_flags += ' -Xfrontend -disable-objc-interop'
952+ if not config .swift_stdlib_enable_objc_interop :
953+ swift_execution_tests_extra_flags += ' -Xfrontend -disable-objc-interop'
949954
950955 # The Concurrency module is not available in "freestanding" mode.
951- swift_execution_tests_extra_flags += \
952- ' -Xfrontend -disable-implicit-concurrency-module-import'
956+ if not 'concurrency' in config .available_features :
957+ swift_execution_tests_extra_flags += \
958+ ' -Xfrontend -disable-implicit-concurrency-module-import'
953959
954960 # To have visible references from symbolic manglings
955961 swift_execution_tests_extra_flags += \
@@ -958,9 +964,11 @@ if run_vendor == 'apple':
958964 # Link all "freestanding" tests with -dead_strip, which can effectively
959965 # even remove parts of the stdlib and runtime, if it's not needed. Since
960966 # it's a very desired behavior, let's enable it for all executable tests.
961- swift_execution_tests_extra_flags += ' -Xlinker -dead_strip'
967+ if not config .swift_freestanding_is_darwin :
968+ swift_execution_tests_extra_flags += ' -Xlinker -dead_strip'
962969
963- swift_execution_tests_extra_flags += ' -experimental-hermetic-seal-at-link -lto=llvm-full'
970+ if not config .swift_freestanding_is_darwin :
971+ swift_execution_tests_extra_flags += ' -experimental-hermetic-seal-at-link -lto=llvm-full'
964972
965973 # Build a resource dir for freestanding tests.
966974 new_resource_dir = os .path .join (config .test_exec_root , "resource_dir" )
@@ -972,6 +980,8 @@ if run_vendor == 'apple':
972980 symlink_if_not_exists ("clang" , "clang" )
973981 symlink_if_not_exists ("shims" , "shims" )
974982 symlink_if_not_exists ("freestanding" , "macosx" )
983+ if config .swift_freestanding_is_darwin :
984+ symlink_if_not_exists ("apinotes" , "apinotes" )
975985 config .resource_dir_opt = "-resource-dir %s" % new_resource_dir
976986 lit_config .note ('Using freestanding resource dir: ' + new_resource_dir )
977987
@@ -1160,7 +1170,13 @@ if run_vendor == 'apple':
11601170 'Running tests on %s version %s (%s)' %
11611171 (sw_vers_name , sw_vers_vers , sw_vers_build ))
11621172
1163- config .target_sdk_name = xcrun_sdk_name
1173+ if "-freestanding" in config .variant_suffix and config .swift_freestanding_is_darwin :
1174+ # This will ensure we are able to find libraries
1175+ # and resource dir at the correct path in tests that require
1176+ # Foundation and ObjectiveC capabilities
1177+ config .target_sdk_name = config .freestanding_sdk_name
1178+ else :
1179+ config .target_sdk_name = xcrun_sdk_name
11641180 config .target_ld = "%s ld -L%r" % (xcrun_prefix , make_path (test_resource_dir , config .target_sdk_name ))
11651181
11661182 maccatalyst_extra_frameworks = ""
0 commit comments