Index: lib/Driver/ToolChains/Darwin.cpp =================================================================== --- lib/Driver/ToolChains/Darwin.cpp +++ lib/Driver/ToolChains/Darwin.cpp @@ -1231,157 +1231,201 @@ << WatchOSVersion->getAsString(Args); WatchOSVersion = nullptr; } else if (!OSXVersion && !iOSVersion && !TvOSVersion && !WatchOSVersion) { - // If no deployment target was specified on the command line, check for - // environment defines. - std::string OSXTarget; - std::string iOSTarget; - std::string TvOSTarget; - std::string WatchOSTarget; - - if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET")) - OSXTarget = env; - if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET")) - iOSTarget = env; - if (char *env = ::getenv("TVOS_DEPLOYMENT_TARGET")) - TvOSTarget = env; - if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET")) - WatchOSTarget = env; - - if (!iOSTarget.empty()) - ExplicitIOSDeploymentTargetStr = - std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget; - - // If there is no command-line argument to specify the Target version and - // no environment variable defined, see if we can set the default based - // on -isysroot. - if (OSXTarget.empty() && iOSTarget.empty() && WatchOSTarget.empty() && - TvOSTarget.empty() && Args.hasArg(options::OPT_isysroot)) { - if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { - StringRef isysroot = A->getValue(); - StringRef SDK = getSDKName(isysroot); - if (SDK.size() > 0) { - // Slice the version number out. - // Version number is between the first and the last number. - size_t StartVer = SDK.find_first_of("0123456789"); - size_t EndVer = SDK.find_last_of("0123456789"); - if (StartVer != StringRef::npos && EndVer > StartVer) { - StringRef Version = SDK.slice(StartVer, EndVer + 1); - if (SDK.startswith("iPhoneOS") || - SDK.startswith("iPhoneSimulator")) - iOSTarget = Version; - else if (SDK.startswith("MacOSX")) - OSXTarget = getSystemOrSDKMacOSVersion(Version); - else if (SDK.startswith("WatchOS") || - SDK.startswith("WatchSimulator")) - WatchOSTarget = Version; - else if (SDK.startswith("AppleTVOS") || - SDK.startswith("AppleTVSimulator")) - TvOSTarget = Version; + // The -target option specifies the deployment target when + // -m-version-min is not given and the OS version is present in the + // target. + if (Args.hasArg(options::OPT_target) && getTriple().getOSMajorVersion() && + getTriple().isOSDarwin()) { + unsigned Major, Minor, Micro; + auto RewriteVersionMinArg = [&](options::ID O) -> Arg * { + std::string Version; + llvm::raw_string_ostream(Version) + << Major << '.' << Minor << '.' << Micro; + Arg *A = Args.MakeJoinedArg(nullptr, Opts.getOption(O), Version); + Args.append(A); + return A; + }; + + // FIXME: Take the -simulator environment into account. + switch (getTriple().getOS()) { + case llvm::Triple::Darwin: + case llvm::Triple::MacOSX: + getTriple().getMacOSXVersion(Major, Minor, Micro); + OSXVersion = RewriteVersionMinArg(options::OPT_mmacosx_version_min_EQ); + break; + case llvm::Triple::IOS: + case llvm::Triple::TvOS: + getTriple().getiOSVersion(Major, Minor, Micro); + if (getTriple().getOS() == llvm::Triple::IOS) { + iOSVersion = + RewriteVersionMinArg(options::OPT_miphoneos_version_min_EQ); + ExplicitIOSDeploymentTargetStr = + std::string("ios") + iOSVersion->getValue(); + } else + TvOSVersion = RewriteVersionMinArg(options::OPT_mtvos_version_min_EQ); + break; + case llvm::Triple::WatchOS: + getTriple().getWatchOSVersion(Major, Minor, Micro); + WatchOSVersion = + RewriteVersionMinArg(options::OPT_mwatchos_version_min_EQ); + break; + default: + llvm_unreachable("invalid Os"); + } + } else { + + // If no deployment target was specified on the command line, check for + // environment defines. + std::string OSXTarget; + std::string iOSTarget; + std::string TvOSTarget; + std::string WatchOSTarget; + + if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET")) + OSXTarget = env; + if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET")) + iOSTarget = env; + if (char *env = ::getenv("TVOS_DEPLOYMENT_TARGET")) + TvOSTarget = env; + if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET")) + WatchOSTarget = env; + + if (!iOSTarget.empty()) + ExplicitIOSDeploymentTargetStr = + std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget; + + // If there is no command-line argument to specify the Target version and + // no environment variable defined, see if we can set the default based + // on -isysroot. + if (OSXTarget.empty() && iOSTarget.empty() && WatchOSTarget.empty() && + TvOSTarget.empty() && Args.hasArg(options::OPT_isysroot)) { + if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { + StringRef isysroot = A->getValue(); + StringRef SDK = getSDKName(isysroot); + if (SDK.size() > 0) { + // Slice the version number out. + // Version number is between the first and the last number. + size_t StartVer = SDK.find_first_of("0123456789"); + size_t EndVer = SDK.find_last_of("0123456789"); + if (StartVer != StringRef::npos && EndVer > StartVer) { + StringRef Version = SDK.slice(StartVer, EndVer + 1); + if (SDK.startswith("iPhoneOS") || + SDK.startswith("iPhoneSimulator")) + iOSTarget = Version; + else if (SDK.startswith("MacOSX")) + OSXTarget = getSystemOrSDKMacOSVersion(Version); + else if (SDK.startswith("WatchOS") || + SDK.startswith("WatchSimulator")) + WatchOSTarget = Version; + else if (SDK.startswith("AppleTVOS") || + SDK.startswith("AppleTVSimulator")) + TvOSTarget = Version; + } } } } - } - // If no OS targets have been specified, try to guess platform from -target - // or arch name and compute the version from the triple. - if (OSXTarget.empty() && iOSTarget.empty() && TvOSTarget.empty() && - WatchOSTarget.empty()) { - llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS; + // If no OS targets have been specified, try to guess platform from + // -target or arch name and compute the version from the triple. + if (OSXTarget.empty() && iOSTarget.empty() && TvOSTarget.empty() && + WatchOSTarget.empty()) { + llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS; - // Set the OSTy based on -target if -arch isn't present. - if (Args.hasArg(options::OPT_target) && !Args.hasArg(options::OPT_arch)) { - OSTy = getTriple().getOS(); - } else { StringRef MachOArchName = getMachOArchName(Args); - if (MachOArchName == "armv7" || MachOArchName == "armv7s" || - MachOArchName == "arm64") - OSTy = llvm::Triple::IOS; - else if (MachOArchName == "armv7k") - OSTy = llvm::Triple::WatchOS; - else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" && - MachOArchName != "armv7em") - OSTy = llvm::Triple::MacOSX; - } + // Set the OSTy based on -target if -arch isn't present. + if (Args.hasArg(options::OPT_target) && + !Args.hasArg(options::OPT_arch)) { + OSTy = getTriple().getOS(); + } else { + if (MachOArchName == "armv7" || MachOArchName == "armv7s" || + MachOArchName == "arm64") + OSTy = llvm::Triple::IOS; + else if (MachOArchName == "armv7k") + OSTy = llvm::Triple::WatchOS; + else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" && + MachOArchName != "armv7em") + OSTy = llvm::Triple::MacOSX; + } + if (OSTy != llvm::Triple::UnknownOS) { + unsigned Major, Minor, Micro; + std::string *OSTarget; + + switch (OSTy) { + case llvm::Triple::Darwin: + case llvm::Triple::MacOSX: + if (!getTriple().getMacOSXVersion(Major, Minor, Micro)) + getDriver().Diag(diag::err_drv_invalid_darwin_version) + << getTriple().getOSName(); + OSTarget = &OSXTarget; + break; + case llvm::Triple::IOS: + getTriple().getiOSVersion(Major, Minor, Micro); + OSTarget = &iOSTarget; + break; + case llvm::Triple::TvOS: + getTriple().getOSVersion(Major, Minor, Micro); + OSTarget = &TvOSTarget; + break; + case llvm::Triple::WatchOS: + getTriple().getWatchOSVersion(Major, Minor, Micro); + OSTarget = &WatchOSTarget; + break; + default: + llvm_unreachable("Unexpected OS type"); + break; + } - if (OSTy != llvm::Triple::UnknownOS) { - unsigned Major, Minor, Micro; - std::string *OSTarget; - - switch (OSTy) { - case llvm::Triple::Darwin: - case llvm::Triple::MacOSX: - if (!getTriple().getMacOSXVersion(Major, Minor, Micro)) - getDriver().Diag(diag::err_drv_invalid_darwin_version) - << getTriple().getOSName(); - OSTarget = &OSXTarget; - break; - case llvm::Triple::IOS: - getTriple().getiOSVersion(Major, Minor, Micro); - OSTarget = &iOSTarget; - break; - case llvm::Triple::TvOS: - getTriple().getOSVersion(Major, Minor, Micro); - OSTarget = &TvOSTarget; - break; - case llvm::Triple::WatchOS: - getTriple().getWatchOSVersion(Major, Minor, Micro); - OSTarget = &WatchOSTarget; - break; - default: - llvm_unreachable("Unexpected OS type"); - break; + llvm::raw_string_ostream(*OSTarget) + << Major << '.' << Minor << '.' << Micro; } - - llvm::raw_string_ostream(*OSTarget) << Major << '.' << Minor << '.' - << Micro; } - } - // Do not allow conflicts with the watchOS target. - if (!WatchOSTarget.empty() && (!iOSTarget.empty() || !TvOSTarget.empty())) { - getDriver().Diag(diag::err_drv_conflicting_deployment_targets) - << "WATCHOS_DEPLOYMENT_TARGET" - << (!iOSTarget.empty() ? "IPHONEOS_DEPLOYMENT_TARGET" : - "TVOS_DEPLOYMENT_TARGET"); - } + // Do not allow conflicts with the watchOS target. + if (!WatchOSTarget.empty() && + (!iOSTarget.empty() || !TvOSTarget.empty())) { + getDriver().Diag(diag::err_drv_conflicting_deployment_targets) + << "WATCHOS_DEPLOYMENT_TARGET" + << (!iOSTarget.empty() ? "IPHONEOS_DEPLOYMENT_TARGET" + : "TVOS_DEPLOYMENT_TARGET"); + } - // Do not allow conflicts with the tvOS target. - if (!TvOSTarget.empty() && !iOSTarget.empty()) { - getDriver().Diag(diag::err_drv_conflicting_deployment_targets) - << "TVOS_DEPLOYMENT_TARGET" - << "IPHONEOS_DEPLOYMENT_TARGET"; - } + // Do not allow conflicts with the tvOS target. + if (!TvOSTarget.empty() && !iOSTarget.empty()) { + getDriver().Diag(diag::err_drv_conflicting_deployment_targets) + << "TVOS_DEPLOYMENT_TARGET" + << "IPHONEOS_DEPLOYMENT_TARGET"; + } - // Allow conflicts among OSX and iOS for historical reasons, but choose the - // default platform. - if (!OSXTarget.empty() && (!iOSTarget.empty() || - !WatchOSTarget.empty() || - !TvOSTarget.empty())) { - if (getTriple().getArch() == llvm::Triple::arm || - getTriple().getArch() == llvm::Triple::aarch64 || - getTriple().getArch() == llvm::Triple::thumb) - OSXTarget = ""; - else - iOSTarget = WatchOSTarget = TvOSTarget = ""; - } + // Allow conflicts among OSX and iOS for historical reasons, but choose + // the default platform. + if (!OSXTarget.empty() && (!iOSTarget.empty() || !WatchOSTarget.empty() || + !TvOSTarget.empty())) { + if (getTriple().getArch() == llvm::Triple::arm || + getTriple().getArch() == llvm::Triple::aarch64 || + getTriple().getArch() == llvm::Triple::thumb) + OSXTarget = ""; + else + iOSTarget = WatchOSTarget = TvOSTarget = ""; + } - if (!OSXTarget.empty()) { - const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); - OSXVersion = Args.MakeJoinedArg(nullptr, O, OSXTarget); - Args.append(OSXVersion); - } else if (!iOSTarget.empty()) { - const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); - iOSVersion = Args.MakeJoinedArg(nullptr, O, iOSTarget); - Args.append(iOSVersion); - } else if (!TvOSTarget.empty()) { - const Option O = Opts.getOption(options::OPT_mtvos_version_min_EQ); - TvOSVersion = Args.MakeJoinedArg(nullptr, O, TvOSTarget); - Args.append(TvOSVersion); - } else if (!WatchOSTarget.empty()) { - const Option O = Opts.getOption(options::OPT_mwatchos_version_min_EQ); - WatchOSVersion = Args.MakeJoinedArg(nullptr, O, WatchOSTarget); - Args.append(WatchOSVersion); + if (!OSXTarget.empty()) { + const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); + OSXVersion = Args.MakeJoinedArg(nullptr, O, OSXTarget); + Args.append(OSXVersion); + } else if (!iOSTarget.empty()) { + const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); + iOSVersion = Args.MakeJoinedArg(nullptr, O, iOSTarget); + Args.append(iOSVersion); + } else if (!TvOSTarget.empty()) { + const Option O = Opts.getOption(options::OPT_mtvos_version_min_EQ); + TvOSVersion = Args.MakeJoinedArg(nullptr, O, TvOSTarget); + Args.append(TvOSVersion); + } else if (!WatchOSTarget.empty()) { + const Option O = Opts.getOption(options::OPT_mwatchos_version_min_EQ); + WatchOSVersion = Args.MakeJoinedArg(nullptr, O, WatchOSTarget); + Args.append(WatchOSVersion); + } } } Index: test/Driver/appletvos-version-min.c =================================================================== --- test/Driver/appletvos-version-min.c +++ test/Driver/appletvos-version-min.c @@ -2,7 +2,7 @@ // REQUIRES: aarch64-registered-target // RUN: %clang -target i386-apple-darwin10 -mappletvsimulator-version-min=9.0 -arch x86_64 -S -o - %s | FileCheck %s // RUN: %clang -target armv7s-apple-darwin10 -mappletvos-version-min=9.0 -arch arm64 -S -o - %s | FileCheck %s -// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin10 -arch x86_64 -S -o - %s | FileCheck %s +// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin -arch x86_64 -S -o - %s | FileCheck %s int main() { return 0; } // CHECK: .tvos_version_min 9, 0 Index: test/Driver/darwin-multiarch-arm.c =================================================================== --- test/Driver/darwin-multiarch-arm.c +++ test/Driver/darwin-multiarch-arm.c @@ -1,6 +1,6 @@ // Check that we compile correctly with multiple ARM -arch options. // -// RUN: %clang -target arm7-apple-darwin10 -### \ +// RUN: %clang -target arm7-apple-ios5.0.0 -### \ // RUN: -arch armv7 -arch armv7s %s 2>&1 | FileCheck %s // CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0" Index: test/Driver/darwin-stdlib.cpp =================================================================== --- test/Driver/darwin-stdlib.cpp +++ test/Driver/darwin-stdlib.cpp @@ -7,7 +7,7 @@ // RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX // RUN: %clang -target x86_64-apple-darwin -arch armv7s -miphoneos-version-min=6.1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBSTDCXX // RUN: %clang -target x86_64-apple-darwin -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX -// RUN: %clang -target x86_64-apple-darwin -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX +// RUN: %clang -target x86_64-apple-watchos -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX // The purpose of this test is that the libc++ headers should be found // properly. At the moment this is done by passing -stdlib=libc++ down to the Index: test/Driver/darwin-version.c =================================================================== --- test/Driver/darwin-version.c +++ test/Driver/darwin-version.c @@ -12,10 +12,14 @@ // CHECK-VERSION-IOS3: "armv6k-apple-ios3.0.0" // RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \ -// RUN: %clang -target armv7-apple-ios9.0 -c -### %s 2> %t.err +// RUN: %clang -target armv7-apple-ios -c -### %s 2> %t.err // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS4 %s // CHECK-VERSION-IOS4: invalid iOS deployment version 'IPHONEOS_DEPLOYMENT_TARGET=11.0' +// RUN: %clang -target armv7-apple-ios11 -c -### %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS41 %s +// CHECK-VERSION-IOS41: invalid iOS deployment version 'ios11.0.0' + // RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -### %s 2> %t.err // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS5 %s // CHECK-VERSION-IOS5: invalid iOS deployment version '-miphoneos-version-min=11.0' @@ -24,9 +28,9 @@ // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS6 %s // CHECK-VERSION-IOS6: invalid iOS deployment version '-mios-simulator-version-min=11.0' -// RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \ +// RUN: %clang -target armv7-apple-ios10.99.99 -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s -// RUN: %clang -target armv7-apple-ios9 -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \ +// RUN: %clang -target armv7-apple-ios -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s // CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.99 @@ -98,33 +102,33 @@ // RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \ -// RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target armv6-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS2 %s // RUN: env MACOSX_DEPLOYMENT_TARGET=10.4.10 \ -// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target i386-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX49 %s // CHECK-VERSION-OSX49: "i386-apple-macosx10.4.10" // RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.3.1 \ -// RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target armv6-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS231 %s // CHECK-VERSION-IOS231: "armv6k-apple-ios2.3.1" // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 TVOS_DEPLOYMENT_TARGET=8.3.1 \ -// RUN: %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target armv7-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-TVOS %s // CHECK-VERSION-TVOS: "thumbv7-apple-tvos8.3.1" // RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \ -// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target i386-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-TVOSSIM %s // CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1-simulator" // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 WATCHOS_DEPLOYMENT_TARGET=2.0 \ -// RUN: %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target armv7-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS %s // CHECK-VERSION-WATCHOS: "thumbv7-apple-watchos2.0.0" // RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \ -// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: %clang -target i386-apple-darwin -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOSSIM %s // CHECK-VERSION-WATCHOSSIM: "i386-apple-watchos2.0.0-simulator" @@ -139,3 +143,66 @@ // RUN: %clang -target x86_64-apple-watchos4.0 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS-TARGET %s // CHECK-VERSION-WATCHOS-TARGET: "x86_64-apple-watchos4.0.0-simulator" + + +// Target can specify the OS version: + +// RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TMAC1 %s +// CHECK-VERSION-TMAC1: "x86_64-apple-macosx10.10.0" + +// RUN: %clang -target x86_64-apple-macos10.11.2 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TMAC2 %s +// CHECK-VERSION-TMAC2: "x86_64-apple-macosx10.11.2" + +// RUN: %clang -target armv7-apple-darwin14 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TMAC3 %s +// CHECK-VERSION-TMAC3: "thumbv7-apple-macosx10.10.0" + +// RUN: %clang -target arm64-apple-ios11.1 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TIOS1 %s +// CHECK-VERSION-TIOS1: "arm64-apple-ios11.1.0" + +// RUN: %clang -target arm64-apple-tvos10.3 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TTVOS1 %s +// CHECK-VERSION-TTVOS1: "arm64-apple-tvos10.3.0" + +// RUN: %clang -target armv7k-apple-watchos4.1 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TWATCHOS1 %s +// CHECK-VERSION-TWATCHOS1: "thumbv7k-apple-watchos4.1.0" + +// Target with OS version is not overriden by environment variables: + +// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 \ +// RUN: %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TMACOS-CMD %s +// CHECK-VERSION-TMACOS-CMD: "i386-apple-macosx10.5.0" + +// RUN: env IPHONEOS_DEPLOYMENT_TARGET=10.1 \ +// RUN: %clang -target arm64-apple-ios11 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TIOS-CMD %s +// CHECK-VERSION-TIOS-CMD: "arm64-apple-ios11.0.0" + +// RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \ +// RUN: %clang -target arm64-apple-tvos9 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TTVOS-CMD %s +// CHECK-VERSION-TTVOS-CMD: "arm64-apple-tvos9.0.0" + +// RUN: env WATCHOS_DEPLOYMENT_TARGET=2 \ +// RUN: %clang -target armv7k-apple-watchos3 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TWATCHOS-CMD %s +// CHECK-VERSION-TWATCHOS-CMD: "thumbv7k-apple-watchos3.0.0" + +// Target with OS version is not overriden by the SDK: + +// RUN: %clang -target armv7-apple-ios9 -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TIOS-SDK %s +// CHECK-VERSION-TIOS-SDK: thumbv7-apple-ios9 + +// RUN: %clang -target armv7k-apple-watchos4 -Wno-missing-sysroot -isysroot SDKs/WatchOS3.0.sdk -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TWATCHOS-SDK %s +// CHECK-VERSION-TWATCHOS-SDK: thumbv7k-apple-watchos4 + +// RUN: %clang -target armv7-apple-tvos9 -Wno-missing-sysroot -isysroot SDKs/AppleTVOS11.0.sdk -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TTVOS-SDK %s +// CHECK-VERSION-TTVOS-SDK: thumbv7-apple-tvos9