From 87612b40ded05171ade4ff0c07196c6a0cca76d9 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:24:17 -0700 Subject: [PATCH 01/35] [Apple Silicon] Add arm64 macOS support to benchmark suite --- benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake b/benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake index 05a9e75ddc7f2..ce0aa58f486ee 100644 --- a/benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake +++ b/benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake @@ -105,7 +105,7 @@ macro(configure_build) endmacro() macro(configure_sdks_darwin) - set(macosx_arch "x86_64") + set(macosx_arch "x86_64" "arm64") set(iphoneos_arch "arm64" "arm64e" "armv7") set(appletvos_arch "arm64") set(watchos_arch "armv7k") @@ -609,11 +609,7 @@ function (swift_benchmark_compile_archopts) if(is_darwin) # If host == target. - if("${BENCH_COMPILE_ARCHOPTS_PLATFORM}" STREQUAL "macosx") - set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}") - else() - set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}") - endif() + set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}") else() # If we are on Linux, we do not support cross compiling. set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}") From 8d74d35651ab562bd9fc1c4dbefcf7dd69621d53 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:25:34 -0700 Subject: [PATCH 02/35] [Apple Silicon][Test] Enable testing for arm64 macOS --- test/lit.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lit.cfg b/test/lit.cfg index ac51503609aad..0926ee9078c92 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -828,7 +828,7 @@ if run_vendor == 'apple': 'the swift_test_mode is "only_non_executable". Current ' 'swift_test_mode is {}.'.format(swift_test_mode)) - if 'arm' in run_cpu: + if 'arm' in run_cpu and not (run_os == 'macosx' or run_os == 'maccatalyst'): # iOS/tvOS/watchOS device if run_os == 'ios': lit_config.note('Testing iOS ' + config.variant_triple) From d7951697da7aa001d956350ae426f733619abb90 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:26:10 -0700 Subject: [PATCH 03/35] [Apple Silicon] Mark several tests that require the Swift interpreter accordingly --- test/Driver/options.swift | 2 ++ test/Interpreter/SDK/interpret_with_options.swift | 1 + test/Interpreter/availability_host_os.swift | 1 + validation-test/execution/interpret-with-dependencies.swift | 1 + 4 files changed, 5 insertions(+) diff --git a/test/Driver/options.swift b/test/Driver/options.swift index 7b98acf88d4b3..23f6ffdca4ff8 100644 --- a/test/Driver/options.swift +++ b/test/Driver/options.swift @@ -1,3 +1,5 @@ +// REQUIRES: swift_interpreter + // RUN: not %swiftc_driver -emit-silgen -parse-as-library %s -module-name "Swift" 2>&1 | %FileCheck -check-prefix=STDLIB_MODULE %s // RUN: %target-swiftc_driver -emit-silgen -parse-as-library %s -module-name "Swift" -parse-stdlib -### // STDLIB_MODULE: error: module name "Swift" is reserved for the standard library{{$}} diff --git a/test/Interpreter/SDK/interpret_with_options.swift b/test/Interpreter/SDK/interpret_with_options.swift index c427e0b9b4cc5..22e95023c2a8f 100644 --- a/test/Interpreter/SDK/interpret_with_options.swift +++ b/test/Interpreter/SDK/interpret_with_options.swift @@ -5,6 +5,7 @@ // RUN: cd %S && %swift_driver -sdk %sdk -lInputs/libTestLoad.dylib %s | %FileCheck -check-prefix=WITH-LIB %s // REQUIRES: OS=macosx // REQUIRES: executable_test +// REQUIRES: swift_interpreter import ObjectiveC diff --git a/test/Interpreter/availability_host_os.swift b/test/Interpreter/availability_host_os.swift index 17eeffcb79b5a..764d9cfa4c395 100644 --- a/test/Interpreter/availability_host_os.swift +++ b/test/Interpreter/availability_host_os.swift @@ -8,6 +8,7 @@ // REQUIRES: OS=macosx // REQUIRES: executable_test +// REQUIRES: swift_interpreter print(mavericks()) // CHECK: {{^9$}} print(yosemite()) // CHECK-NEXT: {{^10$}} diff --git a/validation-test/execution/interpret-with-dependencies.swift b/validation-test/execution/interpret-with-dependencies.swift index 330691dfea769..4c72efc9908fe 100644 --- a/validation-test/execution/interpret-with-dependencies.swift +++ b/validation-test/execution/interpret-with-dependencies.swift @@ -1,5 +1,6 @@ // REQUIRES: OS=macosx // RUN: %empty-directory(%t) +// REQUIRES: swift_interpreter // RUN: echo 'int abc = 42;' | %clang -x c - -dynamiclib -Xlinker -install_name -Xlinker libabc.dylib -o %t/libabc.dylib // RUN: echo 'int test() { extern int abc; return abc; }' | %clang -x c - -L%t -dynamiclib -labc -o %t/libfoo.dylib From d5b48bceee40f79213260882368e70e946792ac3 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:27:46 -0700 Subject: [PATCH 04/35] [Apple Silicon] Generalize tests for other macOS architectures Most of the changes fall into a few categories: * Replace explicit "x86_64" with %target-cpu in lit tests * Cope with architecture differences in IR/asm/etc. macOS-specific tests --- .../availability_implicit_macosx.swift | 4 +-- .../ClangImporter/bad-deployment-target.swift | 2 +- test/ClangImporter/enum-with-target.swift | 4 +-- test/ClangImporter/objc_factory_method.swift | 2 +- test/ClangImporter/objc_ir.swift | 2 +- test/Driver/print_target_info_macos.swift | 4 +-- test/IDE/print_module_bad_target.swift | 2 +- .../autolink-runtime-compatibility.swift | 10 +++--- test/IRGen/condfail.sil | 16 +++++----- test/IRGen/lazy_metadata_with-g.swift | 2 +- test/IRGen/objc_properties.swift | 28 ++++++++-------- .../objc_protocol_extended_method_types.swift | 32 +++++++++---------- .../opaque_result_type_availability.swift | 4 +-- test/IRGen/osx-targets.swift | 10 +++--- test/IRGen/weak_import_clang.swift | 4 +-- .../IRGen/weak_import_deployment_target.swift | 12 +++---- .../objc_class_properties_runtime.swift | 2 +- ...e-cache-deployment-target-irrelevant.swift | 12 +++---- .../stable-bit-backward-deployment.swift | 2 +- test/SILGen/availability_attribute.swift | 4 +-- test/SILGen/availability_query.swift | 4 +-- .../enum_raw_representable_available.swift | 6 ++-- test/Sema/availability_versions.swift | 6 ++-- test/Sema/deprecation_osx.swift | 4 +-- test/Serialization/target-too-new.swift | 16 +++++----- .../InterfaceGen/gen_clang_module.swift | 2 +- .../Misc/resource-dir-handling.swift | 4 +-- test/api-digester/compare-two-sdks.swift | 2 +- .../conforms/nscoding_availability_osx.swift | 4 +-- test/stdlib/DispatchDeprecationMacOS.swift | 2 +- 30 files changed, 103 insertions(+), 105 deletions(-) diff --git a/test/ClangImporter/availability_implicit_macosx.swift b/test/ClangImporter/availability_implicit_macosx.swift index 71713bf1fff27..158a321fd06d5 100644 --- a/test/ClangImporter/availability_implicit_macosx.swift +++ b/test/ClangImporter/availability_implicit_macosx.swift @@ -1,5 +1,5 @@ -// RUN: %swift -typecheck -verify -target x86_64-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s %S/Inputs/availability_implicit_macosx_other.swift -// RUN: not %swift -typecheck -target x86_64-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s %S/Inputs/availability_implicit_macosx_other.swift 2>&1 | %FileCheck %s '--implicit-check-not=:0' +// RUN: %swift -typecheck -verify -target %target-cpu-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s %S/Inputs/availability_implicit_macosx_other.swift +// RUN: not %swift -typecheck -target %target-cpu-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s %S/Inputs/availability_implicit_macosx_other.swift 2>&1 | %FileCheck %s '--implicit-check-not=:0' // REQUIRES: OS=macosx diff --git a/test/ClangImporter/bad-deployment-target.swift b/test/ClangImporter/bad-deployment-target.swift index 47d0bfa934d34..3e60703a55a5c 100644 --- a/test/ClangImporter/bad-deployment-target.swift +++ b/test/ClangImporter/bad-deployment-target.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -target x86_64-apple-macosx10.8 %s +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -target %target-cpu-apple-macosx10.8 %s // // This test ensures that a -target that is too old for the standard library // will not crash in the ClangImporter. diff --git a/test/ClangImporter/enum-with-target.swift b/test/ClangImporter/enum-with-target.swift index 334276c10ae07..35d26fef25b1e 100644 --- a/test/ClangImporter/enum-with-target.swift +++ b/test/ClangImporter/enum-with-target.swift @@ -1,5 +1,5 @@ -// RUN: %swift %clang-importer-sdk -target x86_64-apple-macosx10.51 -typecheck %s -verify -// RUN: %swift %clang-importer-sdk -target x86_64-apple-macosx10.52 -typecheck %s -verify +// RUN: %swift %clang-importer-sdk -target %target-cpu-apple-macosx10.51 -typecheck %s -verify +// RUN: %swift %clang-importer-sdk -target %target-cpu-apple-macosx10.52 -typecheck %s -verify // REQUIRES: OS=macosx import Foundation diff --git a/test/ClangImporter/objc_factory_method.swift b/test/ClangImporter/objc_factory_method.swift index cef3cae8707a2..4fcfb4d9e7d38 100644 --- a/test/ClangImporter/objc_factory_method.swift +++ b/test/ClangImporter/objc_factory_method.swift @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) // RUN: %build-clang-importer-objc-overlays -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -target x86_64-apple-macosx10.51 -typecheck %s -verify +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -target %target-cpu-apple-macosx10.51 -typecheck %s -verify // REQUIRES: OS=macosx // REQUIRES: objc_interop diff --git a/test/ClangImporter/objc_ir.swift b/test/ClangImporter/objc_ir.swift index b61e34ff01309..5e4bd325f04ce 100644 --- a/test/ClangImporter/objc_ir.swift +++ b/test/ClangImporter/objc_ir.swift @@ -34,7 +34,7 @@ func instanceMethods(_ b: B) { func extensionMethods(b b: B) { // CHECK: load i8*, i8** @"\01L_selector(method:separateExtMethod:)", align 8 // CHECK: [[T0:%.*]] = call i8* bitcast (void ()* @objc_msgSend to i8* - // CHECK-NEXT: [[T1:%.*]] = {{.*}}call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]]) + // CHECK: [[T1:%.*]] = {{.*}}call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]]) // CHECK-NOT: [[T0]] // CHECK: [[T1]] b.method(1, separateExtMethod:1.5) diff --git a/test/Driver/print_target_info_macos.swift b/test/Driver/print_target_info_macos.swift index 14074424cf484..eec4e0a291803 100644 --- a/test/Driver/print_target_info_macos.swift +++ b/test/Driver/print_target_info_macos.swift @@ -7,5 +7,5 @@ // REQUIRES: OS=macosx -// CHECK: "triple": "x86_64-apple-macosx10 -// CHECK: "unversionedTriple": "x86_64-apple-macosx" +// CHECK: "triple": "{{.*}}-apple-macosx10 +// CHECK: "unversionedTriple": "{{.*}}-apple-macosx" diff --git a/test/IDE/print_module_bad_target.swift b/test/IDE/print_module_bad_target.swift index da4a02bb5684b..5ebec7359c244 100644 --- a/test/IDE/print_module_bad_target.swift +++ b/test/IDE/print_module_bad_target.swift @@ -1,7 +1,7 @@ // RUN: not %swift-ide-test -source-filename %s -print-module -module-to-print Swift -target x86_64-unknown-solaris // RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -emit-module -o %t -module-name Dummy -target x86_64-apple-macosx10.99 %s +// RUN: %target-swift-frontend -emit-module -o %t -module-name Dummy -target %target-cpu-apple-macosx10.99 %s // RUN: not %target-swift-ide-test -source-filename %s -print-module -module-to-print Dummy -I %t // REQUIRES: OS=macosx diff --git a/test/IRGen/autolink-runtime-compatibility.swift b/test/IRGen/autolink-runtime-compatibility.swift index 99dc558382103..54102577c19b3 100644 --- a/test/IRGen/autolink-runtime-compatibility.swift +++ b/test/IRGen/autolink-runtime-compatibility.swift @@ -1,23 +1,23 @@ // REQUIRES: OS=macosx // Doesn't autolink compatibility library because autolinking is disabled -// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -target x86_64-apple-macosx10.9 -disable-autolinking-runtime-compatibility -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s +// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -target %target-cpu-apple-macosx10.9 -disable-autolinking-runtime-compatibility -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s // RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-dynamic-replacements -runtime-compatibility-version 5.0 -disable-autolinking-runtime-compatibility -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s // Doesn't autolink compatibility library because runtime compatibility library is disabled // RUN: %target-swift-frontend -runtime-compatibility-version none -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s // Doesn't autolink compatibility library because target OS doesn't need it -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.24 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.24 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s // Only autolinks 5.1 compatibility library because target OS has 5.1 -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.15 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD-51 %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.15 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD-51 %s // Autolinks because compatibility library was explicitly asked for // RUN: %target-swift-frontend -runtime-compatibility-version 5.0 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD %s // RUN: %target-swift-frontend -runtime-compatibility-version 5.1 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD-51 %s -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.24 -runtime-compatibility-version 5.0 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD %s -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.24 -runtime-compatibility-version 5.1 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD-51 %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.24 -runtime-compatibility-version 5.0 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.24 -runtime-compatibility-version 5.1 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=FORCE-LOAD-51 %s public func foo() {} diff --git a/test/IRGen/condfail.sil b/test/IRGen/condfail.sil index 528e63a65474e..ebdc6b92318bc 100644 --- a/test/IRGen/condfail.sil +++ b/test/IRGen/condfail.sil @@ -17,8 +17,8 @@ import Swift // CHECK-powerpc64: .cfi_startproc // CHECK-powerpc64le: .cfi_startproc // CHECK-s390x: .cfi_startproc -// CHECK-OPT-macosx: ## InlineAsm Start -// CHECK-OPT-macosx: ## InlineAsm End +// CHECK-OPT-macosx: InlineAsm Start +// CHECK-OPT-macosx: InlineAsm End // CHECK-OPT-linux: ##APP // CHECK-OPT-linux: ##NO_APP // CHECK-OPT-windows: ##APP @@ -27,8 +27,8 @@ import Swift // CHECK-OPT-linux-androideabi: @NO_APP // CHECK-OPT-linux-android: //APP // CHECK-OPT-linux-android: //NO_APP -// CHECK-NOOPT-macosx-NOT: ## InlineAsm Start -// CHECK-NOOPT-macosx-NOT: ## InlineAsm End +// CHECK-NOOPT-macosx-NOT: InlineAsm Start +// CHECK-NOOPT-macosx-NOT: InlineAsm End // CHECK-NOOPT-linux-NOT: ##APP // CHECK-NOOPT-linux-NOT: ##NO_APP // CHECK-NOOPT-windows-NOT: ##APP @@ -55,14 +55,14 @@ import Swift // CHECK-NOT-powerpc64: .cfi_endproc // CHECK-NOT-powerpc64le: .cfi_endproc // CHECK-NOT-s390x: .cfi_endproc -// CHECK-OPT-macosx: ## InlineAsm Start -// CHECK-OPT-macosx: ## InlineAsm End +// CHECK-OPT-macosx: InlineAsm Start +// CHECK-OPT-macosx: InlineAsm End // CHECK-OPT-linux: ##APP // CHECK-OPT-linux: ##NO_APP // CHECK-OPT-windows: ##APP // CHECK-OPT-windows: ##NO_APP -// CHECK-NOOPT-macosx-NOT: ## InlineAsm Start -// CHECK-NOOPT-macosx-NOT: ## InlineAsm End +// CHECK-NOOPT-macosx-NOT: InlineAsm Start +// CHECK-NOOPT-macosx-NOT: InlineAsm End // CHECK-NOOPT-linux-NOT: ##APP // CHECK-NOOPT-linux-NOT: ##NO_APP // CHECK-NOOPT-windows-NOT: ##APP diff --git a/test/IRGen/lazy_metadata_with-g.swift b/test/IRGen/lazy_metadata_with-g.swift index b5f02f6720249..d532778d2fe96 100644 --- a/test/IRGen/lazy_metadata_with-g.swift +++ b/test/IRGen/lazy_metadata_with-g.swift @@ -1,4 +1,4 @@ -// RUN: %target-swiftc_driver -parse-as-library -module-name=test -target x86_64-apple-macosx10.15 -wmo -O -g -emit-ir %s | %FileCheck %s +// RUN: %target-swiftc_driver -parse-as-library -module-name=test -target %target-cpu-apple-macosx10.15 -wmo -O -g -emit-ir %s | %FileCheck %s // REQUIRES: OS=macosx // Check that the compiler does not emit any metadata for unused internal diff --git a/test/IRGen/objc_properties.swift b/test/IRGen/objc_properties.swift index bcf966829a886..b79e20b0e9187 100644 --- a/test/IRGen/objc_properties.swift +++ b/test/IRGen/objc_properties.swift @@ -1,7 +1,7 @@ // This file is also used by objc_properties_ios.swift. -// RUN: %swift -target x86_64-apple-macosx10.11 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %s -// RUN: %swift -target x86_64-apple-macosx10.10 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %s +// RUN: %swift -target %target-cpu-apple-macosx10.11 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %s +// RUN: %swift -target %target-cpu-apple-macosx10.10 %s -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %s // REQUIRES: OS=macosx // REQUIRES: objc_interop @@ -133,35 +133,35 @@ class SomeWrapperTests { // CHECK: [8 x { i8*, i8*, i8* }] [{ // CHECK: i8* getelementptr inbounds ([9 x i8], [9 x i8]* @"\01L_selector_data(readonly)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast ([[OPAQUE0:%.*]]* ([[OPAQUE1:%.*]]*, i8*)* @"$s15objc_properties10SomeObjectC8readonlyACvgTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC8readonlyACvgTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([10 x i8], [10 x i8]* @"\01L_selector_data(readwrite)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast ([[OPAQUE0]]* ([[OPAQUE1]]*, i8*)* @"$s15objc_properties10SomeObjectC9readwriteACvgTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC9readwriteACvgTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([14 x i8], [14 x i8]* @"\01L_selector_data(setReadwrite:)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* [[SETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (void ([[OPAQUE3:%.*]]*, i8*, [[OPAQUE4:%.*]]*)* @"$s15objc_properties10SomeObjectC9readwriteACvsTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC9readwriteACvsTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([9 x i8], [9 x i8]* @"\01L_selector_data(bareIvar)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast ([[OPAQUE0]]* ([[OPAQUE1]]*, i8*)* @"$s15objc_properties10SomeObjectC8bareIvarACvgTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC8bareIvarACvgTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([13 x i8], [13 x i8]* @"\01L_selector_data(setBareIvar:)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* [[SETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (void ([[OPAQUE3]]*, i8*, [[OPAQUE4]]*)* @"$s15objc_properties10SomeObjectC8bareIvarACvsTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC8bareIvarACvsTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([7 x i8], [7 x i8]* @"\01L_selector_data(wobble)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (%0* (%0*, i8*)* @"$s15objc_properties10SomeObjectC6wibbleACvgTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC6wibbleACvgTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* @"\01L_selector_data(setWobble:)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* [[SETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (void (%0*, i8*, %0*)* @"$s15objc_properties10SomeObjectC6wibbleACvsTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC6wibbleACvsTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([5 x i8], [5 x i8]* @"\01L_selector_data(init)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast ([[OPAQUE5:%.*]]* ([[OPAQUE6:%.*]]*, i8*)* @"$s15objc_properties10SomeObjectCACycfcTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectCACycfcTo{{(.ptrauth)?}}" // CHECK: }] // CHECK: }, section "__DATA, __objc_const", align 8 @@ -214,11 +214,11 @@ class SomeWrapperTests { // CHECK: [2 x { i8*, i8*, i8* }] [{ // CHECK: { i8* getelementptr inbounds ([18 x i8], [18 x i8]* @"\01L_selector_data(extensionProperty)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast ([[OPAQUE0]]* ([[OPAQUE1]]*, i8*)* @"$s15objc_properties10SomeObjectC17extensionPropertyACvgTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC17extensionPropertyACvgTo{{(.ptrauth)?}}" // CHECK: }, { // CHECK: i8* getelementptr inbounds ([22 x i8], [22 x i8]* @"\01L_selector_data(setExtensionProperty:)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* [[SETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (void ([[OPAQUE3]]*, i8*, [[OPAQUE4]]*)* @"$s15objc_properties10SomeObjectC17extensionPropertyACvsTo" to i8*) +// CHECK: @"$s15objc_properties10SomeObjectC17extensionPropertyACvsTo{{(.ptrauth)?}}" // CHECK: }] // CHECK: }, section "__DATA, __objc_const", align 8 @@ -264,10 +264,10 @@ class SomeWrapperTests { // CHECK: @_INSTANCE_METHODS__TtC15objc_properties4Tree = // CHECK: i8* getelementptr inbounds ([7 x i8], [7 x i8]* @"\01L_selector_data(parent)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([8 x i8], [8 x i8]* [[GETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (%2* (%2*, i8*)* @"$s15objc_properties4TreeC6parentACSgvgTo" to i8*) +// CHECK: @"$s15objc_properties4TreeC6parentACSgvgTo{{(.ptrauth)?}}" // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* @"\01L_selector_data(setParent:)", i64 0, i64 0), // CHECK: i8* getelementptr inbounds ([11 x i8], [11 x i8]* [[SETTER_SIGNATURE]], i64 0, i64 0), -// CHECK: i8* bitcast (void (%2*, i8*, %2*)* @"$s15objc_properties4TreeC6parentACSgvsTo" to i8*) +// CHECK: @"$s15objc_properties4TreeC6parentACSgvsTo{{(.ptrauth)?}}" // CHECK: @_PROTOCOL__TtP15objc_properties5Proto_ = private constant { {{.+}} } { // CHECK: i8* null, diff --git a/test/IRGen/objc_protocol_extended_method_types.swift b/test/IRGen/objc_protocol_extended_method_types.swift index 87db4b883d49a..1483c47e4b631 100644 --- a/test/IRGen/objc_protocol_extended_method_types.swift +++ b/test/IRGen/objc_protocol_extended_method_types.swift @@ -99,26 +99,26 @@ print(P.self) // CHECK-JIT: [[NEW_PROTOCOL:%.+]] = call %swift.protocol* @objc_allocateProtocol(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @2, i64 0, i64 0)) // -- requiredInstanceMethod: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceMethod:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- optionalInstanceMethod: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalInstanceMethod:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 0, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), {{(i8 0|i1 false)}}, {{(i8 1|i1 true)}}) // -- requiredClassMethod: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredClassMethod:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 0) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 0|i1 false)}}) // -- optionalClassMethod: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalClassMethod:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 0, i8 0) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), {{(i8 0|i1 false)}}, {{(i8 0|i1 false)}}) // -- requiredInstanceProperty // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceProperty)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // Make sure we don't emit storage accessors multiple times. // CHECK-JIT-NOT: requiredInstanceProperty // -- setRequiredInstanceProperty: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(setRequiredInstanceProperty:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // Make sure we don't emit storage accessors multiple times. // CHECK-JIT-NOT: requiredInstanceProperty @@ -126,34 +126,34 @@ print(P.self) // -- requiredROInstanceProperty // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredROInstanceProperty)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- requiredInstanceMethod2: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceMethod2:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- optionalInstanceMethod2: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalInstanceMethod2:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 0, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), {{(i8 0|i1 false)}}, {{(i8 1|i1 true)}}) // -- requiredClassMethod2: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredClassMethod2:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 0) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 0|i1 false)}}) // -- optionalClassMethod2: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalClassMethod2:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 0, i8 0) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), {{(i8 0|i1 false)}}, {{(i8 0|i1 false)}}) // -- requiredInstanceProperty2 // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceProperty2)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- setRequiredInstanceProperty2: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(setRequiredInstanceProperty2:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- requiredROInstanceProperty2 // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredROInstanceProperty2)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- objectAtIndexedSubscript: // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(objectAtIndexedSubscript:)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_INT_INT]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_INT_INT]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // -- init // CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(init)", i64 0, i64 0)) -// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1) +// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), {{(i8 1|i1 true)}}, {{(i8 1|i1 true)}}) // CHECK-JIT: call void @objc_registerProtocol(%swift.protocol* [[NEW_PROTOCOL]]) // CHECK-JIT: br label %[[FINISH_LABEL]] diff --git a/test/IRGen/opaque_result_type_availability.swift b/test/IRGen/opaque_result_type_availability.swift index ebbc05a55bfaa..db522568ffc18 100644 --- a/test/IRGen/opaque_result_type_availability.swift +++ b/test/IRGen/opaque_result_type_availability.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -enable-implicit-dynamic -target x86_64-apple-macosx10.9 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s -// RUN: %target-swift-frontend -enable-implicit-dynamic -target x86_64-apple-macosx10.15 -Onone -emit-ir %s | %FileCheck --check-prefix=ALWAYS-AVAILABLE %s +// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.9 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s +// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.15 -Onone -emit-ir %s | %FileCheck --check-prefix=ALWAYS-AVAILABLE %s // REQUIRES: OS=macosx protocol P {} diff --git a/test/IRGen/osx-targets.swift b/test/IRGen/osx-targets.swift index deb62e65ff4c3..3b066048aef74 100644 --- a/test/IRGen/osx-targets.swift +++ b/test/IRGen/osx-targets.swift @@ -1,13 +1,11 @@ // RUN: %swift %s -emit-ir | %FileCheck %s -// RUN: %swift -target x86_64-apple-macosx10.51 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC %s - -// disable this test until macOS 11 support lands in Swift. -// : %swift -target x86_64-apple-darwin55 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC %s +// RUN: %swift -target %target-cpu-apple-macosx10.51 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC %s +// RUN: %swift -target %target-cpu-apple-darwin55 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC %s // REQUIRES: OS=macosx -// CHECK: target triple = "x86_64-apple-macosx10. -// CHECK-SPECIFIC: target triple = "x86_64-apple-macosx10.51.0" +// CHECK: target triple = "{{.*}}-apple-macosx10. +// CHECK-SPECIFIC: target triple = "{{.*}}-apple-macosx10.51.0" public func anchor() {} anchor() diff --git a/test/IRGen/weak_import_clang.swift b/test/IRGen/weak_import_clang.swift index df29eed02992e..52630b5233810 100644 --- a/test/IRGen/weak_import_clang.swift +++ b/test/IRGen/weak_import_clang.swift @@ -4,8 +4,8 @@ // Specify explicit target triples for the deployment target to test weak // linking for a symbol introduced in OS X 10.51. // -// RUN: %target-swift-frontend(mock-sdk: -target x86_64-apple-macosx10.50 -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck -check-prefix=CHECK-10_50 %s -// RUN: %target-swift-frontend(mock-sdk: -target x86_64-apple-macosx10.51 -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck -check-prefix=CHECK-10_51 %s +// RUN: %target-swift-frontend(mock-sdk: -target %target-cpu-apple-macosx10.50 -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck -check-prefix=CHECK-10_50 %s +// RUN: %target-swift-frontend(mock-sdk: -target %target-cpu-apple-macosx10.51 -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck -check-prefix=CHECK-10_51 %s // REQUIRES: OS=macosx // REQUIRES: objc_interop diff --git a/test/IRGen/weak_import_deployment_target.swift b/test/IRGen/weak_import_deployment_target.swift index cbab1d9dce2ef..b906c7df5383d 100644 --- a/test/IRGen/weak_import_deployment_target.swift +++ b/test/IRGen/weak_import_deployment_target.swift @@ -1,12 +1,12 @@ // RUN: %empty-directory(%t) // -// RUN: %target-swift-frontend -enable-library-evolution -emit-module -target x86_64-apple-macosx10.50 -emit-module-path %t/weak_import_deployment_target_helper.swiftmodule -parse-as-library %S/Inputs/weak_import_deployment_target_helper.swift -// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target x86_64-apple-macosx10.50 | %FileCheck %s --check-prefix=CHECK-OLD -// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target x86_64-apple-macosx10.60 | %FileCheck %s --check-prefix=CHECK-NEW +// RUN: %target-swift-frontend -enable-library-evolution -emit-module -target %target-cpu-apple-macosx10.50 -emit-module-path %t/weak_import_deployment_target_helper.swiftmodule -parse-as-library %S/Inputs/weak_import_deployment_target_helper.swift +// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.50 | %FileCheck %s --check-prefix=CHECK-OLD +// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.60 | %FileCheck %s --check-prefix=CHECK-NEW // -// RUN: %target-swift-frontend -enable-library-evolution -emit-module -target x86_64-apple-macosx10.60 -emit-module-path %t/weak_import_deployment_target_helper.swiftmodule -parse-as-library %S/Inputs/weak_import_deployment_target_helper.swift -// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target x86_64-apple-macosx10.50 | %FileCheck %s --check-prefix=CHECK-OLD -// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target x86_64-apple-macosx10.60 | %FileCheck %s --check-prefix=CHECK-NEW +// RUN: %target-swift-frontend -enable-library-evolution -emit-module -target %target-cpu-apple-macosx10.60 -emit-module-path %t/weak_import_deployment_target_helper.swiftmodule -parse-as-library %S/Inputs/weak_import_deployment_target_helper.swift +// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.50 | %FileCheck %s --check-prefix=CHECK-OLD +// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target %target-cpu-apple-macosx10.60 | %FileCheck %s --check-prefix=CHECK-NEW // // REQUIRES: OS=macosx diff --git a/test/Interpreter/objc_class_properties_runtime.swift b/test/Interpreter/objc_class_properties_runtime.swift index 3cbeee721b554..1d1cf21348c45 100644 --- a/test/Interpreter/objc_class_properties_runtime.swift +++ b/test/Interpreter/objc_class_properties_runtime.swift @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) -// RUN: %clang -arch x86_64 -mmacosx-version-min=10.11 -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o +// RUN: %clang -arch %target-cpu -mmacosx-version-min=10.11 -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o // RUN: %swiftc_driver -target $(echo '%target-triple' | sed -E -e 's/macosx10.(9|10).*/macosx10.11/') -sdk %sdk -I %S/Inputs/ObjCClasses/ %t/ObjCClasses.o %s -o %t/a.out // RUN: %target-run %t/a.out diff --git a/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift b/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift index 27aad747e5426..13f132c586477 100644 --- a/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift +++ b/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift @@ -10,17 +10,17 @@ // RUN: echo 'import LeafModule' >%t/other.swift // RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift // -// Phase 1: build LeafModule into a .swiftinterface file with -target x86_64-macosx-10.9: +// Phase 1: build LeafModule into a .swiftinterface file with -target %target-cpu-macosx-10.9: // -// RUN: %swift -target x86_64-apple-macosx10.9 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck +// RUN: %swift -target %target-cpu-apple-macosx10.9 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck // -// Phase 2: build OtherModule into a .swiftinterface file with -target x86_64-macosx-10.10: +// Phase 2: build OtherModule into a .swiftinterface file with -target %target-cpu-macosx-10.10: // -// RUN: %swift -target x86_64-apple-macosx10.10 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -typecheck +// RUN: %swift -target %target-cpu-apple-macosx10.10 -I %t -module-cache-path %t/modulecache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -typecheck // -// Phase 3: build TestModule in -target x86_64-apple-macosx10.11 and import both of these: +// Phase 3: build TestModule in -target %target-cpu-apple-macosx10.11 and import both of these: // -// RUN: %swift -target x86_64-apple-macosx10.11 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -typecheck +// RUN: %swift -target %target-cpu-apple-macosx10.11 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -typecheck // // Phase 4: make sure we only compiled LeafModule and OtherModule one time: // diff --git a/test/Runtime/stable-bit-backward-deployment.swift b/test/Runtime/stable-bit-backward-deployment.swift index aa0e7b33dea43..09e18a7432c15 100644 --- a/test/Runtime/stable-bit-backward-deployment.swift +++ b/test/Runtime/stable-bit-backward-deployment.swift @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) // -- Deployment target is set to pre-10.14.4 so that we use the "old" // Swift runtime bit in compiler-emitted classes -// RUN: %target-build-swift -target x86_64-apple-macosx10.9 %s -module-name main -o %t/a.out +// RUN: %target-build-swift -target %target-cpu-apple-macosx10.9 %s -module-name main -o %t/a.out // RUN: %target-run %t/a.out | %FileCheck %s // REQUIRES: executable_test diff --git a/test/SILGen/availability_attribute.swift b/test/SILGen/availability_attribute.swift index c2bb509828e8c..cceb0ca07da9d 100644 --- a/test/SILGen/availability_attribute.swift +++ b/test/SILGen/availability_attribute.swift @@ -1,6 +1,6 @@ // RUN: %target-swift-emit-silgen %s | %FileCheck %s -// RUN: %target-swift-emit-silgen %s -target x86_64-apple-macosx10.50 | %FileCheck %s -// RUN: %target-swift-emit-silgen %s -target x86_64-apple-macosx10.60 | %FileCheck %s +// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.50 | %FileCheck %s +// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.60 | %FileCheck %s // REQUIRES: OS=macosx // CHECK-LABEL: sil [available 10.50] [ossa] @$s22availability_attribute17availableFunctionyyF : $@convention(thin) () -> () diff --git a/test/SILGen/availability_query.swift b/test/SILGen/availability_query.swift index 5ae132e316ddb..6cae310c96d7b 100644 --- a/test/SILGen/availability_query.swift +++ b/test/SILGen/availability_query.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-emit-sil %s -target x86_64-apple-macosx10.50 -verify -// RUN: %target-swift-emit-silgen %s -target x86_64-apple-macosx10.50 | %FileCheck %s +// RUN: %target-swift-emit-sil %s -target %target-cpu-apple-macosx10.50 -verify +// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.50 | %FileCheck %s // REQUIRES: OS=macosx diff --git a/test/SILGen/enum_raw_representable_available.swift b/test/SILGen/enum_raw_representable_available.swift index 080112253913e..404684a261fa7 100644 --- a/test/SILGen/enum_raw_representable_available.swift +++ b/test/SILGen/enum_raw_representable_available.swift @@ -1,10 +1,10 @@ -// RUN: %target-typecheck-verify-swift -target x86_64-apple-macosx10.52 +// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.52 -// RUN: %target-swift-emit-silgen -target x86_64-apple-macosx10.52 -emit-sorted-sil -o %t.fragile.sil %s +// RUN: %target-swift-emit-silgen -target %target-cpu-apple-macosx10.52 -emit-sorted-sil -o %t.fragile.sil %s // RUN: %FileCheck %s < %t.fragile.sil // RUN: %FileCheck -check-prefix NEGATIVE %s < %t.fragile.sil -// RUN: %target-swift-emit-silgen -target x86_64-apple-macosx10.52 -emit-sorted-sil -enable-library-evolution -o %t.resilient.sil %s +// RUN: %target-swift-emit-silgen -target %target-cpu-apple-macosx10.52 -emit-sorted-sil -enable-library-evolution -o %t.resilient.sil %s // RUN: %FileCheck %s < %t.resilient.sil // RUN: %FileCheck -check-prefix NEGATIVE %s < %t.resilient.sil diff --git a/test/Sema/availability_versions.swift b/test/Sema/availability_versions.swift index f757798b86b5a..e3adcb811d4cc 100644 --- a/test/Sema/availability_versions.swift +++ b/test/Sema/availability_versions.swift @@ -1,8 +1,8 @@ -// RUN: %target-typecheck-verify-swift -target x86_64-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -// RUN: not %target-swift-frontend -target x86_64-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=:0' +// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module +// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=:0' // Make sure we do not emit availability errors or warnings when -disable-availability-checking is passed -// RUN: not %target-swift-frontend -target x86_64-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:' '--implicit-check-not=warning:' +// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:' '--implicit-check-not=warning:' // REQUIRES: OS=macosx diff --git a/test/Sema/deprecation_osx.swift b/test/Sema/deprecation_osx.swift index d25f8ab7c5e5b..84a48bd81325e 100644 --- a/test/Sema/deprecation_osx.swift +++ b/test/Sema/deprecation_osx.swift @@ -1,5 +1,5 @@ -// RUN: %swift -typecheck -parse-as-library -target x86_64-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s -verify -// RUN: %swift -typecheck -parse-as-library -target x86_64-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s 2>&1 | %FileCheck %s '--implicit-check-not=:0' +// RUN: %swift -typecheck -parse-as-library -target %target-cpu-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s -verify +// RUN: %swift -typecheck -parse-as-library -target %target-cpu-apple-macosx10.51 %clang-importer-sdk -I %S/Inputs/custom-modules %s 2>&1 | %FileCheck %s '--implicit-check-not=:0' // // This test requires a target of OS X 10.51 or later to test deprecation // diagnostics because (1) we only emit deprecation warnings if a symbol is diff --git a/test/Serialization/target-too-new.swift b/test/Serialization/target-too-new.swift index d2cd2633941f2..62c0916a9a0ab 100644 --- a/test/Serialization/target-too-new.swift +++ b/test/Serialization/target-too-new.swift @@ -1,16 +1,16 @@ // RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.50 -emit-module -parse-stdlib %S/../Inputs/empty.swift -o %t -// RUN: not %target-swift-frontend -I %t -target x86_64-apple-macosx10.9 -typecheck %s 2>&1 | %FileCheck %s -// RUN: not %target-swift-frontend -I %t -target x86_64-apple-darwin13 -typecheck %s 2>&1 | %FileCheck %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.50 -emit-module -parse-stdlib %S/../Inputs/empty.swift -o %t +// RUN: not %target-swift-frontend -I %t -target %target-cpu-apple-macosx10.9 -typecheck %s 2>&1 | %FileCheck %s +// RUN: not %target-swift-frontend -I %t -target %target-cpu-apple-darwin13 -typecheck %s 2>&1 | %FileCheck %s // RUN: %target-swift-frontend -I %t -typecheck %s -disable-target-os-checking -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.50 -I %t -typecheck %s -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.50.1 -I %t -typecheck %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.50 -I %t -typecheck %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.50.1 -I %t -typecheck %s // Allow any version when built with resilience. (Really we should encode a // "minimum supported OS", but we don't have that information today.) -// RUN: %target-swift-frontend -target x86_64-apple-macosx10.50 -emit-module -parse-stdlib %S/../Inputs/empty.swift -enable-library-evolution -o %t -// RUN: %target-swift-frontend -I %t -target x86_64-apple-macosx10.9 -typecheck %s -// RUN: %target-swift-frontend -I %t -target x86_64-apple-darwin13 -typecheck %s +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.50 -emit-module -parse-stdlib %S/../Inputs/empty.swift -enable-library-evolution -o %t +// RUN: %target-swift-frontend -I %t -target %target-cpu-apple-macosx10.9 -typecheck %s +// RUN: %target-swift-frontend -I %t -target %target-cpu-apple-darwin13 -typecheck %s // REQUIRES: OS=macosx diff --git a/test/SourceKit/InterfaceGen/gen_clang_module.swift b/test/SourceKit/InterfaceGen/gen_clang_module.swift index 7c92eb4fe74ad..d97fc0b498eed 100644 --- a/test/SourceKit/InterfaceGen/gen_clang_module.swift +++ b/test/SourceKit/InterfaceGen/gen_clang_module.swift @@ -69,7 +69,7 @@ var x: FooClassBase // RUN: -target %target-triple %clang-importer-sdk-nosource -I %t | %FileCheck -check-prefix=CHECK-IFACE %s // CHECK-IFACE: DOC: (/) -// CHECK-IFACE: ARGS: [-target x86_64-{{.*}} -sdk {{.*}} -F {{.*}}/libIDE-mock-sdk -I {{.*}}.overlays {{.*}} -module-cache-path {{.*}} ] +// CHECK-IFACE: ARGS: [-target {{.*}}-{{.*}} -sdk {{.*}} -F {{.*}}/libIDE-mock-sdk -I {{.*}}.overlays {{.*}} -module-cache-path {{.*}} ] // RUN: %sourcekitd-test -req=interface-gen-open -module Foo -- -I %t.overlays -F %S/../Inputs/libIDE-mock-sdk \ // RUN: -target %target-triple %clang-importer-sdk-nosource -I %t \ diff --git a/test/SourceKit/Misc/resource-dir-handling.swift b/test/SourceKit/Misc/resource-dir-handling.swift index a4a1f66d5b87e..74d70cb82398d 100644 --- a/test/SourceKit/Misc/resource-dir-handling.swift +++ b/test/SourceKit/Misc/resource-dir-handling.swift @@ -5,8 +5,8 @@ var p: CoolInt // RUN: %empty-directory(%t) // RUN: %empty-directory(%t/custom-resource-dir/macosx/Swift.swiftmodule) -// RUN: %target-swift-frontend -emit-module -module-name Swift -parse-stdlib -target x86_64-apple-macosx10.12 %S/Inputs/custom-resource-stdlib.swift -o %t/custom-resource-dir/macosx/Swift.swiftmodule/%target-swiftmodule-name -// RUN: %sourcekitd-test -req=cursor -pos=3:8 %s -- -resource-dir %t/custom-resource-dir -target x86_64-apple-macosx10.12 %s | %FileCheck %s +// RUN: %target-swift-frontend -emit-module -module-name Swift -parse-stdlib -target %target-cpu-apple-macosx10.12 %S/Inputs/custom-resource-stdlib.swift -o %t/custom-resource-dir/macosx/Swift.swiftmodule/%target-swiftmodule-name +// RUN: %sourcekitd-test -req=cursor -pos=3:8 %s -- -resource-dir %t/custom-resource-dir -target %target-cpu-apple-macosx10.12 %s | %FileCheck %s // CHECK: source.lang.swift.ref.struct // CHECK-NEXT: CoolInt diff --git a/test/api-digester/compare-two-sdks.swift b/test/api-digester/compare-two-sdks.swift index f33596a0025c5..a95e7fbcd7755 100644 --- a/test/api-digester/compare-two-sdks.swift +++ b/test/api-digester/compare-two-sdks.swift @@ -5,7 +5,7 @@ // RUN: %empty-directory(%t.sdk) // RUN: %empty-directory(%t.module-cache) -// RUN: %api-digester -diagnose-sdk -print-module -module-list-file %S/Inputs/mock-sdk-modules.txt -sdk %S/Inputs/mock-sdk.sdk -bsdk %S/Inputs/mock-sdk-baseline.sdk -module-cache-path %t.module-cache -o %t.result -abort-on-module-fail -target x86_64-apple-macos10.14 +// RUN: %api-digester -diagnose-sdk -print-module -module-list-file %S/Inputs/mock-sdk-modules.txt -sdk %S/Inputs/mock-sdk.sdk -bsdk %S/Inputs/mock-sdk-baseline.sdk -module-cache-path %t.module-cache -o %t.result -abort-on-module-fail -target %target-cpu-apple-macos10.14 // RUN: %clang -E -P -x c %S/Outputs/mock-sdk-api.txt -o - | sed '/^\s*$/d' > %t.expected // RUN: %clang -E -P -x c %t.result -o - | sed '/^\s*$/d' > %t.result.tmp diff --git a/test/decl/protocol/conforms/nscoding_availability_osx.swift b/test/decl/protocol/conforms/nscoding_availability_osx.swift index 90fced355f7cc..31fb24e90eb6c 100644 --- a/test/decl/protocol/conforms/nscoding_availability_osx.swift +++ b/test/decl/protocol/conforms/nscoding_availability_osx.swift @@ -1,6 +1,6 @@ -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -target x86_64-apple-macosx10.50 -verify +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -target %target-cpu-apple-macosx10.50 -verify -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -target x86_64-apple-macosx10.50 -dump-ast > %t.ast +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -target %target-cpu-apple-macosx10.50 -dump-ast > %t.ast // RUN: %FileCheck %s < %t.ast // REQUIRES: objc_interop diff --git a/test/stdlib/DispatchDeprecationMacOS.swift b/test/stdlib/DispatchDeprecationMacOS.swift index 04440f6f316d7..834a50f303ca3 100644 --- a/test/stdlib/DispatchDeprecationMacOS.swift +++ b/test/stdlib/DispatchDeprecationMacOS.swift @@ -1,4 +1,4 @@ -// RUN: %swift -typecheck -target x86_64-apple-macosx10.9 -verify -sdk %sdk %s +// RUN: %swift -typecheck -target %target-cpu-apple-macosx10.9 -verify -sdk %sdk %s // REQUIRES: OS=macosx // REQUIRES: libdispatch From e24f7df268c70788266848ee4a2c550e9be1c078 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:28:41 -0700 Subject: [PATCH 05/35] [Apple Silicon] Mark macOS tests that require x86_64 --- test/ClangImporter/CoreGraphics_test.swift | 1 + test/DebugInfo/ASTSection_linker.swift | 1 + test/IDE/print_clang_header_i386.swift | 1 + test/ModuleInterface/NoWrongSDKWarning.swiftinterface | 1 + 4 files changed, 4 insertions(+) diff --git a/test/ClangImporter/CoreGraphics_test.swift b/test/ClangImporter/CoreGraphics_test.swift index 017265f52a220..ef16031857079 100644 --- a/test/ClangImporter/CoreGraphics_test.swift +++ b/test/ClangImporter/CoreGraphics_test.swift @@ -4,6 +4,7 @@ import CoreGraphics // REQUIRES: OS=macosx +// REQUIRES: CPU=x86_64 // CHECK: [[SWITCHTABLE:@.*]] = private unnamed_addr constant [8 x i64] [i64 0, i64 12, i64 23, i64 34, i64 45, i64 55, i64 67, i64 71] diff --git a/test/DebugInfo/ASTSection_linker.swift b/test/DebugInfo/ASTSection_linker.swift index 7fbf987b8ad0f..90d4a849c97b9 100644 --- a/test/DebugInfo/ASTSection_linker.swift +++ b/test/DebugInfo/ASTSection_linker.swift @@ -14,6 +14,7 @@ // RUN: %lldb-moduleimport-test -verbose %t/ASTSection.dylib | %FileCheck %s // REQUIRES: OS=macosx +// REQUIRES: CPU=x86_64 // CHECK: - Swift Version: {{.+}}.{{.+}} // CHECK: - Compatibility Version: 4 diff --git a/test/IDE/print_clang_header_i386.swift b/test/IDE/print_clang_header_i386.swift index 5f514182ce9fb..4774771e3fb83 100644 --- a/test/IDE/print_clang_header_i386.swift +++ b/test/IDE/print_clang_header_i386.swift @@ -1,4 +1,5 @@ // REQUIRES: OS=macosx +// REQUIRES: CPU=x86_64 // FIXME: rdar://problem/19648117 Needs splitting objc parts out // XFAIL: linux, freebsd diff --git a/test/ModuleInterface/NoWrongSDKWarning.swiftinterface b/test/ModuleInterface/NoWrongSDKWarning.swiftinterface index 61b7f7fde6708..6918b235f91a4 100644 --- a/test/ModuleInterface/NoWrongSDKWarning.swiftinterface +++ b/test/ModuleInterface/NoWrongSDKWarning.swiftinterface @@ -6,6 +6,7 @@ // RUN: %swift -sdk %sdk -target arm64-apple-ios10 -compile-module-from-interface %s -o %t/NoWrongSDKWarning.swiftmodule 2>&1 | %FileCheck -allow-empty %s // REQUIRES: OS=macosx +// REQUIRES: CPU=x86_64 public func empty() From 6c183c891e39c0983454a16bb4cafc5589887cc6 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:40:16 -0700 Subject: [PATCH 06/35] [Apple Silicon] [Build] Generalize macOS architecture check --- .../swift_build_support/host_specific_configuration.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/swift_build_support/swift_build_support/host_specific_configuration.py b/utils/swift_build_support/swift_build_support/host_specific_configuration.py index ad50abbac5213..6a407a06a7b65 100644 --- a/utils/swift_build_support/swift_build_support/host_specific_configuration.py +++ b/utils/swift_build_support/swift_build_support/host_specific_configuration.py @@ -10,6 +10,7 @@ # # ---------------------------------------------------------------------------- +import re import sys from argparse import ArgumentError @@ -155,11 +156,13 @@ def __init__(self, host_target, args): # Support for running the macCatalyst tests with # the iOS-like target triple. - if name == "macosx-x86_64" and args.maccatalyst \ + macosx_platform_match = re.search("macosx-(.*)", name) + if macosx_platform_match and args.maccatalyst \ and args.maccatalyst_ios_tests: (self.swift_test_run_targets - .append("check-swift{}{}-{}".format( - subset_suffix, suffix, "macosx-maccatalyst-x86_64"))) + .append("check-swift{}{}-{}-{}".format( + subset_suffix, suffix, "macosx-maccatalyst", + macosx_platform_match.group(1)))) else: (self.swift_test_run_targets .append("check-swift{}{}-{}".format( From 76c5fac24ed8cbe30bf34b788faa6e57e979782f Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:41:01 -0700 Subject: [PATCH 07/35] [Apple Silicon] [ObjectiveC Overlay] ObjCBool is C _Bool on arm64 macOS. --- stdlib/public/Darwin/ObjectiveC/ObjectiveC.swift | 6 +++--- test/IRGen/Inputs/ObjectiveC.swift | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/public/Darwin/ObjectiveC/ObjectiveC.swift b/stdlib/public/Darwin/ObjectiveC/ObjectiveC.swift index e127f4366329e..0204b2cee461d 100644 --- a/stdlib/public/Darwin/ObjectiveC/ObjectiveC.swift +++ b/stdlib/public/Darwin/ObjectiveC/ObjectiveC.swift @@ -25,8 +25,8 @@ import ObjectiveC /// ObjCBool. @frozen public struct ObjCBool : ExpressibleByBooleanLiteral { -#if os(macOS) || (os(iOS) && (arch(i386) || arch(arm))) - // On OS X and 32-bit iOS, Objective-C's BOOL type is a "signed char". +#if (os(macOS) && arch(x86_64)) || (os(iOS) && (arch(i386) || arch(arm))) + // On Intel OS X and 32-bit iOS, Objective-C's BOOL type is a "signed char". @usableFromInline var _value: Int8 @_transparent @@ -52,7 +52,7 @@ public struct ObjCBool : ExpressibleByBooleanLiteral { /// The value of `self`, expressed as a `Bool`. @_transparent public var boolValue: Bool { -#if os(macOS) || (os(iOS) && (arch(i386) || arch(arm))) +#if (os(macOS) && arch(x86_64)) || (os(iOS) && (arch(i386) || arch(arm))) return _value != 0 #else return _value diff --git a/test/IRGen/Inputs/ObjectiveC.swift b/test/IRGen/Inputs/ObjectiveC.swift index 2a21acf99b142..f455271717cab 100644 --- a/test/IRGen/Inputs/ObjectiveC.swift +++ b/test/IRGen/Inputs/ObjectiveC.swift @@ -2,7 +2,8 @@ @_exported import ObjectiveC public struct ObjCBool : CustomStringConvertible { -#if os(macOS) || (os(iOS) && (arch(i386) || arch(arm))) +#if (os(macOS) && arch(x86_64)) || (os(iOS) && (arch(i386) || arch(arm) || targetEnvironment(macCatalyst))) + // On macOS and 32-bit iOS, Objective-C's BOOL type is a "signed char". private var value: Int8 From 16110be07b365e31a7fb5e0607057e2e3c06a178 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 16:42:15 -0700 Subject: [PATCH 08/35] [Apple Silicon] Baseline arm64 macOS at Swift 5.3 / macOS 10.16 --- lib/AST/Availability.cpp | 12 ++++++++++++ lib/Basic/Platform.cpp | 3 +++ lib/Driver/DarwinToolChains.cpp | 8 ++++++++ test/Driver/linker.swift | 3 +++ ...autolink-runtime-compatibility-arm64-macos.swift | 13 +++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 test/IRGen/autolink-runtime-compatibility-arm64-macos.swift diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index 7eacce69db72e..5210350f39616 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -246,6 +246,9 @@ AvailabilityContext ASTContext::getSwift50Availability() { return AvailabilityContext::alwaysAvailable(); if (target.isMacOSX()) { + if (target.isAArch64()) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10,14,4))); } else if (target.isiOS()) { @@ -274,6 +277,9 @@ AvailabilityContext ASTContext::getSwift51Availability() { return AvailabilityContext::alwaysAvailable(); if (target.isMacOSX()) { + if (target.isAArch64()) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10,15,0))); } else if (target.isiOS()) { @@ -302,6 +308,9 @@ AvailabilityContext ASTContext::getSwift52Availability() { return AvailabilityContext::alwaysAvailable(); if (target.isMacOSX() ) { + if (target.isAArch64()) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); } else if (target.isiOS()) { @@ -322,6 +331,9 @@ AvailabilityContext ASTContext::getSwift53Availability() { return AvailabilityContext::alwaysAvailable(); if (target.isMacOSX() ) { + if (target.isAArch64()) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); } else if (target.isiOS()) { diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 9f46b1785a548..91c22b17231d2 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -387,6 +387,9 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget( if (Triple.isMacOSX()) { Triple.getMacOSXVersion(Major, Minor, Micro); if (Major == 10) { + if (Triple.isAArch64() && Minor <= 16) + return llvm::VersionTuple(5, 3); + if (Minor <= 14) { return llvm::VersionTuple(5, 0); } else if (Minor <= 15) { diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index bfd3bd442d3cc..af43ce9299692 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -602,6 +602,14 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, switch (getDarwinPlatformKind((triple))) { case DarwinPlatformKind::MacOS: triple.getMacOSXVersion(major, minor, micro); + + // The first deployment of arm64 for macOS is version 10.16; + if (triple.isAArch64() && major <= 10 && minor < 16) { + major = 10; + minor = 16; + micro = 0; + } + break; case DarwinPlatformKind::IPhoneOS: case DarwinPlatformKind::IPhoneOSSimulator: diff --git a/test/Driver/linker.swift b/test/Driver/linker.swift index 1c47aa6f420cd..1f2ce629089bf 100644 --- a/test/Driver/linker.swift +++ b/test/Driver/linker.swift @@ -106,6 +106,9 @@ // RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -sdk %S/Inputs/MacOSX10.15.4.versioned.sdk %s 2>&1 | %FileCheck -check-prefix MACOS_10_15_4 %s // RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -sdk %S/Inputs/MacOSX10.15.sdk %s 2>&1 | %FileCheck -check-prefix MACOS_UNVERSIONED %s +// Check arm64 macOS first deployment version adjustment. +// RUN: %swiftc_driver -driver-print-jobs -target arm64-apple-macosx10.15.1 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s + // MACOS_10_15: -platform_version macos 10.9.0 10.15.0 // MACOS_10_15_4: -platform_version macos 10.9.0 10.15.4 // MACOS_UNVERSIONED: -platform_version macos 10.9.0 0.0.0 diff --git a/test/IRGen/autolink-runtime-compatibility-arm64-macos.swift b/test/IRGen/autolink-runtime-compatibility-arm64-macos.swift new file mode 100644 index 0000000000000..48e9c61955e44 --- /dev/null +++ b/test/IRGen/autolink-runtime-compatibility-arm64-macos.swift @@ -0,0 +1,13 @@ +// REQUIRES: CPU=arm64,OS=macosx + +// Doesn't autolink compatibility library because target OS doesn't need it +// RUN: %target-swift-frontend -target arm64-apple-macosx10.14 -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s + +public func foo() {} + +// NO-FORCE-LOAD-NOT: FORCE_LOAD +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility50"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility51"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility52"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility53"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibilityDynamicReplacements"} From 7c942165459ebef3474bf016dabe8dac37b8f55f Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 17:56:54 -0700 Subject: [PATCH 09/35] [Apple Silicon] [Test] Fix various IRGen tests for arm64 macOS --- test/IRGen/abitypes.swift | 19 ++++++++++++- ...al_conformances_gettypemetdatabyname.swift | 4 +-- test/IRGen/metadata.swift | 2 +- test/IRGen/objc_properties.swift | 10 +++---- .../opaque_result_type_availability.swift | 2 +- .../swift-modules/ObjectiveC.swift | 27 ++++++++----------- test/TBD/app-extension.swift | 2 +- 7 files changed, 39 insertions(+), 27 deletions(-) diff --git a/test/IRGen/abitypes.swift b/test/IRGen/abitypes.swift index b8f920752c6ef..bc851923ce21a 100644 --- a/test/IRGen/abitypes.swift +++ b/test/IRGen/abitypes.swift @@ -17,6 +17,7 @@ import Foundation // arm64e-ios: [[ARM64E_MYRECT:%.*]] = type { float, float, float, float } // arm64-tvos: [[ARM64_MYRECT:%.*]] = type { float, float, float, float } // armv7k-watchos: [[ARMV7K_MYRECT:%.*]] = type { float, float, float, float } +// arm64-macosx: [[ARM64E_MYRECT:%.*]] = type { float, float, float, float } class Foo { // x86_64-macosx: define hidden swiftcc { float, float, float, float } @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}F"(%T8abitypes3FooC* swiftself %0) {{.*}} { @@ -428,7 +429,12 @@ class Foo { // armv7k-watchos: [[TOOBJCBOOL:%[0-9]+]] = call swiftcc i1 @"$s10ObjectiveC22_convertBoolToObjCBool{{[_0-9a-zA-Z]*}}F"(i1 [[NEG]]) // armv7k-watchos: ret i1 [[TOOBJCBOOL]] // - @objc dynamic func negate2(_ b: Bool) -> Bool { + + // arm64-macosx: define hidden zeroext i1 @"$s8abitypes3FooC7negate2{{[_0-9a-zA-Z]*}}FTo"(i8* %0, i8* %1, i1 zeroext %2) + // arm64-macosx: [[NEG:%[0-9]+]] = call swiftcc i1 @"$s8abitypes3FooC7negate2{{[_0-9a-zA-Z]*}}F"(i1 + // arm64-macosx: [[TOOBJCBOOL:%[0-9]+]] = call swiftcc i1 @"$s10ObjectiveC22_convertBoolToObjCBool{{[_0-9a-zA-Z]*}}F"(i1 [[NEG]]) + // arm64-macosx: ret i1 [[TOOBJCBOOL]] +@objc dynamic func negate2(_ b: Bool) -> Bool { var g = Gadget() return g.negate(b) } @@ -532,6 +538,8 @@ class Foo { // // arm64-tvos: define hidden swiftcc { i64, i64, i64, i64 } @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}F"(%TSo13StructReturnsC* %0, i64 %1, i64 %2, i64 %3, i64 %4, %T8abitypes3FooC* swiftself %5) {{.*}} { // arm64-tvos: define hidden void @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}FTo"(%TSo9BigStructV* noalias nocapture sret %0, i8* %1, i8* %2, [[OPAQUE:.*]]* %3, %TSo9BigStructV* %4) {{[#0-9]*}} { + // arm64-macosx: define hidden swiftcc { i64, i64, i64, i64 } @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}F"(%TSo13StructReturnsC* %0, i64 %1, i64 %2, i64 %3, i64 %4, %T8abitypes3FooC* swiftself %5) {{.*}} { + // arm64-macosx: define hidden void @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}FTo"(%TSo9BigStructV* noalias nocapture sret %0, i8* %1, i8* %2, [[OPAQUE:.*]]* %3, %TSo9BigStructV* %4) {{.*}} { @objc dynamic func callJustReturn(_ r: StructReturns, with v: BigStruct) -> BigStruct { return r.justReturn(v) } @@ -585,6 +593,15 @@ public func testInlineAgg(_ rect: MyRect) -> Float { // arm64e-ios: store i1 false, i1* [[PTR2]], align 8 // arm64e-ios: [[ARG:%.*]] = load i64, i64* [[COERCED]] // arm64e-ios: call void bitcast (void ()* @objc_msgSend to void (i8*, i8*, i64)*)(i8* {{.*}}, i8* {{.*}}, i64 [[ARG]]) +// arm64-macosx: define swiftcc void @"$s8abitypes14testBOOLStructyyF"() +// arm64-macosx: [[COERCED:%.*]] = alloca i64 +// arm64-macosx: [[STRUCTPTR:%.*]] = bitcast i64* [[COERCED]] to %TSo14FiveByteStructV +// arm64-macosx: [[PTR0:%.*]] = getelementptr inbounds %TSo14FiveByteStructV, %TSo14FiveByteStructV* [[STRUCTPTR]], {{i.*}} 0, {{i.*}} 0 +// arm64-macosx: [[PTR1:%.*]] = getelementptr inbounds %T10ObjectiveC8ObjCBoolV, %T10ObjectiveC8ObjCBoolV* [[PTR0]], {{i.*}} 0, {{i.*}} 0 +// arm64-macosx: [[PTR2:%.*]] = getelementptr inbounds %TSb, %TSb* [[PTR1]], {{i.*}} 0, {{i.*}} 0 +// arm64-macosx: store i1 false, i1* [[PTR2]], align 8 +// arm64-macosx: [[ARG:%.*]] = load i64, i64* [[COERCED]] +// arm64-macosx: call void bitcast (void ()* @objc_msgSend to void (i8*, i8*, i64)*)(i8* {{.*}}, i8* {{.*}}, i64 [[ARG]]) public func testBOOLStruct() { let s = FiveByteStruct() MyClass.mymethod(s) diff --git a/test/IRGen/conditional_conformances_gettypemetdatabyname.swift b/test/IRGen/conditional_conformances_gettypemetdatabyname.swift index 7ab1f91295f61..28a2a50597f3d 100644 --- a/test/IRGen/conditional_conformances_gettypemetdatabyname.swift +++ b/test/IRGen/conditional_conformances_gettypemetdatabyname.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -target x86_64-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME -// RUN: %target-swift-frontend -prespecialize-generic-metadata -target x86_64-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME_PRESPECIALIZED +// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -target %target-cpu-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME +// RUN: %target-swift-frontend -prespecialize-generic-metadata -target %target-cpu-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME_PRESPECIALIZED // Too many pointer-sized integers in the IR // REQUIRES: PTRSIZE=64 diff --git a/test/IRGen/metadata.swift b/test/IRGen/metadata.swift index f838c4e1f43b4..54fbd30a6d31a 100644 --- a/test/IRGen/metadata.swift +++ b/test/IRGen/metadata.swift @@ -10,7 +10,7 @@ enum Singleton { // CHECK: @"$s1A1GC14zeroSizedFieldAA9SingletonOvpWvd" = hidden constant i{{(64|32)}} 0 // Check that the instance start is after the header (at 8 or 16). -// CHECK-macosx: _DATA__TtC1A1G = private constant {{.*}} { i32 128, i32 {{(16|8)}} +// CHECK-macosx: _DATA__TtC1A1G = private constant {{.*}} { i32 {{(128|129)}}, i32 {{(16|8|40)}} // CHECK-ios: _DATA__TtC1A1G = private constant {{.*}} { i32 {{(128|129)}}, i32 {{(16|8|40)}} // CHECK-watchos: _DATA__TtC1A1G = private constant {{.*}} { i32 128, i32 {{(16|8)}} // CHECK-tvos: _DATA__TtC1A1G = private constant {{.*}} { i32 128, i32 {{(16|8)}} diff --git a/test/IRGen/objc_properties.swift b/test/IRGen/objc_properties.swift index b79e20b0e9187..48a5ec69bc786 100644 --- a/test/IRGen/objc_properties.swift +++ b/test/IRGen/objc_properties.swift @@ -118,7 +118,7 @@ class SomeWrapperTests { // CHECK-SAME: i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}}, // CHECK-SAME: i8* null, // CHECK-SAME: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0), -// CHECK-SAME: { {{.+}} }* @_CLASS_METHODS__TtC15objc_properties10SomeObject, +// CHECK-SAME: { {{.+}} }* @_CLASS_METHODS__TtC15objc_properties10SomeObject{{(\.ptrauth)?}} // CHECK-SAME: i8* null, i8* null, i8* null, // CHECK-NEW-SAME: { {{.+}} }* @_CLASS_PROPERTIES__TtC15objc_properties10SomeObject // CHECK-OLD-SAME: i8* null @@ -201,7 +201,7 @@ class SomeWrapperTests { // CHECK: i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}}, // CHECK: i8* null, // CHECK: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0), -// CHECK: { {{.+}} }* @_INSTANCE_METHODS__TtC15objc_properties10SomeObject, +// CHECK: { {{.+}} }* @_INSTANCE_METHODS__TtC15objc_properties10SomeObject{{(\.ptrauth)?}} // CHECK: i8* null, // CHECK: { {{.+}} }* @_IVARS__TtC15objc_properties10SomeObject, // CHECK: i8* null, @@ -251,10 +251,10 @@ class SomeWrapperTests { // CHECK: @"_CATEGORY__TtC15objc_properties10SomeObject_$_objc_properties" = private constant { {{.+}} } { // CHECK: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0), // CHECK: %swift.type* bitcast (i64* getelementptr inbounds (<{ {{.+}} }>* @"$s15objc_properties10SomeObjectCMf", i32 0, i32 2) to %swift.type*), -// CHECK: { {{.+}} }* @"_CATEGORY_INSTANCE_METHODS__TtC15objc_properties10SomeObject_$_objc_properties", -// CHECK: { {{.+}} }* @"_CATEGORY_CLASS_METHODS__TtC15objc_properties10SomeObject_$_objc_properties", +// CHECK: { {{.+}} }* @"_CATEGORY_INSTANCE_METHODS__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}" +// CHECK: { {{.+}} }* @"_CATEGORY_CLASS_METHODS__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}" // CHECK: i8* null, -// CHECK: { {{.+}} }* @"_CATEGORY_PROPERTIES__TtC15objc_properties10SomeObject_$_objc_properties", +// CHECK: { {{.+}} }* @"_CATEGORY_PROPERTIES__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}", // CHECK-NEW: { {{.+}} }* @"_CATEGORY_CLASS_PROPERTIES__TtC15objc_properties10SomeObject_$_objc_properties", // CHECK-OLD: i8* null, // CHECK: i32 60 diff --git a/test/IRGen/opaque_result_type_availability.swift b/test/IRGen/opaque_result_type_availability.swift index db522568ffc18..06d7e6d245e82 100644 --- a/test/IRGen/opaque_result_type_availability.swift +++ b/test/IRGen/opaque_result_type_availability.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.9 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s +// RUN: %target-swift-frontend -enable-implicit-dynamic -target x86_64-apple-macosx10.9 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s // RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.15 -Onone -emit-ir %s | %FileCheck --check-prefix=ALWAYS-AVAILABLE %s // REQUIRES: OS=macosx diff --git a/test/Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift b/test/Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift index f56fd986c4460..278fb9d340760 100644 --- a/test/Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift +++ b/test/Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift @@ -2,38 +2,33 @@ // The iOS/arm64 target uses _Bool for Objective-C's BOOL. We include // x86_64 here as well because the iOS simulator also uses _Bool. -#if ((os(iOS) || os(tvOS)) && (arch(arm64) || arch(x86_64))) || os(watchOS) public struct ObjCBool { - private var value : Bool +#if (os(macOS) && arch(x86_64)) || (os(iOS) && (arch(i386) || arch(arm) || targetEnvironment(macCatalyst))) + + // On macOS and 32-bit iOS, Objective-C's BOOL type is a "signed char". + private var value: UInt8 public init(_ value: Bool) { - self.value = value + self.value = value ? 1 : 0 } + /// Allow use in a Boolean context. public var boolValue: Bool { - return value + return value != 0 } -} - #else - -public struct ObjCBool { - private var value : UInt8 + // Everywhere else it is C/C++'s "Bool" + private var value: Bool public init(_ value: Bool) { - self.value = value ? 1 : 0 - } - - public init(_ value: UInt8) { self.value = value } public var boolValue: Bool { - if value == 0 { return false } - return true + return value } -} #endif +} extension ObjCBool : ExpressibleByBooleanLiteral { public init(booleanLiteral: Bool) { diff --git a/test/TBD/app-extension.swift b/test/TBD/app-extension.swift index 9fe43bb68ac99..8bdf74b852d51 100644 --- a/test/TBD/app-extension.swift +++ b/test/TBD/app-extension.swift @@ -9,7 +9,7 @@ // EXTENSIONSAFE-NOT: not_app_extension_safe // NOTEXTENSIONSAFE: not_app_extension_safe -// RUN: %target-swift-frontend -target-variant x86_64-apple-ios13.0-macabi -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/target-variant.tbd +// RUN: %target-swift-frontend -target-variant %target-cpu-apple-ios13.0-macabi -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/target-variant.tbd // RUN: %FileCheck %s --check-prefix MACABI < %t/target-variant.tbd // MACABI: targets: [ {{.*}}macos{{.*}}maccatalyst{{.*}} ] From 781aa53ddda387d10b273cb9f06199a844918c97 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 17:57:59 -0700 Subject: [PATCH 10/35] [Apple Silicon] [Test] Generalize api-digester tests for Apple Silicon macOS. Most of this is enabled by an upstream change to generalize the tests for the api-digester to properly handle all targets. The primary change here is to account for the Swift-level ABI differences for the standard library between Apple Silicon macOS and Intel macOS. Specifically, anything related to Float80 will be removed from the standard library on Apple Silicon macOS, so account for the differences. --- .../arm64-apple-macos.swiftinterface | 7 +++++ .../arm64-apple-macos.swiftinterface | 7 +++++ ...ability-stdlib-source-arm64.swift.expected | 27 +++++++++++++++++++ ...ility-stdlib-source-x86_64.swift.expected} | 0 .../stability-stdlib-source.swift | 2 +- 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/api-digester/Inputs/mock-sdk-baseline.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface create mode 100644 test/api-digester/Inputs/mock-sdk.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface create mode 100644 test/api-digester/Outputs/stability-stdlib-source-arm64.swift.expected rename test/api-digester/Outputs/{stability-stdlib-source.swift.expected => stability-stdlib-source-x86_64.swift.expected} (100%) diff --git a/test/api-digester/Inputs/mock-sdk-baseline.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface b/test/api-digester/Inputs/mock-sdk-baseline.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface new file mode 100644 index 0000000000000..04fba0eeed4da --- /dev/null +++ b/test/api-digester/Inputs/mock-sdk-baseline.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface @@ -0,0 +1,7 @@ +// swift-interface-format-version: 1.0 +// swift-tools-version: Apple Swift version 5.1 (swiftlang-1100.0.38 clang-1100.0.20.14) +// swift-module-flags: -target arm64-apple-macos10.14 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name SwiftFoo +import Swift +public class RemovedClass { + @objc deinit +} diff --git a/test/api-digester/Inputs/mock-sdk.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface b/test/api-digester/Inputs/mock-sdk.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface new file mode 100644 index 0000000000000..606b8bd222422 --- /dev/null +++ b/test/api-digester/Inputs/mock-sdk.sdk/System/Library/Frameworks/SwiftFoo.framework/Modules/SwiftFoo.swiftmodule/arm64-apple-macos.swiftinterface @@ -0,0 +1,7 @@ +// swift-interface-format-version: 1.0 +// swift-tools-version: Apple Swift version 5.1 (swiftlang-1100.0.38 clang-1100.0.20.14) +// swift-module-flags: -target arm64-apple-macos10.14 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name SwiftFoo +import Swift +public class AddedClass { + @objc deinit +} diff --git a/test/api-digester/Outputs/stability-stdlib-source-arm64.swift.expected b/test/api-digester/Outputs/stability-stdlib-source-arm64.swift.expected new file mode 100644 index 0000000000000..902afdfd72c19 --- /dev/null +++ b/test/api-digester/Outputs/stability-stdlib-source-arm64.swift.expected @@ -0,0 +1,27 @@ +Constructor BinaryFloatingPoint.init(_:) has been removed +Constructor Double.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Double.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Float.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Float.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int16.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int16.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int32.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int32.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int64.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int64.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int8.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor Int8.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt16.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt16.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt32.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt32.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt64.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt64.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt8.init(_:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Constructor UInt8.init(exactly:) has parameter 0 type change from Swift.Float80 to Swift.Float16 +Struct Float80 has been removed +TypeAlias CLongDouble has underlying type change from Swift.Float80 to Swift.Double diff --git a/test/api-digester/Outputs/stability-stdlib-source.swift.expected b/test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected similarity index 100% rename from test/api-digester/Outputs/stability-stdlib-source.swift.expected rename to test/api-digester/Outputs/stability-stdlib-source-x86_64.swift.expected diff --git a/test/api-digester/stability-stdlib-source.swift b/test/api-digester/stability-stdlib-source.swift index 32934342910d4..f0e383a5cc2c2 100644 --- a/test/api-digester/stability-stdlib-source.swift +++ b/test/api-digester/stability-stdlib-source.swift @@ -2,6 +2,6 @@ // RUN: %empty-directory(%t.tmp) // mkdir %t.tmp/module-cache && mkdir %t.tmp/dummy.sdk // RUN: %api-digester -diagnose-sdk -module Swift -o %t.tmp/changes.txt -module-cache-path %t.tmp/module-cache -sdk %t.tmp/dummy.sdk -avoid-location -// RUN: %clang -E -P -x c %S/Outputs/stability-stdlib-source.swift.expected -o - | sed '/^\s*$/d' | sort > %t.tmp/stability-stdlib-source.swift.expected +// RUN: %clang -E -P -x c %S/Outputs/stability-stdlib-source-%target-cpu.swift.expected -o - | sed '/^\s*$/d' | sort > %t.tmp/stability-stdlib-source.swift.expected // RUN: %clang -E -P -x c %t.tmp/changes.txt -o - | sed '/^\s*$/d' | sort > %t.tmp/changes.txt.tmp // RUN: diff -u %t.tmp/stability-stdlib-source.swift.expected %t.tmp/changes.txt.tmp From 885ef363b9c897807c31671b4919c4c9dff86e7e Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:03:39 -0700 Subject: [PATCH 11/35] [Apple Silicon] Support building for macOS arm64/arm64e --- cmake/modules/DarwinSDKs.cmake | 2 +- utils/build-script-impl | 25 ++++++++++++++++++- .../swift_build_support/targets.py | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cmake/modules/DarwinSDKs.cmake b/cmake/modules/DarwinSDKs.cmake index 23fa42a9bd43e..6a9e4ef3a4040 100644 --- a/cmake/modules/DarwinSDKs.cmake +++ b/cmake/modules/DarwinSDKs.cmake @@ -14,7 +14,7 @@ set(SUPPORTED_TVOS_ARCHS "arm64") set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64") set(SUPPORTED_WATCHOS_ARCHS "armv7k") set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386") -set(SUPPORTED_OSX_ARCHS "x86_64") +set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e") is_sdk_requested(OSX swift_build_osx) if(swift_build_osx) diff --git a/utils/build-script-impl b/utils/build-script-impl index 948585dc5882f..adef067e66baf 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -416,6 +416,8 @@ function verify_host_is_supported() { | linux-powerpc64le \ | linux-s390x \ | macosx-x86_64 \ + | macosx-arm64 \ + | macosx-arm64e \ | iphonesimulator-i386 \ | iphonesimulator-x86_64 \ | iphoneos-armv7 \ @@ -493,6 +495,24 @@ function set_build_options_for_host() { SWIFT_HOST_VARIANT_SDK="OSX" cmake_osx_deployment_target="${DARWIN_DEPLOYMENT_VERSION_OSX}" ;; + macosx-arm64) + xcrun_sdk_name="macosx" + llvm_target_arch="AArch64" + SWIFT_HOST_TRIPLE="arm64-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}" + SWIFT_HOST_VARIANT="macosx" + SWIFT_HOST_VARIANT_SDK="OSX" + SWIFT_HOST_VARIANT_ARCH="arm64" + cmake_osx_deployment_target="${DARWIN_DEPLOYMENT_VERSION_OSX}" + ;; + macosx-arm64e) + xcrun_sdk_name="macosx" + llvm_target_arch="AArch64" + SWIFT_HOST_TRIPLE="arm64e-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}" + SWIFT_HOST_VARIANT="macosx" + SWIFT_HOST_VARIANT_SDK="OSX" + SWIFT_HOST_VARIANT_ARCH="arm64e" + cmake_osx_deployment_target="${DARWIN_DEPLOYMENT_VERSION_OSX}" + ;; iphonesimulator-i386) SWIFT_HOST_TRIPLE="i386-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator" llvm_target_arch="X86" @@ -920,7 +940,7 @@ function false_true() { CROSS_COMPILE_HOSTS=($CROSS_COMPILE_HOSTS) for t in "${CROSS_COMPILE_HOSTS[@]}"; do case ${t} in - iphone* | appletv* | watch* | linux-armv6 | linux-armv7 ) + macosx-arm64* | iphone* | appletv* | watch* | linux-armv6 | linux-armv7 ) ;; *) echo "Unknown host to cross-compile for: ${t}" @@ -1187,6 +1207,9 @@ function common_cross_c_flags() { local arch=${host##*-} case $host in + macosx-*) + echo -n " -arch ${arch} " + ;; iphonesimulator-*) echo -n " -arch ${arch} -mios-simulator-version-min=${DARWIN_DEPLOYMENT_VERSION_IOS}" ;; diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 9cb31c6dfe8a4..973c2ccc69e2a 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -114,7 +114,7 @@ def name(self): class StdlibDeploymentTarget(object): - OSX = DarwinPlatform("macosx", archs=["x86_64"], + OSX = DarwinPlatform("macosx", archs=["x86_64", "arm64", "arm64e"], sdk_name="OSX") iOS = DarwinPlatform("iphoneos", archs=["armv7", "armv7s", "arm64", "arm64e"], From 3b7495172483cd33391359fbd52c17b1aeaf5f0f Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:13:16 -0700 Subject: [PATCH 12/35] [Apple Silicon] [build-script] Support stdlib macOS arm64/arm64e --- utils/swift_build_support/swift_build_support/targets.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 973c2ccc69e2a..576d675832bd8 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -219,6 +219,10 @@ def host_target(): elif system == 'Darwin': if machine == 'x86_64': return StdlibDeploymentTarget.OSX.x86_64 + elif machine == 'arm64': + return StdlibDeploymentTarget.OSX.arm64 + elif machine == 'arm64e': + return StdlibDeploymentTarget.OSX.arm64e elif system == 'FreeBSD': if machine == 'amd64': From d84da25af48135137f79ad4aaf4a4733a594fc9a Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:13:56 -0700 Subject: [PATCH 13/35] [Apple Silicon] Use SWIFT_CROSS_COMPILING to use build-time tools (tblgen) from the native build --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c334534250777..df33c4569f314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -462,6 +462,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD) endif() message(STATUS "") +if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "") + set(SWIFT_CROSS_COMPILING FALSE) +else() + set(SWIFT_CROSS_COMPILING TRUE) +endif() + include(SwiftSharedCMakeConfig) # NOTE: We include this before SwiftComponents as it relies on some LLVM CMake From 676b9af7246a7033fcbe70902a46196fc5f8e9b7 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:14:39 -0700 Subject: [PATCH 14/35] [Apple Silicon] Don't set native llvm tools path when cross compiling swift --- cmake/modules/SwiftSharedCMakeConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/SwiftSharedCMakeConfig.cmake b/cmake/modules/SwiftSharedCMakeConfig.cmake index 5bddf37d86816..c4c15084fe902 100644 --- a/cmake/modules/SwiftSharedCMakeConfig.cmake +++ b/cmake/modules/SwiftSharedCMakeConfig.cmake @@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product) fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS}") endif() - if(NOT CMAKE_CROSSCOMPILING) + if(NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING) set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}") endif() From b850bc67f6787fbf2d81531da1e6a167fd867e7a Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:22:04 -0700 Subject: [PATCH 15/35] [Apple Silicon] [build-script] Build compiler-rt even when cross-compiling clang and compiler-rt are rev-locked and should match. Currently, we build clang (and use it to bootstrap the rest) but don't build compiler-rt. We should. This doesn't completely achieve that: this only makes us build compiler-rt for the local host. This used to be pretty much impossible, but, since then, compiler-rt cmake support was rewritten. We should build it for the other hosts as well, but that's trickier, because we'd need to make the cross-compiled compiler-rt build use a separate just-built clang (from the local host). We do that for the other projects, but compiler-rt is special (because it's cmake'd as a runtime part of clang/llvm). --- utils/build-script-impl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index adef067e66baf..f7aeef172e4eb 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -649,10 +649,19 @@ function set_build_options_for_host() { esac - llvm_cmake_options+=( - -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})" - -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})" - ) + # We don't currently support building compiler-rt for cross-compile targets. + # It's not clear that's useful anyway. + if is_cross_tools_host "${host}"; then + llvm_cmake_options+=( + -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=FALSE + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=FALSE + ) + else + llvm_cmake_options+=( + -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})" + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})" + ) + fi # If we are asked to not generate test targets for LLVM and or Swift, # disable as many LLVM tools as we can. This improves compile time when @@ -861,11 +870,6 @@ if [[ "${CMAKE_GENERATOR}" == "Xcode" ]]; then SKIP_BUILD_COMPILER_RT=1 fi -# FIXME: We currently do not support cross-compiling swift with compiler-rt. -if [[ "${CROSS_COMPILE_HOSTS}" ]]; then - SKIP_BUILD_COMPILER_RT=1 -fi - if [[ "${SKIP_RECONFIGURE}" ]]; then RECONFIGURE="" fi From 824a3e65f3572e3171de99c61a43b99a499ab2f4 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:22:52 -0700 Subject: [PATCH 16/35] [Apple Silicon] [build-script] Fix cross-compile check. --- utils/build-script-impl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index f7aeef172e4eb..189f36361cd4f 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -651,7 +651,7 @@ function set_build_options_for_host() { # We don't currently support building compiler-rt for cross-compile targets. # It's not clear that's useful anyway. - if is_cross_tools_host "${host}"; then + if [[ $(is_cross_tools_host "${host}") ]] ; then llvm_cmake_options+=( -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=FALSE -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=FALSE From 39ee89fc0695f77a54366c2b4ad6d7317cc59221 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:23:52 -0700 Subject: [PATCH 17/35] [Apple Silicon] Build system configuration to support arm64 macOS --- utils/build-script-impl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 189f36361cd4f..cfd4a0e14510a 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -975,6 +975,9 @@ function get_host_install_destdir() { if [[ $(should_include_host_in_lipo ${host}) ]]; then # If this is one of the hosts we should lipo, install in to a temporary subdirectory. local host_install_destdir="${BUILD_DIR}/intermediate-install/${host}" + elif [[ "${host}" == "merged-hosts" ]]; then + # This assumes that all hosts are merged to the lipo. + local host_install_destdir="${INSTALL_DESTDIR}" else local host_install_destdir="${INSTALL_DESTDIR}/${host}" fi @@ -1036,7 +1039,7 @@ function should_include_host_in_lipo() { local host="$1" if [[ $(has_cross_compile_hosts) ]] && [[ -z "${SKIP_MERGE_LIPO_CROSS_COMPILE_TOOLS}" ]]; then case ${host} in - iphone* | appletv* | watch* ) + macosx* | iphone* | appletv* | watch* ) echo 1 ;; esac @@ -2831,6 +2834,15 @@ for host in "${ALL_HOSTS[@]}"; do if [[ "${DARWIN_INSTALL_EXTRACT_SYMBOLS}" ]] && [[ $(host_has_darwin_symbols ${host}) ]]; then echo "--- Extracting symbols ---" + # The usage for this script says that lipo happens before + # dsym extraction but that's not really what happens. At this point, + # we're processing an individual host (eg macosx-x86_64) but targeting + # the (shared) SYMROOT which can cause mutliple hosts to stomp on each + # other. As a hack, I'm segregating the hosts in the symroot but it + # would probably be better to make the script behave as the usage + # descibes + host_symroot="${INSTALL_SYMROOT}/${host}" + # FIXME: Since it's hard to trace output pipe call, # For now, We don't support dry-run trace for this block # Instead, just echo we do "darwin_intall_extract_symbols". @@ -2845,7 +2857,7 @@ for host in "${ALL_HOSTS[@]}"; do # Copy executables and shared libraries from the `host_install_destdir` to # INSTALL_SYMROOT and run dsymutil on them. (cd "${CURRENT_INSTALL_DIR}" && - find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | cpio --insecure -pdm "${INSTALL_SYMROOT}") + find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | cpio --insecure -pdm "${host_symroot}") dsymutil_path= if [[ -n "${DARWIN_INSTALL_EXTRACT_SYMBOLS_USE_JUST_BUILT_DSYMUTIL}" ]]; then @@ -2858,7 +2870,7 @@ for host in "${ALL_HOSTS[@]}"; do # # Exclude shell scripts and static archives. # Exclude swift-api-digester dSYM to reduce debug toolchain size. - (cd "${INSTALL_SYMROOT}" && + (cd "${host_symroot}" && find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | \ grep -v '.py$' | \ grep -v '.a$' | \ From 05028a2d941bece95e77c47d84a22ea4b25a44ed Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:24:43 -0700 Subject: [PATCH 18/35] [Apple Silicon] [build-script] Fix lipo step invocation with --no-legacy-impl. LIPO_SRC_DIRS wasn't set for '--only-execute merged-hosts-lipo', because the logic was skipped for actions other than install. --- utils/build-script-impl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index cfd4a0e14510a..66992a626921c 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -3023,21 +3023,21 @@ done # Lipo those products which require it, optionally build and test an installable package. mergedHost="merged-hosts" -if [[ ${#LIPO_SRC_DIRS[@]} -gt 0 ]] && [[ $(should_execute_action "${mergedHost}-lipo") ]]; then +if [[ ${#LIPO_SRC_DIRS[@]} -gt 0 ]]; then # This is from multiple hosts; Which host should we say it is? # Let's call it 'merged-hosts' so that we can identify it. - echo "--- Merging and running lipo ---" + if [[ $(should_execute_action "${mergedHost}-lipo") ]]; then + # Allow passing lipo with --host-lipo + if [[ -z "${HOST_LIPO}" ]] ; then + LIPO_PATH=$(xcrun_find_tool lipo) + else + LIPO_PATH="${HOST_LIPO}" + fi + call "${SWIFT_SOURCE_DIR}"/utils/recursive-lipo --lipo=${LIPO_PATH} --copy-subdirs="$(get_host_install_prefix ${host})lib/swift $(get_host_install_prefix ${host})lib/swift_static" --destination="$(get_host_install_destdir ${mergedHost})" ${LIPO_SRC_DIRS[@]} - # Allow passing lipo with --host-lipo - if [[ -z "${HOST_LIPO}" ]] ; then - LIPO_PATH=$(xcrun_find_tool lipo) - else - LIPO_PATH="${HOST_LIPO}" + # Build and test the lipo-ed package. + build_and_test_installable_package ${mergedHost} fi - call "${SWIFT_SOURCE_DIR}"/utils/recursive-lipo --lipo=${LIPO_PATH} --copy-subdirs="$(get_host_install_prefix ${host})lib/swift $(get_host_install_prefix ${host})lib/swift_static" --destination="$(get_host_install_destdir ${mergedHost})" ${LIPO_SRC_DIRS[@]} - - # Build and test the lipo-ed package. - build_and_test_installable_package ${mergedHost} fi # END From 2ef95d3217fc7e6134e91e391a8b728e41e1868b Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:25:44 -0700 Subject: [PATCH 19/35] [Apple Silicon] Fix cross-compilation in Xcode trains where we're not building stdlib at all --- utils/build-script-impl | 4 ++++ .../swift_build_support/host_specific_configuration.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/utils/build-script-impl b/utils/build-script-impl index 66992a626921c..26bb13adb77d8 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -1056,6 +1056,10 @@ function host_has_darwin_symbols() { } function get_stdlib_targets_for_host() { + # Don't build the stdlib in the Xcode train for host and cross-compilations host. + if [[ "${STDLIB_DEPLOYMENT_TARGETS[@]}" == "" ]]; then + return 0 + fi # FIXME: STDLIB_DEPLOYMENT_TARGETS argument assumed to apply when Host == Build # Cross-compile Hosts are only built with their native standard libraries. diff --git a/utils/swift_build_support/swift_build_support/host_specific_configuration.py b/utils/swift_build_support/swift_build_support/host_specific_configuration.py index 6a407a06a7b65..e97c3a44f2eb2 100644 --- a/utils/swift_build_support/swift_build_support/host_specific_configuration.py +++ b/utils/swift_build_support/swift_build_support/host_specific_configuration.py @@ -41,6 +41,10 @@ def __init__(self, host_target, args): stdlib_targets_to_configure = [host_target] stdlib_targets_to_build = set(stdlib_targets_to_configure) + if args.stdlib_deployment_targets == []: + stdlib_targets_to_configure = [] + stdlib_targets_to_build = [] + # Compute derived information from the arguments. # # FIXME: We should move the platform-derived arguments to be entirely From 69ead9d096427de532fd16ce9b3b09dd4c6e6304 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:26:12 -0700 Subject: [PATCH 20/35] [Apple Silicon] [Platform] Default arm64 macOS and arm64 simulators to "vortex" CPU. --- lib/ClangImporter/ClangImporter.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 92d6d1bacd275..430ecb42214d1 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -722,11 +722,20 @@ addCommonInvocationArguments(std::vector &invocationArgStrs, invocationArgStrs.push_back("-mcpu=" + importerOpts.TargetCPU); } else if (triple.isOSDarwin()) { - // Special case: arm64 defaults to the "cyclone" CPU for Darwin, - // and arm64e defaults to the "vortex" CPU for Darwin, - // but Clang only detects this if we use -arch. + // Special case CPU based on known deployments: + // - arm64 deploys to cyclone + // - arm64 on macOS + // - arm64 for iOS/tvOS/watchOS simulators + // - arm64e deploys to vortex + // and arm64e (everywhere) and arm64e macOS defaults to the "vortex" CPU + // for Darwin, but Clang only detects this if we use -arch. if (triple.getArchName() == "arm64e") invocationArgStrs.push_back("-mcpu=vortex"); + else if (triple.isAArch64() && triple.isMacOSX()) + invocationArgStrs.push_back("-mcpu=vortex"); + else if (triple.isAArch64() && triple.isSimulatorEnvironment() && + (triple.isiOS() || triple.isWatchOS())) + invocationArgStrs.push_back("-mcpu=vortex"); else if (triple.getArch() == llvm::Triple::aarch64 || triple.getArch() == llvm::Triple::aarch64_be) { invocationArgStrs.push_back("-mcpu=cyclone"); From 7ca2bac541d10f0052d674a3b7038501618d0185 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:26:42 -0700 Subject: [PATCH 21/35] [Apple Silicon] [IRGen] Fix test for arm64 macOS --- test/IRGen/objc_properties.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/IRGen/objc_properties.swift b/test/IRGen/objc_properties.swift index 48a5ec69bc786..8d740e51985b1 100644 --- a/test/IRGen/objc_properties.swift +++ b/test/IRGen/objc_properties.swift @@ -250,7 +250,7 @@ class SomeWrapperTests { // CHECK: @"_CATEGORY__TtC15objc_properties10SomeObject_$_objc_properties" = private constant { {{.+}} } { // CHECK: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0), -// CHECK: %swift.type* bitcast (i64* getelementptr inbounds (<{ {{.+}} }>* @"$s15objc_properties10SomeObjectCMf", i32 0, i32 2) to %swift.type*), +// CHECK: @"$s15objc_properties10SomeObjectCMf", i32 0, i32 2 // CHECK: { {{.+}} }* @"_CATEGORY_INSTANCE_METHODS__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}" // CHECK: { {{.+}} }* @"_CATEGORY_CLASS_METHODS__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}" // CHECK: i8* null, From 0360f6819ffd1173c9d5cbadd6b8b4e8d5d54ffa Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:28:33 -0700 Subject: [PATCH 22/35] [Apple Silicon] [macCatalyst] Baseline arm64(e) macCatalyst at Swift 5.3/iOS 14.0. --- lib/AST/Availability.cpp | 16 ++++++++++++++++ lib/Basic/Platform.cpp | 7 +++++++ lib/Driver/DarwinToolChains.cpp | 8 ++++++++ test/Driver/macabi-environment.swift | 3 +++ ...runtime-compatibility-arm64-maccatalyst.swift | 13 +++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 test/IRGen/autolink-runtime-compatibility-arm64-maccatalyst.swift diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index 5210350f39616..e860ec586e6da 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -252,6 +252,10 @@ AvailabilityContext ASTContext::getSwift50Availability() { return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10,14,4))); } else if (target.isiOS()) { + if (target.isAArch64() && + (target.isSimulatorEnvironment() || target.isMacCatalystEnvironment())) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(12,2))); } else if (target.isWatchOS()) { @@ -283,6 +287,10 @@ AvailabilityContext ASTContext::getSwift51Availability() { return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10,15,0))); } else if (target.isiOS()) { + if (target.isAArch64() && + (target.isSimulatorEnvironment() || target.isMacCatalystEnvironment())) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(13,0,0))); } else if (target.isWatchOS()) { @@ -314,6 +322,10 @@ AvailabilityContext ASTContext::getSwift52Availability() { return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); } else if (target.isiOS()) { + if (target.isAArch64() && + (target.isSimulatorEnvironment() || target.isMacCatalystEnvironment())) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(99, 0, 0))); } else if (target.isWatchOS()) { @@ -337,6 +349,10 @@ AvailabilityContext ASTContext::getSwift53Availability() { return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); } else if (target.isiOS()) { + if (target.isAArch64() && + (target.isSimulatorEnvironment() || target.isMacCatalystEnvironment())) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(99, 0, 0))); } else if (target.isWatchOS()) { diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 91c22b17231d2..91962bf258dc5 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -402,6 +402,13 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget( } } else if (Triple.isiOS()) { // includes tvOS Triple.getiOSVersion(Major, Minor, Micro); + + // arm64 simulators and macCatalyst are introduced in iOS 14.0/tvOS 14.0 + // with Swift 5.3 + if (Triple.isAArch64() && Major <= 14 && + (Triple.isSimulatorEnvironment() || Triple.isMacCatalystEnvironment())) + return llvm::VersionTuple(5, 3); + if (Major <= 12) { return llvm::VersionTuple(5, 0); } else if (Major <= 13) { diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index af43ce9299692..aea9eda6a5a59 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -591,6 +591,14 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, if (tripleIsMacCatalystEnvironment(triple)) { triple.getiOSVersion(major, minor, micro); + // Mac Catalyst on arm was introduced with an iOS deployment target of + // 14.0; the linker doesn't want to see a deployment target before that. + if (major < 14 && triple.isAArch64()) { + major = 14; + minor = 0; + micro = 0; + } + // Mac Catalyst was introduced with an iOS deployment target of 13.0; // the linker doesn't want to see a deployment target before that. if (major < 13) { diff --git a/test/Driver/macabi-environment.swift b/test/Driver/macabi-environment.swift index 156bd04879786..7fc78970cd638 100644 --- a/test/Driver/macabi-environment.swift +++ b/test/Driver/macabi-environment.swift @@ -34,6 +34,9 @@ // IOS12-MACABI-DAG: -rpath [[MACOSX_SDK_STDLIB_PATH]] // IOS12-MACABI-DAG: -platform_version mac-catalyst 13.0.0 0.0.0 +// RUN: %swiftc_driver -driver-print-jobs -target arm64-apple-ios12.0-macabi -sdk %S/../Inputs/clang-importer-sdk %s | %FileCheck -check-prefix=IOS14-MACABI %s +// IOS14-MACABI: -platform_version mac-catalyst 14.0.0 0.0.0 + // Test using target-variant to build zippered outputs // RUN: %swiftc_driver -driver-print-jobs -c -target x86_64-apple-macosx10.14 -target-variant x86_64-apple-ios13.0-macabi %s | %FileCheck -check-prefix=ZIPPERED-VARIANT-OBJECT %s diff --git a/test/IRGen/autolink-runtime-compatibility-arm64-maccatalyst.swift b/test/IRGen/autolink-runtime-compatibility-arm64-maccatalyst.swift new file mode 100644 index 0000000000000..9f6d38802a5b2 --- /dev/null +++ b/test/IRGen/autolink-runtime-compatibility-arm64-maccatalyst.swift @@ -0,0 +1,13 @@ +// REQUIRES: CPU=arm64,OS=maccatalyst + +// Doesn't autolink compatibility library because target OS doesn't need it +// RUN: %target-swift-frontend -target arm64-apple-ios12.0-macabi -emit-ir -parse-stdlib %s | %FileCheck -check-prefix=NO-FORCE-LOAD %s + +public func foo() {} + +// NO-FORCE-LOAD-NOT: FORCE_LOAD +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility50"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility51"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility52"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibility53"} +// NO-FORCE-LOAD-NOT: !{!"-lswiftCompatibilityDynamicReplacements"} From 5566ace6e027a5609b3a16ae696b4f5b25264c72 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:31:09 -0700 Subject: [PATCH 23/35] [Apple Silicon] Adjust linking deployment target from 11.0 down to 10.16 on x86. --- lib/Driver/DarwinToolChains.cpp | 8 ++++++++ test/Driver/linker.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index aea9eda6a5a59..43d485b2f4753 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -618,6 +618,14 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, micro = 0; } + // Temporary hack: adjust macOS version passed to the linker from + // 11 down to 10.16, but only for x86. + if (triple.isX86() && major == 11) { + major = 10; + minor = 16; + micro = 0; + } + break; case DarwinPlatformKind::IPhoneOS: case DarwinPlatformKind::IPhoneOSSimulator: diff --git a/test/Driver/linker.swift b/test/Driver/linker.swift index 1f2ce629089bf..db953a22986bf 100644 --- a/test/Driver/linker.swift +++ b/test/Driver/linker.swift @@ -109,10 +109,18 @@ // Check arm64 macOS first deployment version adjustment. // RUN: %swiftc_driver -driver-print-jobs -target arm64-apple-macosx10.15.1 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s +// Check x86 macOS 11 deployment version adjustment. +// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix X86_MACOS11_LINKER %s +// RUN: %swiftc_driver -driver-print-jobs -target arm64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s + // MACOS_10_15: -platform_version macos 10.9.0 10.15.0 // MACOS_10_15_4: -platform_version macos 10.9.0 10.15.4 // MACOS_UNVERSIONED: -platform_version macos 10.9.0 0.0.0 +// ARM64E_MACOS_LINKER: -platform_version macos 11.0.0 +// X86_MACOS11_LINKER: -platform_version macos 10.16.0 +// X86_64_WATCHOS_SIM_LINKER: -platform_version watchos-simulator 7.0.0 + // There are more RUN lines further down in the file. // CHECK: swift From e5d11ff55df7193c482a8e3e0af91af584b952cc Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 18:32:23 -0700 Subject: [PATCH 24/35] [Apple Silicon] [In-process memory reader] Adjust low-bits computation for arm64 macOS --- include/swift/Remote/InProcessMemoryReader.h | 4 ++-- .../swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h | 2 +- stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp | 2 +- stdlib/tools/swift-reflection-test/swift-reflection-test.c | 2 +- tools/swift-reflection-dump/swift-reflection-dump.cpp | 2 +- tools/swift-reflection-fuzzer/swift-reflection-fuzzer.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/swift/Remote/InProcessMemoryReader.h b/include/swift/Remote/InProcessMemoryReader.h index 2f6b5b535a437..c5147e56db9c0 100644 --- a/include/swift/Remote/InProcessMemoryReader.h +++ b/include/swift/Remote/InProcessMemoryReader.h @@ -38,7 +38,7 @@ class InProcessMemoryReader final : public MemoryReader { #else auto applePlatform = false; #endif -#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV)) +#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV) || defined(__arm64__)) auto iosDerivedPlatform = true; #else auto iosDerivedPlatform = false; @@ -67,7 +67,7 @@ class InProcessMemoryReader final : public MemoryReader { case DLQ_GetObjCReservedLowBits: { auto result = static_cast(outBuffer); if (applePlatform && !iosDerivedPlatform && (sizeof(void *) == 8)) { - // Obj-C reserves low bit on 64-bit macOS only. + // Obj-C reserves low bit on 64-bit Intel macOS only. // Other Apple platforms don't reserve this bit (even when // running on x86_64-based simulators). *result = 1; diff --git a/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h b/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h index 3834872d793f3..cc745a2c5dd04 100644 --- a/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h +++ b/include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h @@ -585,7 +585,7 @@ swift_reflection_interop_minimalDataLayoutQueryFunction8( #else int applePlatform = 0; #endif -#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV)) +#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV) || defined(__arm64__)) int iosDerivedPlatform = 1; #else int iosDerivedPlatform = 0; diff --git a/stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp b/stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp index 449ba048c4457..bd9b2c33fa2a5 100644 --- a/stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp +++ b/stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp @@ -70,7 +70,7 @@ static int minimalDataLayoutQueryFunction(void *ReaderContext, #else auto applePlatform = false; #endif -#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV)) +#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV) || defined(__arm64__)) auto iosDerivedPlatform = true; #else auto iosDerivedPlatform = false; diff --git a/stdlib/tools/swift-reflection-test/swift-reflection-test.c b/stdlib/tools/swift-reflection-test/swift-reflection-test.c index 4c2d94c5aec47..4e3d143174ced 100644 --- a/stdlib/tools/swift-reflection-test/swift-reflection-test.c +++ b/stdlib/tools/swift-reflection-test/swift-reflection-test.c @@ -147,7 +147,7 @@ static int PipeMemoryReader_queryDataLayout(void *Context, #else int applePlatform = 0; #endif -#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV)) +#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV) || defined(__arm64__)) int iosDerivedPlatform = 1; #else int iosDerivedPlatform = 0; diff --git a/tools/swift-reflection-dump/swift-reflection-dump.cpp b/tools/swift-reflection-dump/swift-reflection-dump.cpp index 999f467b06da8..c06ec35de5f81 100644 --- a/tools/swift-reflection-dump/swift-reflection-dump.cpp +++ b/tools/swift-reflection-dump/swift-reflection-dump.cpp @@ -458,7 +458,7 @@ class ObjectMemoryReader : public MemoryReader { #else auto applePlatform = false; #endif -#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV)) +#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV) || defined(__arm64__)) auto iosDerivedPlatform = true; #else auto iosDerivedPlatform = false; diff --git a/tools/swift-reflection-fuzzer/swift-reflection-fuzzer.cpp b/tools/swift-reflection-fuzzer/swift-reflection-fuzzer.cpp index 80aaf7d4ca6fd..a47ac394e3561 100644 --- a/tools/swift-reflection-fuzzer/swift-reflection-fuzzer.cpp +++ b/tools/swift-reflection-fuzzer/swift-reflection-fuzzer.cpp @@ -61,7 +61,7 @@ class ObjectMemoryReader : public MemoryReader { #else auto applePlatform = false; #endif -#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV)) +#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV) || defined(__arm64__)) auto iosDerivedPlatform = true; #else auto iosDerivedPlatform = false; From 0b7382689ae41844f2dca0edd56848bb44134eff Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:05:45 -0700 Subject: [PATCH 25/35] [Apple Silicon] [Build] Filter out any architectures that are unsupported by the SDKs --- cmake/modules/SwiftConfigureSDK.cmake | 35 ++++++++++++++++ utils/build-script | 13 ++++++ .../host_specific_configuration.py | 3 +- .../swift_build_support/targets.py | 40 +++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index 5953feca4b9fd..b55e6e6b9866e 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -85,6 +85,38 @@ function(_report_sdk prefix) message(STATUS "") endfunction() +# Remove architectures not supported by the SDK from the given list. +function(remove_sdk_unsupported_archs name os sdk_path architectures_var) + execute_process(COMMAND + /usr/libexec/PlistBuddy -c "Print :SupportedTargets:${os}:Archs" ${sdk_path}/SDKSettings.plist + OUTPUT_VARIABLE sdk_supported_archs + RESULT_VARIABLE plist_error) + + if (NOT plist_error EQUAL 0) + message(STATUS "${os} SDK at ${sdk_path} does not publish its supported architectures") + return() + endif() + + set(architectures) + foreach(arch ${${architectures_var}}) + if(sdk_supported_archs MATCHES "${arch}\n") + list(APPEND architectures ${arch}) + elseif(arch MATCHES "^armv7(s)?$" AND os STREQUAL "iphoneos") + # 32-bit iOS is not listed explicitly in SDK settings. + message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}") + list(APPEND architectures ${arch}) + elseif(arch STREQUAL "i386" AND os STREQUAL "iphonesimulator") + # 32-bit iOS simulatoris not listed explicitly in SDK settings. + message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}") + list(APPEND architectures ${arch}) + else() + message(STATUS "${name} SDK at ${sdk_path} does not support architecture ${arch}") + endif() + endforeach() + + set("${architectures_var}" ${architectures} PARENT_SCOPE) +endfunction() + # Configure an SDK # # Usage: @@ -164,6 +196,9 @@ macro(configure_sdk_darwin SWIFT_SDK_${prefix}_ARCHITECTURES) # result endif() + # Remove any architectures not supported by the SDK. + remove_sdk_unsupported_archs(${name} ${xcrun_name} ${SWIFT_SDK_${prefix}_PATH} SWIFT_SDK_${prefix}_ARCHITECTURES) + list_intersect( "${SWIFT_DARWIN_MODULE_ARCHS}" # lhs "${architectures}" # rhs diff --git a/utils/build-script b/utils/build-script index aa79436709f7f..1a96cb78f2b9a 100755 --- a/utils/build-script +++ b/utils/build-script @@ -350,6 +350,19 @@ def apply_default_arguments(toolchain, args): target.arch in supported_archs) ] + # Filter out any macOS stdlib deployment targets that are not supported + # by the macOS SDK. + if platform.system() == "Darwin": + targets = StdlibDeploymentTarget.get_targets_by_name( + args.stdlib_deployment_targets) + args.stdlib_deployment_targets = [ + target.name + for target in targets + if (target.platform.is_darwin and + target.platform.sdk_supports_architecture( + target.arch, args.darwin_xcrun_toolchain)) + ] + # Include the Darwin module-only architectures in the CMake options. if args.swift_darwin_module_archs: args.extra_cmake_options.append( diff --git a/utils/swift_build_support/swift_build_support/host_specific_configuration.py b/utils/swift_build_support/swift_build_support/host_specific_configuration.py index e97c3a44f2eb2..b13140f10a876 100644 --- a/utils/swift_build_support/swift_build_support/host_specific_configuration.py +++ b/utils/swift_build_support/swift_build_support/host_specific_configuration.py @@ -41,7 +41,8 @@ def __init__(self, host_target, args): stdlib_targets_to_configure = [host_target] stdlib_targets_to_build = set(stdlib_targets_to_configure) - if args.stdlib_deployment_targets == []: + if (hasattr(args, 'stdlib_deployment_targets') and + args.stdlib_deployment_targets == []): stdlib_targets_to_configure = [] stdlib_targets_to_build = [] diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 576d675832bd8..044c945c70a66 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -11,6 +11,13 @@ import os import platform +from . import shell + +try: + from build_swift.build_swift.wrappers import xcrun +except ImportError: + from build_swift.wrappers import xcrun + class Platform(object): """ @@ -86,6 +93,39 @@ def uses_host_tests(self): """ return self.is_embedded and not self.is_simulator + def sdk_supports_architecture(self, arch, toolchain): + """ + Convenience function for checking whether the SDK supports the + target architecture. + """ + + # The names match up with the xcrun SDK names. + xcrun_sdk_name = self.name + + # 32-bit iOS and iOS simulator are supported, but are not covered + # by the SDK settings. Handle this special case here. + if (xcrun_sdk_name == 'iphoneos' and + (arch == 'armv7' or arch == 'armv7s')): + return True + + if (xcrun_sdk_name == 'iphonesimulator' and arch == 'i386'): + return True + + sdk_path = xcrun.sdk_path(sdk=xcrun_sdk_name, toolchain=toolchain) + if not sdk_path: + raise RuntimeError('Cannot find SDK path for %s' % xcrun_sdk_name) + + # Find the SDKSettings.plist for this sdK + plistCommand = [ + '/usr/libexec/PlistBuddy', + '-c', + 'Print :SupportedTargets:%s:Archs' % (self.name), + '%s/SDKSettings.plist' % (sdk_path) + ] + + sdk_archs = shell.capture(plistCommand, dry_run=False, echo=True) + return arch in sdk_archs + class AndroidPlatform(Platform): @property From dedd4263dc32c68ad2c47559e682da8ac9bd66a6 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:12:05 -0700 Subject: [PATCH 26/35] [Apple Silicon] [Test] Fix a few tests for SDK differences --- test/Driver/linker.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Driver/linker.swift b/test/Driver/linker.swift index db953a22986bf..de4f25dd7ceb6 100644 --- a/test/Driver/linker.swift +++ b/test/Driver/linker.swift @@ -107,11 +107,11 @@ // RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -sdk %S/Inputs/MacOSX10.15.sdk %s 2>&1 | %FileCheck -check-prefix MACOS_UNVERSIONED %s // Check arm64 macOS first deployment version adjustment. -// RUN: %swiftc_driver -driver-print-jobs -target arm64-apple-macosx10.15.1 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s +// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-macosx10.15.1 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s // Check x86 macOS 11 deployment version adjustment. -// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix X86_MACOS11_LINKER %s -// RUN: %swiftc_driver -driver-print-jobs -target arm64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s +// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target x86_64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix X86_MACOS11_LINKER %s +// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s // MACOS_10_15: -platform_version macos 10.9.0 10.15.0 // MACOS_10_15_4: -platform_version macos 10.9.0 10.15.4 From 8364ec9fc7d9e40bc836ce890bcfe17ad7daea21 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:14:56 -0700 Subject: [PATCH 27/35] [Apple Silicon] [Test] Remove explicitly-specified target. --- test/api-digester/compare-two-sdks.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/api-digester/compare-two-sdks.swift b/test/api-digester/compare-two-sdks.swift index a95e7fbcd7755..f034e359803cb 100644 --- a/test/api-digester/compare-two-sdks.swift +++ b/test/api-digester/compare-two-sdks.swift @@ -5,7 +5,7 @@ // RUN: %empty-directory(%t.sdk) // RUN: %empty-directory(%t.module-cache) -// RUN: %api-digester -diagnose-sdk -print-module -module-list-file %S/Inputs/mock-sdk-modules.txt -sdk %S/Inputs/mock-sdk.sdk -bsdk %S/Inputs/mock-sdk-baseline.sdk -module-cache-path %t.module-cache -o %t.result -abort-on-module-fail -target %target-cpu-apple-macos10.14 +// RUN: %api-digester -diagnose-sdk -print-module -module-list-file %S/Inputs/mock-sdk-modules.txt -sdk %S/Inputs/mock-sdk.sdk -bsdk %S/Inputs/mock-sdk-baseline.sdk -module-cache-path %t.module-cache -o %t.result -abort-on-module-fail // RUN: %clang -E -P -x c %S/Outputs/mock-sdk-api.txt -o - | sed '/^\s*$/d' > %t.expected // RUN: %clang -E -P -x c %t.result -o - | sed '/^\s*$/d' > %t.result.tmp From 795c363eb9f0b0b0d925109370bb9d105ec1c270 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:17:29 -0700 Subject: [PATCH 28/35] [Apple Silicon] Simulator support for arm64 --- cmake/modules/DarwinSDKs.cmake | 25 ++++++++-- utils/build-script-impl | 48 +++++++++++++++++++ .../swift_build_support/targets.py | 7 +-- 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/cmake/modules/DarwinSDKs.cmake b/cmake/modules/DarwinSDKs.cmake index 6a9e4ef3a4040..5ad1e32d1d8a1 100644 --- a/cmake/modules/DarwinSDKs.cmake +++ b/cmake/modules/DarwinSDKs.cmake @@ -4,18 +4,35 @@ option(SWIFT_ENABLE_IOS32 if(SWIFT_ENABLE_IOS32) set(SUPPORTED_IOS_ARCHS "armv7;armv7s;arm64;arm64e") -set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64") +set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64;arm64") else() set(SUPPORTED_IOS_ARCHS "arm64;arm64e") -set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64") +set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64;arm64") endif() set(SUPPORTED_TVOS_ARCHS "arm64") -set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64") +set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64") set(SUPPORTED_WATCHOS_ARCHS "armv7k") -set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386") +set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64") set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e") +# Get the SDK version from SDKSettings. +execute_process( + COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "Version" + OUTPUT_VARIABLE SWIFT_OSX_SDK_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# Remove the last component, if any. e.g. 10.15.26 -> 10.15 +string(REGEX REPLACE "\([0-9]*[.][0-9]*\)[.][0-9]*" "\\1" + SWIFT_OSX_SDK_VERSION "${SWIFT_OSX_SDK_VERSION}") + +if (${SWIFT_OSX_SDK_VERSION} STREQUAL "10.14" OR + ${SWIFT_OSX_SDK_VERSION} STREQUAL "10.15") + set(SUPPORTED_OSX_ARCHS "x86_64") +else() + set(SUPPORTED_OSX_ARCHS "x86_64;arm64e") +endif() + is_sdk_requested(OSX swift_build_osx) if(swift_build_osx) configure_sdk_darwin( diff --git a/utils/build-script-impl b/utils/build-script-impl index 26bb13adb77d8..60d46cdf6dc48 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -420,13 +420,16 @@ function verify_host_is_supported() { | macosx-arm64e \ | iphonesimulator-i386 \ | iphonesimulator-x86_64 \ + | iphonesimulator-arm64 \ | iphoneos-armv7 \ | iphoneos-armv7s \ | iphoneos-arm64 \ | iphoneos-arm64e \ | appletvsimulator-x86_64 \ + | appletvsimulator-arm64 \ | appletvos-arm64 \ | watchsimulator-i386 \ + | watchsimulator-arm64 \ | watchos-armv7k \ | android-armv7 \ | android-aarch64) @@ -527,6 +530,21 @@ function set_build_options_for_host() { SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR" cmake_osx_deployment_target="" ;; + iphonesimulator-arm64) + xcrun_sdk_name="iphonesimulator" + llvm_target_arch="AArch64" + SWIFT_HOST_TRIPLE="arm64-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator" + SWIFT_HOST_VARIANT="iphonesimulator" + SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR" + SWIFT_HOST_VARIANT_ARCH="arm64" + + cmake_osx_deployment_target="" + cmark_cmake_options=( + -DCMAKE_C_FLAGS="$(cmark_c_flags ${host})" + -DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})" + -DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)" + ) + ;; iphoneos-armv7) SWIFT_HOST_TRIPLE="armv7-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}" llvm_target_arch="ARM" @@ -562,6 +580,21 @@ function set_build_options_for_host() { SWIFT_HOST_VARIANT_SDK="TVOS_SIMULATOR" cmake_osx_deployment_target="" ;; + appletvsimulator-arm64) + xcrun_sdk_name="appletvsimulator" + llvm_target_arch="AArch64" + SWIFT_HOST_TRIPLE="arm64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator" + SWIFT_HOST_VARIANT="appletvsimulator" + SWIFT_HOST_VARIANT_SDK="TVOS_SIMULATOR" + SWIFT_HOST_VARIANT_ARCH="arm64" + + cmake_osx_deployment_target="" + cmark_cmake_options=( + -DCMAKE_C_FLAGS="$(cmark_c_flags ${host})" + -DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})" + -DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)" + ) + ;; appletvos-arm64) SWIFT_HOST_TRIPLE="arm64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}" llvm_target_arch="AArch64" @@ -576,6 +609,21 @@ function set_build_options_for_host() { SWIFT_HOST_VARIANT_SDK="WATCHOS_SIMULATOR" cmake_osx_deployment_target="" ;; + watchsimulator-arm64) + xcrun_sdk_name="watchsimulator" + llvm_target_arch="AArch64" + SWIFT_HOST_TRIPLE="arm64-apple-watchos${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator" + SWIFT_HOST_VARIANT="watchsimulator" + SWIFT_HOST_VARIANT_SDK="WATCHOS_SIMULATOR" + SWIFT_HOST_VARIANT_ARCH="arm64" + + cmake_osx_deployment_target="" + cmark_cmake_options=( + -DCMAKE_C_FLAGS="$(cmark_c_flags ${host})" + -DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})" + -DCMAKE_OSX_SYSROOT:PATH="$(xcrun --sdk ${xcrun_sdk_name} --show-sdk-path)" + ) + ;; watchos-armv7k) SWIFT_HOST_TRIPLE="armv7k-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}" llvm_target_arch="ARM" diff --git a/utils/swift_build_support/swift_build_support/targets.py b/utils/swift_build_support/swift_build_support/targets.py index 044c945c70a66..6bc7abe319fb0 100644 --- a/utils/swift_build_support/swift_build_support/targets.py +++ b/utils/swift_build_support/swift_build_support/targets.py @@ -159,7 +159,7 @@ class StdlibDeploymentTarget(object): iOS = DarwinPlatform("iphoneos", archs=["armv7", "armv7s", "arm64", "arm64e"], sdk_name="IOS") - iOSSimulator = DarwinPlatform("iphonesimulator", archs=["i386", "x86_64"], + iOSSimulator = DarwinPlatform("iphonesimulator", archs=["i386", "x86_64", "arm64"], sdk_name="IOS_SIMULATOR", is_simulator=True) @@ -168,13 +168,14 @@ class StdlibDeploymentTarget(object): AppleTV = DarwinPlatform("appletvos", archs=["arm64"], sdk_name="TVOS") - AppleTVSimulator = DarwinPlatform("appletvsimulator", archs=["x86_64"], + AppleTVSimulator = DarwinPlatform("appletvsimulator", archs=["x86_64", "arm64"], sdk_name="TVOS_SIMULATOR", is_simulator=True) AppleWatch = DarwinPlatform("watchos", archs=["armv7k"], sdk_name="WATCHOS") - AppleWatchSimulator = DarwinPlatform("watchsimulator", archs=["i386"], + + AppleWatchSimulator = DarwinPlatform("watchsimulator", archs=["i386", "arm64"], sdk_name="WATCHOS_SIMULATOR", is_simulator=True) From 00a9c11f08d9bf958668896014ab634fedd20038 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:18:52 -0700 Subject: [PATCH 29/35] [Apple Silicon] [Platform] Baseline arm64 simulators at iOS/tvOS 14.0 and watchOS 7.0. --- lib/AST/Availability.cpp | 26 +++++++++++++++++--------- lib/Driver/DarwinToolChains.cpp | 10 ++++++++++ test/Driver/linker.swift | 9 +++++++++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index e860ec586e6da..158c78fc5c783 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -315,25 +315,27 @@ AvailabilityContext ASTContext::getSwift52Availability() { if (target.getArchName() == "arm64e") return AvailabilityContext::alwaysAvailable(); - if (target.isMacOSX() ) { + if (target.isMacOSX()) { if (target.isAArch64()) return AvailabilityContext::alwaysAvailable(); return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); + VersionRange::allGTE(llvm::VersionTuple(10, 15, 4))); } else if (target.isiOS()) { if (target.isAArch64() && (target.isSimulatorEnvironment() || target.isMacCatalystEnvironment())) return AvailabilityContext::alwaysAvailable(); return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(99, 0, 0))); + VersionRange::allGTE(llvm::VersionTuple(13, 4, 0))); } else if (target.isWatchOS()) { + if (target.isArch64Bit()) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(9, 99, 0))); - } else { - return AvailabilityContext::alwaysAvailable(); + VersionRange::allGTE(llvm::VersionTuple(6, 2, 0))); } + return AvailabilityContext::alwaysAvailable(); } AvailabilityContext ASTContext::getSwift53Availability() { @@ -346,18 +348,24 @@ AvailabilityContext ASTContext::getSwift53Availability() { if (target.isAArch64()) return AvailabilityContext::alwaysAvailable(); + llvm::VersionTuple macOVersion53(10, 16, 0); + macOVersion53 = canonicalizePlatformVersion(PlatformKind::OSX, macOVersion53); return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); + VersionRange::allGTE(llvm::VersionTuple(10, 16, 0))); + VersionRange::allGTE(macOVersion53)); } else if (target.isiOS()) { if (target.isAArch64() && (target.isSimulatorEnvironment() || target.isMacCatalystEnvironment())) return AvailabilityContext::alwaysAvailable(); return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(99, 0, 0))); + VersionRange::allGTE(llvm::VersionTuple(14, 0, 0))); } else if (target.isWatchOS()) { + if (target.isArch64Bit()) + return AvailabilityContext::alwaysAvailable(); + return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(9, 99, 0))); + VersionRange::allGTE(llvm::VersionTuple(7, 0, 0))); } else { return AvailabilityContext::alwaysAvailable(); } diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index 43d485b2f4753..0577e0499c8f4 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -632,6 +632,16 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, case DarwinPlatformKind::TvOS: case DarwinPlatformKind::TvOSSimulator: triple.getiOSVersion(major, minor, micro); + + // The first deployment of arm64 simulators is iOS/tvOS 14.0; + // the linker doesn't want to see a deployment target before that. + if (triple.isSimulatorEnvironment() && triple.isAArch64() && + major < 14) { + major = 14; + minor = 0; + micro = 0; + } + break; case DarwinPlatformKind::WatchOS: case DarwinPlatformKind::WatchOSSimulator: diff --git a/test/Driver/linker.swift b/test/Driver/linker.swift index de4f25dd7ceb6..922940d8f0f4e 100644 --- a/test/Driver/linker.swift +++ b/test/Driver/linker.swift @@ -113,6 +113,12 @@ // RUN: %swiftc_driver -sdk "" -driver-print-jobs -target x86_64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix X86_MACOS11_LINKER %s // RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-macosx11.0 %s 2>&1 | %FileCheck -check-prefix ARM64E_MACOS_LINKER %s +// Check arm64 simulators first deployment version adjustment. +// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-ios13.0-simulator %s 2>&1 | %FileCheck -check-prefix ARM64_IOS_SIMULATOR_LINKER %s +// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-tvos13.0-simulator %s 2>&1 | %FileCheck -check-prefix ARM64_TVOS_SIMULATOR_LINKER %s +// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-watchos5.0-simulator %s 2>&1 | %FileCheck -check-prefix ARM64_WATCHOS_SIMULATOR_LINKER %s + + // MACOS_10_15: -platform_version macos 10.9.0 10.15.0 // MACOS_10_15_4: -platform_version macos 10.9.0 10.15.4 // MACOS_UNVERSIONED: -platform_version macos 10.9.0 0.0.0 @@ -120,6 +126,9 @@ // ARM64E_MACOS_LINKER: -platform_version macos 11.0.0 // X86_MACOS11_LINKER: -platform_version macos 10.16.0 // X86_64_WATCHOS_SIM_LINKER: -platform_version watchos-simulator 7.0.0 +// ARM64_IOS_SIMULATOR_LINKER: -platform_version ios-simulator 14.0.0 +// ARM64_TVOS_SIMULATOR_LINKER: -platform_version tvos-simulator 14.0.0 +// ARM64_WATCHOS_SIMULATOR_LINKER: -platform_version watchos-simulator 7.0.0 // There are more RUN lines further down in the file. From 54d8f938b9af10c51b7beae36e2256647f1d8d4f Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:20:40 -0700 Subject: [PATCH 30/35] [Apple Silicon] Use a correct isa mask on Apple Silicon without signed isas --- stdlib/public/runtime/Private.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stdlib/public/runtime/Private.h b/stdlib/public/runtime/Private.h index 49162640f3ffd..d82895aebec4e 100644 --- a/stdlib/public/runtime/Private.h +++ b/stdlib/public/runtime/Private.h @@ -97,14 +97,22 @@ class TypeInfo { // out the proper includes from libobjc. The values MUST match the ones from // libobjc. Debug builds check these values against objc_debug_isa_class_mask // from libobjc. -# if TARGET_OS_SIMULATOR -// Simulators don't currently use isa masking, but we still want to emit +# if TARGET_OS_SIMULATOR && __x86_64__ +// Simulators don't currently use isa masking on x86, but we still want to emit // swift_isaMask and the corresponding code in case that changes. libobjc's // mask has the bottom bits clear to include pointer alignment, match that // value here. # define SWIFT_ISA_MASK 0xfffffffffffffff8ULL # elif __arm64__ -# define SWIFT_ISA_MASK 0x0000000ffffffff8ULL +# if __has_feature(ptrauth_calls) +# define SWIFT_ISA_MASK 0x007ffffffffffff8ULL +# else +# if TARGET_OS_OSX +# define SWIFT_ISA_MASK 0x00007ffffffffff8ULL +# else +# define SWIFT_ISA_MASK 0x0000000ffffffff8ULL +# endif +# endif # elif __x86_64__ # define SWIFT_ISA_MASK 0x00007ffffffffff8ULL # else From 0c5dc541a9be89555083d6b29095f1966b2766c3 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:23:11 -0700 Subject: [PATCH 31/35] [Apple Silicon] Fix the availability for Swift 5.3 version --- lib/AST/Availability.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index 158c78fc5c783..e262a36387774 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -351,7 +351,6 @@ AvailabilityContext ASTContext::getSwift53Availability() { llvm::VersionTuple macOVersion53(10, 16, 0); macOVersion53 = canonicalizePlatformVersion(PlatformKind::OSX, macOVersion53); return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(10, 16, 0))); VersionRange::allGTE(macOVersion53)); } else if (target.isiOS()) { if (target.isAArch64() && From d764db0047d6a2e1c2a1fdb08bc9eec83a755a90 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:26:25 -0700 Subject: [PATCH 32/35] [Apple Silicon] Add support for triple and availability canonicalization --- include/swift/AST/AvailabilitySpec.h | 22 +++++++ include/swift/AST/PlatformKind.h | 4 ++ lib/AST/Availability.cpp | 2 +- lib/AST/PlatformKind.cpp | 15 +++++ lib/Basic/Platform.cpp | 2 + lib/Driver/DarwinToolChains.cpp | 10 ++- lib/Parse/ParseDecl.cpp | 16 +++++ lib/Parse/ParseExpr.cpp | 7 ++- .../DerivedConformanceRawRepresentable.cpp | 2 +- lib/Sema/TypeCheckAvailability.cpp | 17 ++++-- .../MacOSVersionCanonicalization.h | 11 ++++ .../Inputs/custom-modules/module.map | 4 ++ ...ailability_macosx_canonical_versions.swift | 13 ++++ ...ity_macosx_canonical_versions_appext.swift | 13 ++++ ...it-interface-macos-canonical-version.swift | 18 ++++++ ...t_tc_decls_macosx_canonical_versions.swift | 16 +++++ ...al_conformances_gettypemetdatabyname.swift | 6 +- test/IRGen/generic_metatypes_future.swift | 2 +- test/IRGen/osx-targets.swift | 7 ++- ...ailability_macosx_canonical_versions.swift | 20 ++++++ ...catalyst_zippered_canonical_versions.swift | 22 +++++++ ...lity_query_macosx_canonical_versions.swift | 17 ++++++ ...vailability_versions_canonical_macos.swift | 14 +++++ ...availability_canonical_macos_version.swift | 42 +++++++++++++ ...canonical_macos_version_introduction.swift | 61 +++++++++++++++++++ ...al_macos_version_introduction_appext.swift | 9 +++ test/lit.cfg | 2 +- 27 files changed, 356 insertions(+), 18 deletions(-) create mode 100644 test/ClangImporter/Inputs/custom-modules/MacOSVersionCanonicalization.h create mode 100644 test/ClangImporter/availability_macosx_canonical_versions.swift create mode 100644 test/ClangImporter/availability_macosx_canonical_versions_appext.swift create mode 100644 test/Frontend/emit-interface-macos-canonical-version.swift create mode 100644 test/IDE/print_ast_tc_decls_macosx_canonical_versions.swift create mode 100644 test/PrintAsObjC/availability_macosx_canonical_versions.swift create mode 100644 test/SILGen/availability_query_maccatalyst_zippered_canonical_versions.swift create mode 100644 test/SILGen/availability_query_macosx_canonical_versions.swift create mode 100644 test/Sema/availability_versions_canonical_macos.swift create mode 100644 test/attr/attr_availability_canonical_macos_version.swift create mode 100644 test/attr/attr_availability_canonical_macos_version_introduction.swift create mode 100644 test/attr/attr_availability_canonical_macos_version_introduction_appext.swift diff --git a/include/swift/AST/AvailabilitySpec.h b/include/swift/AST/AvailabilitySpec.h index 05c0752bffaab..d9aa8b12e605c 100644 --- a/include/swift/AST/AvailabilitySpec.h +++ b/include/swift/AST/AvailabilitySpec.h @@ -68,16 +68,33 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec { SourceLoc PlatformLoc; llvm::VersionTuple Version; + + // For macOS Big Sur, we we canonicalize 10.16 to 11.0 for compile-time + // checking since clang canonicalizes availability markup. However, to + // support Beta versions of macOS Big Sur where the OS + // reports 10.16 at run time, we need to compare against 10.16, + // + // This means for: + // + // if #available(macOS 10.16, *) { ... } + // + // we need to keep around both a canonical version for use in compile-time + // checks and an uncanonicalized version for the version to actually codegen + // with. + llvm::VersionTuple RuntimeVersion; + SourceRange VersionSrcRange; public: PlatformVersionConstraintAvailabilitySpec(PlatformKind Platform, SourceLoc PlatformLoc, llvm::VersionTuple Version, + llvm::VersionTuple RuntimeVersion, SourceRange VersionSrcRange) : AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint), Platform(Platform), PlatformLoc(PlatformLoc), Version(Version), + RuntimeVersion(RuntimeVersion), VersionSrcRange(VersionSrcRange) {} /// The required platform. @@ -93,6 +110,11 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec { llvm::VersionTuple getVersion() const { return Version; } SourceRange getVersionSrcRange() const { return VersionSrcRange; } + // The version to be used in codegen for version comparisons at run time. + // This is required to support beta versions of macOS Big Sur that + // report 10.16 at run time. + llvm::VersionTuple getRuntimeVersion() const { return RuntimeVersion; } + SourceRange getSourceRange() const; void print(raw_ostream &OS, unsigned Indent) const; diff --git a/include/swift/AST/PlatformKind.h b/include/swift/AST/PlatformKind.h index 521167f6ce2d7..1a2d105f56d76 100644 --- a/include/swift/AST/PlatformKind.h +++ b/include/swift/AST/PlatformKind.h @@ -20,6 +20,7 @@ #include "swift/Basic/LLVM.h" #include "swift/Config.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/VersionTuple.h" namespace swift { @@ -65,6 +66,9 @@ PlatformKind targetPlatform(LangOptions &LangOpts); /// an explicit attribute for the child. bool inheritsAvailabilityFromPlatform(PlatformKind Child, PlatformKind Parent); +llvm::VersionTuple canonicalizePlatformVersion( + PlatformKind platform, const llvm::VersionTuple &version); + } // end namespace swift #endif diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index e262a36387774..b0ffc9d494507 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -375,7 +375,7 @@ AvailabilityContext ASTContext::getSwiftFutureAvailability() { if (target.isMacOSX() ) { return AvailabilityContext( - VersionRange::allGTE(llvm::VersionTuple(10, 99, 0))); + VersionRange::allGTE(llvm::VersionTuple(99, 99, 0))); } else if (target.isiOS()) { return AvailabilityContext( VersionRange::allGTE(llvm::VersionTuple(99, 0, 0))); diff --git a/lib/AST/PlatformKind.cpp b/lib/AST/PlatformKind.cpp index 1119601d458c1..005f7548e208f 100644 --- a/lib/AST/PlatformKind.cpp +++ b/lib/AST/PlatformKind.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" + using namespace swift; StringRef swift::platformString(PlatformKind platform) { @@ -155,3 +156,17 @@ bool swift::inheritsAvailabilityFromPlatform(PlatformKind Child, return false; } + +llvm::VersionTuple swift::canonicalizePlatformVersion( + PlatformKind platform, const llvm::VersionTuple &version) { + + // Canonicalize macOS version for macOS Big Sur to great + // 10.16 as 11.0. + if (platform == PlatformKind::OSX || + platform == PlatformKind::OSXApplicationExtension) { + return llvm::Triple::getCanonicalVersionForOS(llvm::Triple::MacOSX, + version); + } + + return version; +} diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 91962bf258dc5..e58ff28914164 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -399,6 +399,8 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget( return llvm::VersionTuple(5, 2); } } + } else if (Major == 11) { + return llvm::VersionTuple(5, 3); } } else if (Triple.isiOS()) { // includes tvOS Triple.getiOSVersion(Major, Minor, Micro); diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index 0577e0499c8f4..a7153dc064e52 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -13,6 +13,7 @@ #include "ToolChains.h" #include "swift/AST/DiagnosticsDriver.h" +#include "swift/AST/PlatformKind.h" #include "swift/Basic/Dwarf.h" #include "swift/Basic/LLVM.h" #include "swift/Basic/Platform.h" @@ -613,9 +614,12 @@ toolchains::Darwin::addDeploymentTargetArgs(ArgStringList &Arguments, // The first deployment of arm64 for macOS is version 10.16; if (triple.isAArch64() && major <= 10 && minor < 16) { - major = 10; - minor = 16; - micro = 0; + llvm::VersionTuple firstMacARM64e(10, 16, 0); + firstMacARM64e = canonicalizePlatformVersion(PlatformKind::OSX, + firstMacARM64e); + major = firstMacARM64e.getMajor(); + minor = firstMacARM64e.getMinor().getValueOr(0); + micro = firstMacARM64e.getSubminor().getValueOr(0); } // Temporary hack: adjust macOS version passed to the linker from diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 57d75efd4f17f..6ba5265ed37c7 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -575,6 +575,20 @@ ParserResult Parser::parseExtendedAvailabilitySpecList( return nullptr; } + if (PlatformKind) { + if (!Introduced.empty()) + Introduced.Version = + canonicalizePlatformVersion(*PlatformKind, Introduced.Version); + + if (!Deprecated.empty()) + Deprecated.Version = + canonicalizePlatformVersion(*PlatformKind, Deprecated.Version); + + if (!Obsoleted.empty()) + Obsoleted.Version = + canonicalizePlatformVersion(*PlatformKind, Obsoleted.Version); + } + auto Attr = new (Context) AvailableAttr(AtLoc, SourceRange(AttrLoc, Tok.getLoc()), PlatformKind.getValue(), @@ -1962,6 +1976,8 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc, continue; } + Version = canonicalizePlatformVersion(Platform, Version); + Attributes.add(new (Context) AvailableAttr(AtLoc, AttrRange, Platform, diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index cc4ef2471061b..d26c076f3a44b 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -3815,6 +3815,11 @@ Parser::parsePlatformVersionConstraintSpec() { // Register the platform name as a keyword token. TokReceiver->registerTokenKindChange(PlatformLoc, tok::contextual_keyword); + // Keep the original version around for run-time checks to support + // macOS Big Sur betas that report 10.16 at + // at run time. + llvm::VersionTuple RuntimeVersion = Version; + Version = canonicalizePlatformVersion(*Platform, Version); return makeParserResult(new (Context) PlatformVersionConstraintAvailabilitySpec( - Platform.getValue(), PlatformLoc, Version, VersionRange)); + Platform.getValue(), PlatformLoc, Version, RuntimeVersion, VersionRange)); } diff --git a/lib/Sema/DerivedConformanceRawRepresentable.cpp b/lib/Sema/DerivedConformanceRawRepresentable.cpp index ffa9f13854303..0a8e9ce72df79 100644 --- a/lib/Sema/DerivedConformanceRawRepresentable.cpp +++ b/lib/Sema/DerivedConformanceRawRepresentable.cpp @@ -198,7 +198,7 @@ struct RuntimeVersionCheck { // platformSpec = "\(attr.platform) \(attr.introduced)" auto platformSpec = new (C) PlatformVersionConstraintAvailabilitySpec( Platform, SourceLoc(), - Version, SourceLoc() + Version, Version, SourceLoc() ); // otherSpec = "*" diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index daf1ea3340b9f..38b3eef7c78f7 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -453,8 +453,8 @@ class TypeRefinementContextBuilder : private ASTWalker { continue; } - AvailabilityContext NewConstraint = contextForSpec(Spec); - Query->setAvailableRange(NewConstraint.getOSVersion()); + AvailabilityContext NewConstraint = contextForSpec(Spec, false); + Query->setAvailableRange(contextForSpec(Spec, true).getOSVersion()); // When compiling zippered for macCatalyst, we need to collect both // a macOS version (the target version) and an iOS/macCatalyst version @@ -464,7 +464,8 @@ class TypeRefinementContextBuilder : private ASTWalker { if (Context.LangOpts.TargetVariant) { AvailabilitySpec *VariantSpec = bestActiveSpecForQuery(Query, /*ForTargetVariant*/ true); - VersionRange VariantRange = contextForSpec(VariantSpec).getOSVersion(); + VersionRange VariantRange = + contextForSpec(VariantSpec, true).getOSVersion(); Query->setVariantAvailableRange(VariantRange); } @@ -594,13 +595,19 @@ class TypeRefinementContextBuilder : private ASTWalker { } /// Return the availability context for the given spec. - AvailabilityContext contextForSpec(AvailabilitySpec *Spec) { + AvailabilityContext contextForSpec(AvailabilitySpec *Spec, + bool GetRuntimeContext) { if (isa(Spec)) { return AvailabilityContext::alwaysAvailable(); } auto *VersionSpec = cast(Spec); - return AvailabilityContext(VersionRange::allGTE(VersionSpec->getVersion())); + + llvm::VersionTuple Version = (GetRuntimeContext ? + VersionSpec->getRuntimeVersion() : + VersionSpec->getVersion()); + + return AvailabilityContext(VersionRange::allGTE(Version)); } Expr *walkToExprPost(Expr *E) override { diff --git a/test/ClangImporter/Inputs/custom-modules/MacOSVersionCanonicalization.h b/test/ClangImporter/Inputs/custom-modules/MacOSVersionCanonicalization.h new file mode 100644 index 0000000000000..b0b02c20e999b --- /dev/null +++ b/test/ClangImporter/Inputs/custom-modules/MacOSVersionCanonicalization.h @@ -0,0 +1,11 @@ +__attribute__((availability(macosx,introduced=10.16))) +void FunctionIntroducedIn10_16(); + +__attribute__((availability(macosx,introduced=11.0))) +void FunctionIntroducedIn11_0(); + +__attribute__((availability(macosx_app_extension,introduced=10.16))) +void FunctionIntroducedIn10_16AppExt(); + +__attribute__((availability(macosx_app_extension,introduced=11.0))) +void FunctionIntroducedIn11_0AppExt(); diff --git a/test/ClangImporter/Inputs/custom-modules/module.map b/test/ClangImporter/Inputs/custom-modules/module.map index 6c4612efb44c0..b66f030963f97 100644 --- a/test/ClangImporter/Inputs/custom-modules/module.map +++ b/test/ClangImporter/Inputs/custom-modules/module.map @@ -221,6 +221,10 @@ module BlocksReturningBool { header "BlocksReturningBool.h" } +module MacOSVersionCanonicalization { + header "MacOSVersionCanonicalization.h" +} + module Warnings1 { header "Warnings1.h" } module Warnings2 { header "Warnings2.h" } module Warnings3 { header "Warnings3.h" } diff --git a/test/ClangImporter/availability_macosx_canonical_versions.swift b/test/ClangImporter/availability_macosx_canonical_versions.swift new file mode 100644 index 0000000000000..29e6dd40dbd4b --- /dev/null +++ b/test/ClangImporter/availability_macosx_canonical_versions.swift @@ -0,0 +1,13 @@ +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -target x86_64-apple-macosx10.15 %s + +// REQUIRES: OS=macosx + +import MacOSVersionCanonicalization + +FunctionIntroducedIn10_16() +// expected-error@-1 {{'FunctionIntroducedIn10_16()' is only available in macOS 11.0 or newer}} +// expected-note@-2 {{add 'if #available' version check}} + +FunctionIntroducedIn11_0() +// expected-error@-1 {{'FunctionIntroducedIn11_0()' is only available in macOS 11.0 or newer}} +// expected-note@-2 {{add 'if #available' version check}} diff --git a/test/ClangImporter/availability_macosx_canonical_versions_appext.swift b/test/ClangImporter/availability_macosx_canonical_versions_appext.swift new file mode 100644 index 0000000000000..b6357e8a553a5 --- /dev/null +++ b/test/ClangImporter/availability_macosx_canonical_versions_appext.swift @@ -0,0 +1,13 @@ +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -I %S/Inputs/custom-modules -target x86_64-apple-macosx10.15 -application-extension %s + +// REQUIRES: OS=macosx + +import MacOSVersionCanonicalization + +FunctionIntroducedIn10_16AppExt() +// expected-error@-1 {{'FunctionIntroducedIn10_16AppExt()' is only available in application extensions for macOS 11.0 or newer}} +// expected-note@-2 {{add 'if #available' version check}} + +FunctionIntroducedIn11_0AppExt() +// expected-error@-1 {{'FunctionIntroducedIn11_0AppExt()' is only available in application extensions for macOS 11.0 or newer}} +// expected-note@-2 {{add 'if #available' version check}} diff --git a/test/Frontend/emit-interface-macos-canonical-version.swift b/test/Frontend/emit-interface-macos-canonical-version.swift new file mode 100644 index 0000000000000..e21c9348887f2 --- /dev/null +++ b/test/Frontend/emit-interface-macos-canonical-version.swift @@ -0,0 +1,18 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend -typecheck %s -enable-library-evolution -emit-module-interface-path %t/Module.swiftinterface -experimental-skip-non-inlinable-function-bodies +// RUN: %FileCheck %s --check-prefixes CHECK < %t/Module.swiftinterface + +// REQUIRES: OS=macosx + +@available(macOS 10.16, *) +public func introduced10_16() { } +// CHECK: @available(OSX 11.0, *) +// CHECK-NEXT: public func introduced10_16() + + +@available(OSX 11.0, *) +public func introduced11_0() { } +// CHECK-NEXT: @available(OSX 11.0, *) +// CHECK-NEXT: public func introduced11_0() + + diff --git a/test/IDE/print_ast_tc_decls_macosx_canonical_versions.swift b/test/IDE/print_ast_tc_decls_macosx_canonical_versions.swift new file mode 100644 index 0000000000000..86a6565b740af --- /dev/null +++ b/test/IDE/print_ast_tc_decls_macosx_canonical_versions.swift @@ -0,0 +1,16 @@ +// RUN: %empty-directory(%t) +// +// +// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -swift-version 4 -typecheck -verify %s -F %S/Inputs/mock-sdk -enable-objc-interop -disable-objc-attr-requires-foundation-module +// +// RUN: %target-swift-ide-test(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -swift-version 4 -skip-deinit=false -print-ast-typechecked -source-filename %s -F %S/Inputs/mock-sdk -function-definitions=false -prefer-type-repr=false -print-implicit-attrs=true -enable-objc-interop -disable-objc-attr-requires-foundation-module > %t.printed.txt +// RUN: %FileCheck %s -check-prefix=PASS_COMMON -strict-whitespace < %t.printed.txt + + +// FIXME: rdar://problem/19648117 Needs splitting objc parts out +// REQUIRES: objc_interop + +@available(iOS 10.16, OSX 10.16, *) +func introduced10_16() {} +// PASS_COMMON: {{^}}@available(iOS 10.16, OSX 11.0, *){{$}} +// PASS_COMMON-NEXT: {{^}}func introduced10_16(){{$}} diff --git a/test/IRGen/conditional_conformances_gettypemetdatabyname.swift b/test/IRGen/conditional_conformances_gettypemetdatabyname.swift index 28a2a50597f3d..a194e081a7a01 100644 --- a/test/IRGen/conditional_conformances_gettypemetdatabyname.swift +++ b/test/IRGen/conditional_conformances_gettypemetdatabyname.swift @@ -1,5 +1,7 @@ -// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -target %target-cpu-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME -// RUN: %target-swift-frontend -prespecialize-generic-metadata -target %target-cpu-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME_PRESPECIALIZED +// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -target %target-cpu-apple-macosx10.15.4 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME +// RUN: %target-swift-frontend -prespecialize-generic-metadata -target %target-cpu-apple-macosx99.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME_PRESPECIALIZED +// RUN: %target-swift-frontend -target %target-cpu-apple-macosx10.15.4 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=CHECK --check-prefix=CHECK-STABLE-ABI-TRUE + // Too many pointer-sized integers in the IR // REQUIRES: PTRSIZE=64 diff --git a/test/IRGen/generic_metatypes_future.swift b/test/IRGen/generic_metatypes_future.swift index 4cfaab336ad8a..cb529b255af92 100644 --- a/test/IRGen/generic_metatypes_future.swift +++ b/test/IRGen/generic_metatypes_future.swift @@ -1,5 +1,5 @@ -// RUN: %swift -prespecialize-generic-metadata -module-name generic_metatypes -target x86_64-apple-macosx10.99 -emit-ir -disable-legacy-type-info -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s +// RUN: %swift -prespecialize-generic-metadata -module-name generic_metatypes -target x86_64-apple-macosx50.99 -emit-ir -disable-legacy-type-info -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s // RUN: %swift -prespecialize-generic-metadata -module-name generic_metatypes -target x86_64-apple-ios99.0 -emit-ir -disable-legacy-type-info -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s // RUN: %swift -prespecialize-generic-metadata -module-name generic_metatypes -target x86_64-apple-tvos99.0 -emit-ir -disable-legacy-type-info -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 -DINT=i64 %s // RUN: %swift -prespecialize-generic-metadata -module-name generic_metatypes -target i386-apple-watchos9.99 -emit-ir -disable-legacy-type-info -parse-stdlib -primary-file %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 -DINT=i32 %s diff --git a/test/IRGen/osx-targets.swift b/test/IRGen/osx-targets.swift index 3b066048aef74..e828c9cb156c3 100644 --- a/test/IRGen/osx-targets.swift +++ b/test/IRGen/osx-targets.swift @@ -1,11 +1,12 @@ // RUN: %swift %s -emit-ir | %FileCheck %s -// RUN: %swift -target %target-cpu-apple-macosx10.51 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC %s -// RUN: %swift -target %target-cpu-apple-darwin55 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC %s +// RUN: %swift -target %target-cpu-apple-macosx10.51 %s -emit-ir | %FileCheck -check-prefix=CHECK-SPECIFIC-MAC-10-X %s +// RUN: %swift -target %target-cpu-apple-darwin55 %s -emit-ir | %FileCheck -check-prefix=CHECK-DARWIN-OVER-11 %s // REQUIRES: OS=macosx // CHECK: target triple = "{{.*}}-apple-macosx10. -// CHECK-SPECIFIC: target triple = "{{.*}}-apple-macosx10.51.0" +// CHECK-SPECIFIC-MAC-10-X: target triple = "{{.*}}-apple-macosx10.51.0" +// CHECK-DARWIN-OVER-11: target triple = "{{.*}}-apple-macosx46.0.0" public func anchor() {} anchor() diff --git a/test/PrintAsObjC/availability_macosx_canonical_versions.swift b/test/PrintAsObjC/availability_macosx_canonical_versions.swift new file mode 100644 index 0000000000000..fae1907434932 --- /dev/null +++ b/test/PrintAsObjC/availability_macosx_canonical_versions.swift @@ -0,0 +1,20 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %s -disable-objc-attr-requires-foundation-module +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library %t/availability_macosx_canonical_versions.swiftmodule -typecheck -emit-objc-header-path %t/availability.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module +// RUN: %FileCheck %s < %t/availability.h +// RUN: %check-in-clang %t/availability.h + +// REQUIRES: objc_interop + +// CHECK-LABEL: @interface Availability{{$}} +// CHECK-NEXT: - (void)alwaysAvailable; +// CHECK-NEXT: - (void)introducedOn10_16 +// CHECK-DAG: SWIFT_AVAILABILITY(macos,introduced=11.0) +// CHECK-DAG: SWIFT_AVAILABILITY(ios,introduced=10.16) + +@objc class Availability { + @objc func alwaysAvailable() {} + @available(macOS 10.16, *) + @available(iOS, introduced: 10.16) + @objc func introducedOn10_16() {} +} diff --git a/test/SILGen/availability_query_maccatalyst_zippered_canonical_versions.swift b/test/SILGen/availability_query_maccatalyst_zippered_canonical_versions.swift new file mode 100644 index 0000000000000..0c68ea7c8b30c --- /dev/null +++ b/test/SILGen/availability_query_maccatalyst_zippered_canonical_versions.swift @@ -0,0 +1,22 @@ +// RUN: %target-swift-emit-silgen %s -target x86_64-apple-macosx10.52 -target-variant x86_64-apple-ios50.0-macabi | %FileCheck %s +// RUN: %target-swift-emit-silgen %s -target x86_64-apple-ios50.0-macabi -target-variant x86_64-apple-macosx10.52 | %FileCheck %s + + +// REQUIRES: maccatalyst_support + +// CHECK-LABEL: sil{{.+}}@main{{.*}} { + + +// Test for the runtime non-canonical version hack for canonical macOS versioning. +// This will eventually change to be the correctly canonicalized version. + +// CHECK: [[MACOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 10 +// CHECK: [[MACOS_MINOR:%.*]] = integer_literal $Builtin.Word, 16 +// CHECK: [[MACOS_PATCH:%.*]] = integer_literal $Builtin.Word, 0 +// CHECK: [[IOS_MAJOR:%.*]] = integer_literal $Builtin.Word, 51 +// CHECK: [[IOS_MINOR:%.*]] = integer_literal $Builtin.Word, 1 +// CHECK: [[IOS_PATCH:%.*]] = integer_literal $Builtin.Word, 2 +// CHECK: [[FUNC:%.*]] = function_ref @$ss042_stdlib_isOSVersionAtLeastOrVariantVersiondE0yBi1_Bw_BwBwBwBwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1 +// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MACOS_MAJOR]], [[MACOS_MINOR]], [[MACOS_PATCH]], [[IOS_MAJOR]], [[IOS_MINOR]], [[IOS_PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1 +if #available(OSX 10.16, iOS 51.1.2, *) { +} diff --git a/test/SILGen/availability_query_macosx_canonical_versions.swift b/test/SILGen/availability_query_macosx_canonical_versions.swift new file mode 100644 index 0000000000000..becbe903eb6b1 --- /dev/null +++ b/test/SILGen/availability_query_macosx_canonical_versions.swift @@ -0,0 +1,17 @@ +// RUN: %target-swift-emit-sil %s -target %target-cpu-apple-macosx10.50 -verify +// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx10.50 | %FileCheck %s + +// REQUIRES: OS=macosx + +// CHECK-LABEL: sil{{.+}}@main{{.*}} { + +// Test for the runtime non-canonical version hack for canonical macOS versioning. +// This will eventually change to be the correctly canonicalized version. + +// CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 +// CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 16 +// CHECK: [[PATCH:%.*]] = integer_literal $Builtin.Word, 0 +// CHECK: [[FUNC:%.*]] = function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1 +// CHECK: [[QUERY_RESULT:%.*]] = apply [[FUNC]]([[MAJOR]], [[MINOR]], [[PATCH]]) : $@convention(thin) (Builtin.Word, Builtin.Word, Builtin.Word) -> Builtin.Int1 +if #available(OSX 10.16, iOS 7.1, *) { +} \ No newline at end of file diff --git a/test/Sema/availability_versions_canonical_macos.swift b/test/Sema/availability_versions_canonical_macos.swift new file mode 100644 index 0000000000000..fb18d412aa22f --- /dev/null +++ b/test/Sema/availability_versions_canonical_macos.swift @@ -0,0 +1,14 @@ +// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -disable-objc-attr-requires-foundation-module + +// REQUIRES: OS=macosx + +func markUsed(_ t: T) {} + +@available(OSX 10.16, *) +func introducedOn10_16() { } + +func useUnderPoundAvailable() { + if #available(OSX 10.16, *) { + introducedOn10_16() // no-error + } +} diff --git a/test/attr/attr_availability_canonical_macos_version.swift b/test/attr/attr_availability_canonical_macos_version.swift new file mode 100644 index 0000000000000..509ba62b2ffe0 --- /dev/null +++ b/test/attr/attr_availability_canonical_macos_version.swift @@ -0,0 +1,42 @@ +// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx11.0 %s +// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.16 %s + + +@available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 11.0, + message: "you don't want to do that anyway") +func obsoletedIn11() { } +// expected-note @-1{{'obsoletedIn11()' was obsoleted in macOS 11.0}} + +obsoletedIn11() // expected-error{{'obsoletedIn11()' is unavailable in macOS: you don't want to do that anyway}} + + +@available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 10.16, + message: "you don't want to do that anyway") +func obsoletedIn10_16() { } +// expected-note @-1{{'obsoletedIn10_16()' was obsoleted in macOS 11.0}} + +obsoletedIn10_16() // expected-error{{'obsoletedIn10_16()' is unavailable in macOS: you don't want to do that anyway}} + + +@available(OSX, deprecated: 10.16) +func deprecatedIn10_16() { } + +@available(OSX, deprecated: 10.18) +func deprecatedIn10_18() { } + +@available(OSX, deprecated: 11.0) +func deprecatedIn11_0() { } + +@available(OSX, deprecated: 13.0) +func deprecatedIn13_0() { } + +@available(OSXApplicationExtension, deprecated: 10.16) +func deprecatedIn10_16AppExtension() { } + +func useDeprecated() { + deprecatedIn10_16() // expected-warning {{deprecatedIn10_16()' was deprecated in macOS 11.0}} + deprecatedIn10_18() // expected-warning {{'deprecatedIn10_18()' was deprecated in macOS 10.18}} + deprecatedIn11_0() // expected-warning {{'deprecatedIn11_0()' was deprecated in macOS 11.0}} + + deprecatedIn13_0() // no-warning +} diff --git a/test/attr/attr_availability_canonical_macos_version_introduction.swift b/test/attr/attr_availability_canonical_macos_version_introduction.swift new file mode 100644 index 0000000000000..69409ec882144 --- /dev/null +++ b/test/attr/attr_availability_canonical_macos_version_introduction.swift @@ -0,0 +1,61 @@ +// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.15 %s + +@available(OSX, introduced: 10.16) +func longFormIntroducedIn10_16() { } + +@available(OSX, introduced: 10.18) +func longFormIntroducedIn10_18() { } + +@available(OSX, introduced: 11.0) +func longFormIntroducedIn11_0() { } + +@available(OSX, introduced: 13.0) +func longFormIntroducedIn13_0() { } + +// expected-note@+1 *{{add @available attribute to enclosing global function}} +func useLongFromIntroduced() { + longFormIntroducedIn10_16() + // expected-error@-1{{'longFormIntroducedIn10_16()' is only available in macOS 11.0 or newer}} + // expected-note@-2{{add 'if #available' version check}} + + longFormIntroducedIn10_18() + // expected-error@-1{{'longFormIntroducedIn10_18()' is only available in macOS 10.18 or newer}} + // expected-note@-2{{add 'if #available' version check}} + + longFormIntroducedIn11_0() + // expected-error@-1{{'longFormIntroducedIn11_0()' is only available in macOS 11.0 or newer}} + // expected-note@-2{{add 'if #available' version check}} + + longFormIntroducedIn13_0() + // expected-error@-1{{'longFormIntroducedIn13_0()' is only available in macOS 13.0 or newer}} + // expected-note@-2{{add 'if #available' version check}} +} + +@available(OSX 10.16, *) +func shortFormIntroducedIn10_16() { } + +@available(OSX 10.18, *) +func shortFormIntroducedIn10_18() { } + +@available(OSX 11.0, *) +func shortFormIntroducedIn11_0() { } + +@available(OSX 13.0, *) +func shortFormIntroducedIn13_0() { } + +// expected-note@+1 *{{add @available attribute to enclosing global function}} +func useShortIntroduced() { + shortFormIntroducedIn10_16() + // expected-error@-1{{'shortFormIntroducedIn10_16()' is only available in macOS 11.0 or newer}} + // expected-note@-2{{add 'if #available' version check}} + shortFormIntroducedIn10_18() + // expected-error@-1{{'shortFormIntroducedIn10_18()' is only available in macOS 10.18 or newer}} + // expected-note@-2{{add 'if #available' version check}} + shortFormIntroducedIn11_0() + // expected-error@-1{{'shortFormIntroducedIn11_0()' is only available in macOS 11.0 or newer}} + // expected-note@-2{{add 'if #available' version check}} + + shortFormIntroducedIn13_0() + // expected-error@-1{{'shortFormIntroducedIn13_0()' is only available in macOS 13.0 or newer}} + // expected-note@-2{{add 'if #available' version check}} +} diff --git a/test/attr/attr_availability_canonical_macos_version_introduction_appext.swift b/test/attr/attr_availability_canonical_macos_version_introduction_appext.swift new file mode 100644 index 0000000000000..fa4ff5ad960f0 --- /dev/null +++ b/test/attr/attr_availability_canonical_macos_version_introduction_appext.swift @@ -0,0 +1,9 @@ +// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.15 %s -application-extension + +@available(OSXApplicationExtension 11, *) +func introducedInAppExtension11_0() { } + +@available(OSXApplicationExtension 10.16, *) +func useAppExtension() { + introducedInAppExtension11_0() // no-warning +} diff --git a/test/lit.cfg b/test/lit.cfg index 0926ee9078c92..64cbffc02b4e1 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -960,7 +960,7 @@ if run_vendor == 'apple': sourcekitd_framework_dir)) config.target_run = "" - target_future_version = "10.99" + target_future_version = "99.99" if 'interpret' in lit_config.params: use_interpreter_for_simple_runs() From f3a61466ed870bac4f163516207604c579fd2add Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 2 Jul 2020 19:30:01 -0700 Subject: [PATCH 33/35] [Apple Silicon] Update tests for no macOS target triple canonicalization LLVM no longer canonicalizes target triples for maOS versions. Update tests to account for this. --- test/Driver/print_target_info_macos.swift | 2 +- test/IRGen/osx-targets.swift | 2 +- .../Interpreter/Inputs/availability_host_os.h | 2 +- test/Interpreter/availability_host_os.swift | 2 +- .../Inputs/availability_multi_other.swift | 80 +++++++++---------- test/Sema/availability_versions_multi.swift | 50 ++++++------ ...availability_canonical_macos_version.swift | 1 - 7 files changed, 69 insertions(+), 70 deletions(-) diff --git a/test/Driver/print_target_info_macos.swift b/test/Driver/print_target_info_macos.swift index eec4e0a291803..a66420b5fa595 100644 --- a/test/Driver/print_target_info_macos.swift +++ b/test/Driver/print_target_info_macos.swift @@ -7,5 +7,5 @@ // REQUIRES: OS=macosx -// CHECK: "triple": "{{.*}}-apple-macosx10 +// CHECK: "triple": "{{.*}}-apple-macosx{{[0-9][0-9]}} // CHECK: "unversionedTriple": "{{.*}}-apple-macosx" diff --git a/test/IRGen/osx-targets.swift b/test/IRGen/osx-targets.swift index e828c9cb156c3..b967650dc2f9c 100644 --- a/test/IRGen/osx-targets.swift +++ b/test/IRGen/osx-targets.swift @@ -4,7 +4,7 @@ // REQUIRES: OS=macosx -// CHECK: target triple = "{{.*}}-apple-macosx10. +// CHECK: target triple = "{{.*}}-apple-macosx{{[0-9][0-9]}}. // CHECK-SPECIFIC-MAC-10-X: target triple = "{{.*}}-apple-macosx10.51.0" // CHECK-DARWIN-OVER-11: target triple = "{{.*}}-apple-macosx46.0.0" diff --git a/test/Interpreter/Inputs/availability_host_os.h b/test/Interpreter/Inputs/availability_host_os.h index aaab1ee10f87a..b6fc096f9548c 100644 --- a/test/Interpreter/Inputs/availability_host_os.h +++ b/test/Interpreter/Inputs/availability_host_os.h @@ -2,5 +2,5 @@ static inline int mavericks() { return 9; } __attribute__((availability(macosx,introduced=10.10))) static inline int yosemite() { return 10; } - __attribute__((availability(macosx,introduced=10.99))) + __attribute__((availability(macosx,introduced=99.99))) static inline int todosSantos() { return 99; } diff --git a/test/Interpreter/availability_host_os.swift b/test/Interpreter/availability_host_os.swift index 764d9cfa4c395..3078ae252b5c4 100644 --- a/test/Interpreter/availability_host_os.swift +++ b/test/Interpreter/availability_host_os.swift @@ -14,6 +14,6 @@ print(mavericks()) // CHECK: {{^9$}} print(yosemite()) // CHECK-NEXT: {{^10$}} #if FAIL -print(todosSantos()) // expected-error {{'todosSantos()' is only available in macOS 10.99 or newer}} +print(todosSantos()) // expected-error {{'todosSantos()' is only available in macOS 99.99 or newer}} // expected-note@-1 {{add 'if #available' version check}} #endif diff --git a/test/Sema/Inputs/availability_multi_other.swift b/test/Sema/Inputs/availability_multi_other.swift index 193cd27acac1b..ccd1c58e88f25 100644 --- a/test/Sema/Inputs/availability_multi_other.swift +++ b/test/Sema/Inputs/availability_multi_other.swift @@ -3,88 +3,88 @@ // validate declarations when resolving declaration signatures. // This file relies on the minimum deployment target for OS X being 10.9. -@available(OSX, introduced: 10.52) -private class PrivateIntroduced10_52 { } +@available(OSX, introduced: 99.52) +private class PrivateIntroduced99_52 { } class OtherIntroduced10_9 { } -@available(OSX, introduced: 10.51) -class OtherIntroduced10_51 { - func uses10_52() { +@available(OSX, introduced: 99.51) +class OtherIntroduced99_51 { + func uses99_52() { // If this were the primary file then the below would emit an error, because - // PrivateIntroduced10_53 is not available on 10.52. But since we only + // PrivateIntroduced99_53 is not available on 99.52. But since we only // run the first pass of the type checker on these declarations, // the body is not checked. - _ = PrivateIntroduced10_52() + _ = PrivateIntroduced99_52() } - // This method uses a 10_52 only type in its signature, so validating + // This method uses a 99_52 only type in its signature, so validating // the declaration should produce an availability error - func returns10_52() -> OtherIntroduced10_52 { // expected-error {{'OtherIntroduced10_52' is only available in macOS 10.52 or newer}} + func returns99_52() -> OtherIntroduced99_52 { // expected-error {{'OtherIntroduced99_52' is only available in macOS 99.52 or newer}} // expected-note@-1 {{add @available attribute to enclosing instance method}} // Body is not type checked (by design) so no error is expected for unavailable type used in return. - return OtherIntroduced10_52() + return OtherIntroduced99_52() } - @available(OSX, introduced: 10.52) - func returns10_52Introduced10_52() -> OtherIntroduced10_52 { - return OtherIntroduced10_52() + @available(OSX, introduced: 99.52) + func returns99_52Introduced99_52() -> OtherIntroduced99_52 { + return OtherIntroduced99_52() } - func takes10_52(o: OtherIntroduced10_52) { + func takes99_52(o: OtherIntroduced99_52) { } - @available(OSX, introduced: 10.52) - func takes10_52Introduced10_52(o: OtherIntroduced10_52) { + @available(OSX, introduced: 99.52) + func takes99_52Introduced99_52(o: OtherIntroduced99_52) { } - var propOf10_52: OtherIntroduced10_52 = + var propOf99_52: OtherIntroduced99_52 = - OtherIntroduced10_52() // We don't expect an error here because the initializer is not type checked (by design). + OtherIntroduced99_52() // We don't expect an error here because the initializer is not type checked (by design). - @available(OSX, introduced: 10.52) - var propOf10_52Introduced10_52: OtherIntroduced10_52 = OtherIntroduced10_52() + @available(OSX, introduced: 99.52) + var propOf99_52Introduced99_52: OtherIntroduced99_52 = OtherIntroduced99_52() - @available(OSX, introduced: 10.52) - class NestedIntroduced10_52 : OtherIntroduced10_52 { - override func returns10_52() -> OtherIntroduced10_52 { + @available(OSX, introduced: 99.52) + class NestedIntroduced99_52 : OtherIntroduced99_52 { + override func returns99_52() -> OtherIntroduced99_52 { } - @available(OSX, introduced: 10.53) - func returns10_53() -> OtherIntroduced10_53 { + @available(OSX, introduced: 99.53) + func returns99_53() -> OtherIntroduced99_53 { } } } -@available(OSX, introduced: 10.51) -class SubOtherIntroduced10_51 : OtherIntroduced10_51 { +@available(OSX, introduced: 99.51) +class SubOtherIntroduced99_51 : OtherIntroduced99_51 { } -@available(OSX, introduced: 10.52) -class OtherIntroduced10_52 : OtherIntroduced10_51 { +@available(OSX, introduced: 99.52) +class OtherIntroduced99_52 : OtherIntroduced99_51 { } -extension OtherIntroduced10_51 { +extension OtherIntroduced99_51 { } extension OtherIntroduced10_9 { - @available(OSX, introduced: 10.51) - func extensionMethodOnOtherIntroduced10_9AvailableOn10_51(_ p: OtherIntroduced10_51) { } + @available(OSX, introduced: 99.51) + func extensionMethodOnOtherIntroduced10_9AvailableOn99_51(_ p: OtherIntroduced99_51) { } } -@available(OSX, introduced: 10.51) -extension OtherIntroduced10_51 { - func extensionMethodOnOtherIntroduced10_51() { } +@available(OSX, introduced: 99.51) +extension OtherIntroduced99_51 { + func extensionMethodOnOtherIntroduced99_51() { } - @available(OSX, introduced: 10.52) - func extensionMethodOnOtherIntroduced10_51AvailableOn10_52() { } + @available(OSX, introduced: 99.52) + func extensionMethodOnOtherIntroduced99_51AvailableOn99_52() { } } -@available(OSX, introduced: 10.53) -class OtherIntroduced10_53 { +@available(OSX, introduced: 99.53) +class OtherIntroduced99_53 { } -var globalFromOtherOn10_52 : OtherIntroduced10_52? = nil // expected-error {{'OtherIntroduced10_52' is only available in macOS 10.52 or newer}} +var globalFromOtherOn99_52 : OtherIntroduced99_52? = nil // expected-error {{'OtherIntroduced99_52' is only available in macOS 99.52 or newer}} // expected-note@-1 {{add @available attribute to enclosing var}} diff --git a/test/Sema/availability_versions_multi.swift b/test/Sema/availability_versions_multi.swift index d471eaa5014d9..89e61cbb7528b 100644 --- a/test/Sema/availability_versions_multi.swift +++ b/test/Sema/availability_versions_multi.swift @@ -8,54 +8,54 @@ callToEnsureNotInScriptMode() // expected-error {{expressions are not allowed at @available(OSX, introduced: 10.9) var globalAvailableOn10_9: Int = 9 -@available(OSX, introduced: 10.51) -var globalAvailableOn10_51: Int = 10 +@available(OSX, introduced: 99.51) +var globalAvailableOn99_51: Int = 10 -@available(OSX, introduced: 10.52) -var globalAvailableOn10_52: Int = 11 +@available(OSX, introduced: 99.52) +var globalAvailableOn99_52: Int = 11 // Top level should reflect the minimum deployment target. let ignored1: Int = globalAvailableOn10_9 -let ignored2: Int = globalAvailableOn10_51 // expected-error {{'globalAvailableOn10_51' is only available in macOS 10.51 or newer}} +let ignored2: Int = globalAvailableOn99_51 // expected-error {{'globalAvailableOn99_51' is only available in macOS 99.51 or newer}} // expected-note@-1 {{add @available attribute to enclosing let}} -let ignored3: Int = globalAvailableOn10_52 // expected-error {{'globalAvailableOn10_52' is only available in macOS 10.52 or newer}} +let ignored3: Int = globalAvailableOn99_52 // expected-error {{'globalAvailableOn99_52' is only available in macOS 99.52 or newer}} // expected-note@-1 {{add @available attribute to enclosing let}} -@available(OSX, introduced: 10.51) -func useFromOtherOn10_51() { - // This will trigger validation of OtherIntroduced10_51 in +@available(OSX, introduced: 99.51) +func useFromOtherOn99_51() { + // This will trigger validation of OtherIntroduced99_51 in // in availability_multi_other.swift - let o10_51 = OtherIntroduced10_51() - o10_51.extensionMethodOnOtherIntroduced10_51() + let o99_51 = OtherIntroduced99_51() + o99_51.extensionMethodOnOtherIntroduced99_51() let o10_9 = OtherIntroduced10_9() - o10_9.extensionMethodOnOtherIntroduced10_9AvailableOn10_51(o10_51) - _ = o10_51.returns10_52Introduced10_52() // expected-error {{'returns10_52Introduced10_52()' is only available in macOS 10.52 or newer}} + o10_9.extensionMethodOnOtherIntroduced10_9AvailableOn99_51(o99_51) + _ = o99_51.returns99_52Introduced99_52() // expected-error {{'returns99_52Introduced99_52()' is only available in macOS 99.52 or newer}} // expected-note@-1 {{add 'if #available' version check}} - _ = OtherIntroduced10_52() - // expected-error@-1 {{'OtherIntroduced10_52' is only available in macOS 10.52 or newer}} + _ = OtherIntroduced99_52() + // expected-error@-1 {{'OtherIntroduced99_52' is only available in macOS 99.52 or newer}} // expected-note@-2 {{add 'if #available' version check}} - o10_51.extensionMethodOnOtherIntroduced10_51AvailableOn10_52() // expected-error {{'extensionMethodOnOtherIntroduced10_51AvailableOn10_52()' is only available in macOS 10.52 or newer}} + o99_51.extensionMethodOnOtherIntroduced99_51AvailableOn99_52() // expected-error {{'extensionMethodOnOtherIntroduced99_51AvailableOn99_52()' is only available in macOS 99.52 or newer}} // expected-note@-1 {{add 'if #available' version check}} - _ = OtherIntroduced10_51.NestedIntroduced10_52() - // expected-error@-1 {{'NestedIntroduced10_52' is only available in macOS 10.52 or newer}} + _ = OtherIntroduced99_51.NestedIntroduced99_52() + // expected-error@-1 {{'NestedIntroduced99_52' is only available in macOS 99.52 or newer}} // expected-note@-2 {{add 'if #available' version check}} } -@available(OSX, introduced: 10.52) -func useFromOtherOn10_52() { - _ = OtherIntroduced10_52() +@available(OSX, introduced: 99.52) +func useFromOtherOn99_52() { + _ = OtherIntroduced99_52() - let n10_52 = OtherIntroduced10_51.NestedIntroduced10_52() - _ = n10_52.returns10_52() - _ = n10_52.returns10_53() // expected-error {{'returns10_53()' is only available in macOS 10.53 or newer}} + let n99_52 = OtherIntroduced99_51.NestedIntroduced99_52() + _ = n99_52.returns99_52() + _ = n99_52.returns99_53() // expected-error {{'returns99_53()' is only available in macOS 99.53 or newer}} // expected-note@-1 {{add 'if #available' version check}} // This will trigger validation of the global in availability_in_multi_other.swift - _ = globalFromOtherOn10_52 + _ = globalFromOtherOn99_52 } diff --git a/test/attr/attr_availability_canonical_macos_version.swift b/test/attr/attr_availability_canonical_macos_version.swift index 509ba62b2ffe0..10cf92286e255 100644 --- a/test/attr/attr_availability_canonical_macos_version.swift +++ b/test/attr/attr_availability_canonical_macos_version.swift @@ -1,5 +1,4 @@ // RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx11.0 %s -// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.16 %s @available(OSX, introduced: 10.5, deprecated: 10.8, obsoleted: 11.0, From 962ce4899e0ed221f56bb27785870536db21ffd8 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Fri, 3 Jul 2020 00:51:05 -0700 Subject: [PATCH 34/35] [Apple Silicon] Remove tvOS/watchOS simulator from Driver/linker test --- test/Driver/linker.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/Driver/linker.swift b/test/Driver/linker.swift index 922940d8f0f4e..df45af93bf0ac 100644 --- a/test/Driver/linker.swift +++ b/test/Driver/linker.swift @@ -115,8 +115,6 @@ // Check arm64 simulators first deployment version adjustment. // RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-ios13.0-simulator %s 2>&1 | %FileCheck -check-prefix ARM64_IOS_SIMULATOR_LINKER %s -// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-tvos13.0-simulator %s 2>&1 | %FileCheck -check-prefix ARM64_TVOS_SIMULATOR_LINKER %s -// RUN: %swiftc_driver -sdk "" -driver-print-jobs -target arm64-apple-watchos5.0-simulator %s 2>&1 | %FileCheck -check-prefix ARM64_WATCHOS_SIMULATOR_LINKER %s // MACOS_10_15: -platform_version macos 10.9.0 10.15.0 @@ -127,8 +125,6 @@ // X86_MACOS11_LINKER: -platform_version macos 10.16.0 // X86_64_WATCHOS_SIM_LINKER: -platform_version watchos-simulator 7.0.0 // ARM64_IOS_SIMULATOR_LINKER: -platform_version ios-simulator 14.0.0 -// ARM64_TVOS_SIMULATOR_LINKER: -platform_version tvos-simulator 14.0.0 -// ARM64_WATCHOS_SIMULATOR_LINKER: -platform_version watchos-simulator 7.0.0 // There are more RUN lines further down in the file. From 7016cb57aec3d91856089de4c5461168ed127875 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Mon, 6 Jul 2020 23:27:34 +0900 Subject: [PATCH 35/35] [WASM] Resolve build failure by fixing cross compile issue on build-script The added lines by Apple Silicon patch really depend on the build machine platform and it forces that we can build stdlib only for darwin targets. So I changed to allow non-darwin targets and filter only unsupported darwin targets. This patch shuold be sent to upstream. --- utils/build-script | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/utils/build-script b/utils/build-script index a5cc412d037d1..6b8222fe49049 100755 --- a/utils/build-script +++ b/utils/build-script @@ -367,16 +367,15 @@ def apply_default_arguments(toolchain, args): # Filter out any macOS stdlib deployment targets that are not supported # by the macOS SDK. - if platform.system() == "Darwin": - targets = StdlibDeploymentTarget.get_targets_by_name( - args.stdlib_deployment_targets) - args.stdlib_deployment_targets = [ - target.name - for target in targets - if (target.platform.is_darwin and - target.platform.sdk_supports_architecture( - target.arch, args.darwin_xcrun_toolchain)) - ] + targets = StdlibDeploymentTarget.get_targets_by_name( + args.stdlib_deployment_targets) + args.stdlib_deployment_targets = [ + target.name + for target in targets + if (not target.platform.is_darwin or + target.platform.sdk_supports_architecture( + target.arch, args.darwin_xcrun_toolchain)) + ] # Include the Darwin module-only architectures in the CMake options. if args.swift_darwin_module_archs: