diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -633,4 +633,8 @@ "invalid or unsupported offload target: '%0'">; def err_drv_cuda_offload_only_emit_bc : Error< "CUDA offload target is supported only along with --emit-llvm">; + +def err_drv_target_variant_invalid : Error< + "unsupported '%0' value '%1'; use 'ios-macabi' instead">; + } diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3976,6 +3976,9 @@ def s : Flag<["-"], "s">, Group; def target : Joined<["--"], "target=">, Flags<[NoXarchOption, CoreOption]>, HelpText<"Generate code for the given target">; +def darwin_target_variant : Separate<["-"], "darwin-target-variant">, + Flags<[NoXarchOption, CoreOption]>, + HelpText<"Generate code for an additional runtime variant of the deployment target">; def print_supported_cpus : Flag<["-", "--"], "print-supported-cpus">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Print supported cpu models for the given target (if target is not specified," diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -310,6 +310,9 @@ /// The information about the darwin SDK that was used. mutable Optional SDKInfo; + /// The target variant triple that was specified (if any). + mutable Optional TargetVariantTriple; + CudaInstallationDetector CudaInstallation; RocmInstallationDetector RocmInstallation; diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1478,6 +1478,10 @@ /// Returns true if the simulator environment can be inferred from the arch. bool canInferSimulatorFromArch() const { return InferSimulatorFromArch; } + const Optional &getTargetVariantTriple() const { + return TargetVariantTriple; + } + /// Adds the -m-version-min argument to the compiler invocation. void addOSVersionMinArgument(DerivedArgList &Args, const OptTable &Opts) { if (Argument) @@ -1540,6 +1544,16 @@ } } } + // In a zippered build, we could be building for a macOS target that's + // lower than the version that's implied by the OS version. In that case + // we need to use the minimum version as the native target version. + if (TargetVariantTriple) { + auto TargetVariantVersion = TargetVariantTriple->getOSVersion(); + if (TargetVariantVersion.getMajor()) { + if (TargetVariantVersion < NativeTargetVersion) + NativeTargetVersion = TargetVariantVersion; + } + } break; } default: @@ -1549,12 +1563,14 @@ static DarwinPlatform createFromTarget(const llvm::Triple &TT, StringRef OSVersion, Arg *A, + Optional TargetVariantTriple, const Optional &SDKInfo) { DarwinPlatform Result(TargetArg, getPlatformFromOS(TT.getOS()), OSVersion, A); VersionTuple OsVersion = TT.getOSVersion(); if (OsVersion.getMajor() == 0) Result.HasOSVersion = false; + Result.TargetVariantTriple = TargetVariantTriple; Result.setEnvironment(TT.getEnvironment(), OsVersion, SDKInfo); return Result; } @@ -1638,6 +1654,7 @@ bool HasOSVersion = true, InferSimulatorFromArch = true; Arg *Argument; StringRef EnvVarName; + Optional TargetVariantTriple; }; /// Returns the deployment target that's specified using the -m-version-min @@ -1863,7 +1880,6 @@ else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" && MachOArchName != "armv7em") OSTy = llvm::Triple::MacOSX; - if (OSTy == llvm::Triple::UnknownOS) return None; return DarwinPlatform::createFromArch(OSTy, @@ -1880,8 +1896,34 @@ Triple.getOS() == llvm::Triple::UnknownOS) return None; std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver); - return DarwinPlatform::createFromTarget( - Triple, OSVersion, Args.getLastArg(options::OPT_target), SDKInfo); + Optional TargetVariantTriple; + for (const Arg *A : Args.filtered(options::OPT_darwin_target_variant)) { + llvm::Triple TVT(A->getValue()); + // Find a matching - target variant triple that can be used. + if ((Triple.getArch() == llvm::Triple::aarch64 || + TVT.getArchName() == Triple.getArchName()) && + TVT.getArch() == Triple.getArch() && + TVT.getSubArch() == Triple.getSubArch() && + TVT.getVendor() == Triple.getVendor()) { + if (TargetVariantTriple) + continue; + A->claim(); + // Accept a -target-variant triple when compiling code that may run on + // macOS or Mac Catalust. + if ((Triple.isMacOSX() && TVT.getOS() == llvm::Triple::IOS && + TVT.isMacCatalystEnvironment()) || + (TVT.isMacOSX() && Triple.getOS() == llvm::Triple::IOS && + Triple.isMacCatalystEnvironment())) { + TargetVariantTriple = TVT; + continue; + } + TheDriver.Diag(diag::err_drv_target_variant_invalid) + << A->getSpelling() << A->getValue(); + } + } + return DarwinPlatform::createFromTarget(Triple, OSVersion, + Args.getLastArg(options::OPT_target), + TargetVariantTriple, SDKInfo); } /// Returns the deployment target that's specified using the -mtargetos option. @@ -2116,6 +2158,7 @@ if (Environment == MacCatalyst) NativeTargetVersion = OSTarget->getNativeTargetVersion(); setTarget(Platform, Environment, Major, Minor, Micro, NativeTargetVersion); + TargetVariantTriple = OSTarget->getTargetVariantTriple(); if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { StringRef SDK = getSDKName(A->getValue()); @@ -2635,6 +2678,12 @@ isAlignedAllocationUnavailable()) CC1Args.push_back("-faligned-alloc-unavailable"); + if (TargetVariantTriple) { + CC1Args.push_back("-darwin-target-variant-triple"); + CC1Args.push_back( + DriverArgs.MakeArgString(TargetVariantTriple->getTriple())); + } + if (SDKInfo) { /// Pass the SDK version to the compiler when the SDK information is /// available. @@ -2656,6 +2705,28 @@ } else { EmitTargetSDKVersionArg(SDKInfo->getVersion()); } + + /// Pass the target variant SDK version to the compiler when the SDK + /// information is available and is required for target variant. + if (TargetVariantTriple) { + if (isTargetMacCatalyst()) { + std::string Arg; + llvm::raw_string_ostream OS(Arg); + OS << "-darwin-target-variant-sdk-version=" << SDKInfo->getVersion(); + CC1Args.push_back(DriverArgs.MakeArgString(OS.str())); + } else if (const auto *MacOStoMacCatalystMapping = + SDKInfo->getVersionMapping( + DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) { + if (Optional SDKVersion = MacOStoMacCatalystMapping->map( + SDKInfo->getVersion(), minimumMacCatalystDeploymentTarget(), + None)) { + std::string Arg; + llvm::raw_string_ostream OS(Arg); + OS << "-darwin-target-variant-sdk-version=" << *SDKVersion; + CC1Args.push_back(DriverArgs.MakeArgString(OS.str())); + } + } + } } // Enable compatibility mode for NSItemProviderCompletionHandler in @@ -2816,6 +2887,25 @@ if (!MinTgtVers.empty() && MinTgtVers > TargetVersion) TargetVersion = MinTgtVers; CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + if (TargetVariantTriple) { + assert(isTargetMacOSBased() && "unexpected target"); + VersionTuple VariantTargetVersion; + if (TargetVariantTriple->isMacOSX()) { + CmdArgs.push_back("-macosx_version_min"); + TargetVariantTriple->getMacOSXVersion(VariantTargetVersion); + } else { + assert(TargetVariantTriple->isiOS() && + TargetVariantTriple->isMacCatalystEnvironment() && + "unexpected target variant triple"); + CmdArgs.push_back("-maccatalyst_version_min"); + VariantTargetVersion = TargetVariantTriple->getiOSVersion(); + } + VersionTuple MinTgtVers = + TargetVariantTriple->getMinimumSupportedOSVersion(); + if (MinTgtVers.getMajor() && MinTgtVers > VariantTargetVersion) + VariantTargetVersion = MinTgtVers; + CmdArgs.push_back(Args.MakeArgString(VariantTargetVersion.getAsString())); + } } static const char *getPlatformName(Darwin::DarwinPlatformKind Platform, @@ -2837,52 +2927,88 @@ void Darwin::addPlatformVersionArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const { - // -platform_version - // Both the target and SDK version support only up to 3 components. - CmdArgs.push_back("-platform_version"); - std::string PlatformName = getPlatformName(TargetPlatform, TargetEnvironment); - if (TargetEnvironment == Darwin::Simulator) - PlatformName += "-simulator"; - CmdArgs.push_back(Args.MakeArgString(PlatformName)); - VersionTuple TargetVersion = getTripleTargetVersion().withoutBuild(); - VersionTuple MinTgtVers = getEffectiveTriple().getMinimumSupportedOSVersion(); - if (!MinTgtVers.empty() && MinTgtVers > TargetVersion) - TargetVersion = MinTgtVers; - CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + auto EmitPlatformVersionArg = + [&](const VersionTuple &TV, Darwin::DarwinPlatformKind TargetPlatform, + Darwin::DarwinEnvironmentKind TargetEnvironment, + const llvm::Triple &TT) { + // -platform_version + // Both the target and SDK version support only up to 3 components. + CmdArgs.push_back("-platform_version"); + std::string PlatformName = + getPlatformName(TargetPlatform, TargetEnvironment); + if (TargetEnvironment == Darwin::Simulator) + PlatformName += "-simulator"; + CmdArgs.push_back(Args.MakeArgString(PlatformName)); + VersionTuple TargetVersion = TV.withoutBuild(); + if ((TargetPlatform == Darwin::IPhoneOS || + TargetPlatform == Darwin::TvOS) && + getTriple().getArchName() == "arm64e" && + TargetVersion.getMajor() < 14) { + // arm64e slice is supported on iOS/tvOS 14+ only. + TargetVersion = VersionTuple(14, 0); + } + VersionTuple MinTgtVers = TT.getMinimumSupportedOSVersion(); + if (!MinTgtVers.empty() && MinTgtVers > TargetVersion) + TargetVersion = MinTgtVers; + CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + + if (TargetPlatform == IPhoneOS && TargetEnvironment == MacCatalyst) { + // Mac Catalyst programs must use the appropriate iOS SDK version + // that corresponds to the macOS SDK version used for the compilation. + Optional iOSSDKVersion; + if (SDKInfo) { + if (const auto *MacOStoMacCatalystMapping = + SDKInfo->getVersionMapping( + DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) { + iOSSDKVersion = MacOStoMacCatalystMapping->map( + SDKInfo->getVersion().withoutBuild(), + minimumMacCatalystDeploymentTarget(), None); + } + } + CmdArgs.push_back(Args.MakeArgString( + (iOSSDKVersion ? *iOSSDKVersion + : minimumMacCatalystDeploymentTarget()) + .getAsString())); + return; + } - if (isTargetMacCatalyst()) { - // Mac Catalyst programs must use the appropriate iOS SDK version - // that corresponds to the macOS SDK version used for the compilation. - Optional iOSSDKVersion; - if (SDKInfo) { - if (const auto *MacOStoMacCatalystMapping = SDKInfo->getVersionMapping( - DarwinSDKInfo::OSEnvPair::macOStoMacCatalystPair())) { - iOSSDKVersion = MacOStoMacCatalystMapping->map( - SDKInfo->getVersion().withoutBuild(), - minimumMacCatalystDeploymentTarget(), None); - } - } - CmdArgs.push_back(Args.MakeArgString( - (iOSSDKVersion ? *iOSSDKVersion : minimumMacCatalystDeploymentTarget()) - .getAsString())); + if (SDKInfo) { + VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild(); + CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString())); + } else { + // Use an SDK version that's matching the deployment target if the SDK + // version is missing. This is preferred over an empty SDK version + // (0.0.0) as the system's runtime might expect the linked binary to + // contain a valid SDK version in order for the binary to work + // correctly. It's reasonable to use the deployment target version as + // a proxy for the SDK version because older SDKs don't guarantee + // support for deployment targets newer than the SDK versions, so that + // rules out using some predetermined older SDK version, which leaves + // the deployment target version as the only reasonable choice. + CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + } + }; + EmitPlatformVersionArg(getTripleTargetVersion(), TargetPlatform, + TargetEnvironment, getEffectiveTriple()); + if (!TargetVariantTriple) return; - } - - if (SDKInfo) { - VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild(); - CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString())); + Darwin::DarwinPlatformKind Platform; + Darwin::DarwinEnvironmentKind Environment; + VersionTuple TargetVariantVersion; + if (TargetVariantTriple->isMacOSX()) { + TargetVariantTriple->getMacOSXVersion(TargetVariantVersion); + Platform = Darwin::MacOS; + Environment = Darwin::NativeEnvironment; } else { - // Use an SDK version that's matching the deployment target if the SDK - // version is missing. This is preferred over an empty SDK version (0.0.0) - // as the system's runtime might expect the linked binary to contain a - // valid SDK version in order for the binary to work correctly. It's - // reasonable to use the deployment target version as a proxy for the - // SDK version because older SDKs don't guarantee support for deployment - // targets newer than the SDK versions, so that rules out using some - // predetermined older SDK version, which leaves the deployment target - // version as the only reasonable choice. - CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); - } + assert(TargetVariantTriple->isiOS() && + TargetVariantTriple->isMacCatalystEnvironment() && + "unexpected target variant triple"); + TargetVariantVersion = TargetVariantTriple->getiOSVersion(); + Platform = Darwin::IPhoneOS; + Environment = Darwin::MacCatalyst; + } + EmitPlatformVersionArg(TargetVariantVersion, Platform, Environment, + *TargetVariantTriple); } // Add additional link args for the -dynamiclib option. diff --git a/clang/test/Driver/darwin-ld-platform-version-target-version.c b/clang/test/Driver/darwin-ld-platform-version-target-version.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/darwin-ld-platform-version-target-version.c @@ -0,0 +1,30 @@ +// RUN: touch %t.o + +// RUN: %clang -target x86_64-apple-ios13.1-macabi -darwin-target-variant x86_64-apple-macos10.15 -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -mlinker-version=520 -### %t.o 2>&1 \ +// RUN: | FileCheck %s +// RUN: %clang -target x86_64-apple-macos10.14.3 -darwin-target-variant x86_64-apple-ios13.1-macabi -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -mlinker-version=520 -### %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-INV %s + +// RUN: %clang -target arm64-apple-ios13.1-macabi -darwin-target-variant arm64-apple-macos10.15 -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -mlinker-version=520 -### %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=ARM64_NEW %s +// RUN: %clang -target arm64-apple-macos10.15 -darwin-target-variant arm64-apple-ios13.1-macabi -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -mlinker-version=520 -### %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=ARM64_NEW-INV %s +// RUN: %clang -target arm64-apple-ios13.1-macabi -darwin-target-variant arm64-apple-macos10.15 -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -mlinker-version=400 -### %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=ARM64_OLD %s +// RUN: %clang -target arm64-apple-macos10.15 -darwin-target-variant arm64-apple-ios13.1-macabi -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -mlinker-version=400 -### %t.o 2>&1 \ +// RUN: | FileCheck --check-prefix=ARM64_OLD-INV %s + +// CHECK: "-platform_version" "mac catalyst" "13.1.0" "13.1" +// CHECK-SAME: "-platform_version" "macos" "10.15" "10.15" + +// CHECK-INV: "-platform_version" "macos" "10.14.3" "10.15" +// CHECK-INV-SAME: "-platform_version" "mac catalyst" "13.1" "13.1" + +// ARM64_NEW: "-platform_version" "mac catalyst" "14.0.0" "13.1" +// ARM64_NEW-SAME: "-platform_version" "macos" "11.0.0" "10.15" + +// ARM64_NEW-INV: "-platform_version" "macos" "11.0.0" "10.15" +// ARM64_NEW-INV-SAME: "-platform_version" "mac catalyst" "14.0.0" "13.1" + +// ARM64_OLD: "-maccatalyst_version_min" "14.0.0" "-macosx_version_min" "11.0.0" +// ARM64_OLD-INV: "-macosx_version_min" "11.0.0" "-maccatalyst_version_min" "14.0.0" diff --git a/clang/test/Driver/darwin-objc-runtime-maccatalyst-target-variant.m b/clang/test/Driver/darwin-objc-runtime-maccatalyst-target-variant.m new file mode 100644 --- /dev/null +++ b/clang/test/Driver/darwin-objc-runtime-maccatalyst-target-variant.m @@ -0,0 +1,9 @@ +// RUN: %clang -target x86_64-apple-ios13.2-macabi -darwin-target-variant x86_64-apple-macos10.15.3-macos -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -c %s -### 2>&1 \ +// RUN: | FileCheck %s +// RUN: %clang -target x86_64-apple-macos10.15.1 -darwin-target-variant x86_64-apple-ios13.2-macabi -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -c %s -### 2>&1 \ +// RUN: | FileCheck %s +// RUN: %clang -target x86_64-apple-ios13.2-macabi -darwin-target-variant x86_64-apple-macos10.15-macos -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -c %s -### 2>&1 \ +// RUN: | FileCheck --check-prefix=LOWER %s + +// CHECK: -fobjc-runtime=macosx-10.15.1 +// LOWER: -fobjc-runtime=macosx-10.15 diff --git a/clang/test/Driver/darwin-target-variant-sdk-version.c b/clang/test/Driver/darwin-target-variant-sdk-version.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/darwin-target-variant-sdk-version.c @@ -0,0 +1,12 @@ +// RUN: %clang -target x86_64-apple-macosx10.15 -darwin-target-variant x86_64-apple-ios13.1-macabi -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -c -### %s 2>&1 \ +// RUN: | FileCheck %s +// RUN: env SDKROOT=%S/Inputs/MacOSX10.15.versioned.sdk %clang -target x86_64-apple-macosx10.15 -darwin-target-variant x86_64-apple-ios13.1-macabi -c -### %s 2>&1 \ +// RUN: | FileCheck %s +// RUN: %clang -target x86_64-apple-ios13.1-macabi -darwin-target-variant x86_64-apple-macosx10.15 -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -c -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-SWAPPED %s +// RUN: %clang -target x86_64-apple-ios13.1-macabi -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -c -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MACCATALYST %s + +// CHECK: "-target-sdk-version=10.15" "-darwin-target-variant-sdk-version=13.1" +// CHECK-SWAPPED: "-target-sdk-version=13.1" "-darwin-target-variant-sdk-version=10.15" +// CHECK-MACCATALYST: "-target-sdk-version=13.1" diff --git a/clang/test/Driver/darwin-target-variant.c b/clang/test/Driver/darwin-target-variant.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/darwin-target-variant.c @@ -0,0 +1,32 @@ +// RUN: %clang -target unknown-apple-macos10.15 -arch x86_64 -arch x86_64h -arch i386 \ +// RUN: -darwin-target-variant x86_64-apple-ios13.1-macabi -darwin-target-variant x86_64h-apple-ios13.1-macabi \ +// RUN: -c %s -### 2>&1 | FileCheck %s + +// RUN: %clang -target x86_64-apple-macos10.15 -darwin-target-variant i386-apple-ios13.1-macabi \ +// RUN: -c %s -### 2>&1 | FileCheck --check-prefix=UNUSED-TV %s + +// RUN: %clang -target x86_64-apple-macos10.15 -darwin-target-variant x86_64-apple-ios13.1-macabi \ +// RUN: -darwin-target-variant x86_64-apple-ios13.1-macabi -c %s -### 2>&1 | FileCheck --check-prefix=REDUNDANT-TV %s + +// RUN: %clang -target x86_64-apple-macos10.15 -darwin-target-variant x86_64-apple-ios13.1 \ +// RUN: -c %s -### 2>&1 | FileCheck --check-prefix=INCORRECT-TV %s + +// RUN: %clang -target unknown-apple-ios13.1-macabi -arch x86_64 -arch x86_64h \ +// RUN: -darwin-target-variant x86_64-apple-macos10.15 \ +// RUN: -c %s -### 2>&1 | FileCheck --check-prefix=INVERTED %s + +// CHECK: "-triple" "x86_64-apple-macosx10.15.0" +// CHECK-SAME: "-darwin-target-variant-triple" "x86_64-apple-ios13.1-macabi" +// CHECK: "-triple" "x86_64h-apple-macosx10.15.0" +// CHECK-SAME: "-darwin-target-variant-triple" "x86_64h-apple-ios13.1-macabi" +// CHECK: "-triple" "i386-apple-macosx10.15.0" +// CHECK-NOT: target-variant-triple + +// INVERTED: "-triple" "x86_64-apple-ios13.1.0-macabi" +// INVERTED-SAME: "-darwin-target-variant-triple" "x86_64-apple-macos10.15" +// INVERTED: "-triple" "x86_64h-apple-ios13.1.0-macabi" +// INVERTED-NOT: target-variant-triple + +// UNUSED-TV: argument unused during compilation: '-darwin-target-variant i386-apple-ios13.1-macabi' +// REDUNDANT-TV: argument unused during compilation: '-darwin-target-variant x86_64-apple-ios13.1-macabi' +// INCORRECT-TV: unsupported '-darwin-target-variant' value 'x86_64-apple-ios13.1'; use 'ios-macabi' instead diff --git a/clang/test/Driver/darwin-zippered-target-version.c b/clang/test/Driver/darwin-zippered-target-version.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/darwin-zippered-target-version.c @@ -0,0 +1,16 @@ +// RUN: %clang -target unknown-apple-macos10.15 -arch x86_64 -arch x86_64h -arch i386 \ +// RUN: -darwin-target-variant x86_64-apple-ios13.1-macabi -darwin-target-variant x86_64h-apple-ios13.1-macabi \ +// RUN: %s -mlinker-version=400 -### 2>&1 | FileCheck %s + +// RUN: %clang -target unknown-apple-ios13.1-macabi -arch x86_64 -arch x86_64h \ +// RUN: -darwin-target-variant x86_64-apple-macos10.15 \ +// RUN: %s -mlinker-version=400 -### 2>&1 | FileCheck --check-prefix=INVERTED %s + +// CHECK: "-arch" "x86_64" "-macosx_version_min" "10.15.0" "-maccatalyst_version_min" "13.1" +// CHECK: "-arch" "x86_64h" "-macosx_version_min" "10.15.0" "-maccatalyst_version_min" "13.1" +// CHECK: "-arch" "i386" "-macosx_version_min" "10.15.0" +// CHECK-NOT: maccatalyst_version_min + +// INVERTED: "-arch" "x86_64" "-maccatalyst_version_min" "13.1.0" "-macosx_version_min" "10.15" +// INVERTED: "-arch" "x86_64h" "-maccatalyst_version_min" "13.1.0" +// INVERTED-NOT: macosx_version_min