<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Unless I'm reading the log wrong there doesn't seem to be any error text getting logged.</div><div><br></div><div>Any idea what that is about?</div><div><br></div><div>-Chris</div><div><br>On Apr 29, 2016, at 9:49 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com">chisophugis@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">This breaks the PS4 bots at least. They've been red for hours now.<div><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast?numbuilds=100">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast?numbuilds=100</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 3:28 PM, Chris Bieneman via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: cbieneman<br>
Date: Fri Apr 29 17:28:34 2016<br>
New Revision: 268127<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268127&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=268127&view=rev</a><br>
Log:<br>
Add a new warning to notify users of mismatched SDK and deployment target<br>
<br>
Summary:<br>
This patch adds a new driver warning -Wincompatible-sdk which notifies the user when they are mismatching the version min options and the sysroot.<br>
<br>
The patch works by checking the sysroot (if present) for an SDK name, then matching that against the target platform. In the case of a mismatch it logs a warning.<br>
<br>
Reviewers: bob.wilson, rsmith<br>
<br>
Subscribers: rsmith, edward-san, cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D18088" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18088</a><br>
<br>
Added:<br>
    cfe/trunk/test/Driver/incompatible_sysroot.c<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
    cfe/trunk/lib/Driver/ToolChains.cpp<br>
    cfe/trunk/lib/Driver/ToolChains.h<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=268127&r1=268126&r2=268127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=268127&r1=268126&r2=268127&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 29 17:28:34 2016<br>
@@ -198,6 +198,8 @@ def warn_drv_pch_not_first_include : War<br>
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;<br>
 def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,<br>
   InGroup<DiagGroup<"missing-sysroot">>;<br>
+def warn_incompatible_sysroot : Warning<"using sysroot for '%0' but targeting '%1'">,<br>
+  InGroup<DiagGroup<"incompatible-sysroot">>;<br>
 def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">,<br>
   InGroup<DiagGroup<"debug-compression-unavailable">>;<br>
 def warn_drv_enabling_rtti_with_exceptions : Warning<<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268127&r1=268126&r2=268127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268127&r1=268126&r2=268127&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 29 17:28:34 2016<br>
@@ -329,6 +329,36 @@ void MachO::AddLinkRuntimeLib(const ArgL<br>
   }<br>
 }<br>
<br>
+StringRef Darwin::getPlatformFamily() const {<br>
+  switch (TargetPlatform) {<br>
+    case DarwinPlatformKind::MacOS:<br>
+      return "MacOSX";<br>
+    case DarwinPlatformKind::IPhoneOS:<br>
+    case DarwinPlatformKind::IPhoneOSSimulator:<br>
+      return "iPhone";<br>
+    case DarwinPlatformKind::TvOS:<br>
+    case DarwinPlatformKind::TvOSSimulator:<br>
+      return "AppleTV";<br>
+    case DarwinPlatformKind::WatchOS:<br>
+    case DarwinPlatformKind::WatchOSSimulator:<br>
+      return "Watch";<br>
+  }<br>
+  llvm_unreachable("Unsupported platform");<br>
+}<br>
+<br>
+StringRef Darwin::getSDKName(StringRef isysroot) {<br>
+  // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk<br>
+  llvm::sys::path::const_iterator SDKDir;<br>
+  auto BeginSDK = llvm::sys::path::begin(isysroot);<br>
+  auto EndSDK = llvm::sys::path::end(isysroot);<br>
+  for (auto IT = BeginSDK; IT != EndSDK; ++IT) {<br>
+    StringRef SDK = *IT;<br>
+    if (SDK.endswith(".sdk"))<br>
+      return SDK.slice(0, SDK.size() - 4);<br>
+  }<br>
+  return "";<br>
+}<br>
+<br>
 StringRef Darwin::getOSLibraryNameSuffix() const {<br>
   switch(TargetPlatform) {<br>
   case DarwinPlatformKind::MacOS:<br>
@@ -540,11 +570,8 @@ void Darwin::AddDeploymentTarget(Derived<br>
         TvOSTarget.empty() && Args.hasArg(options::OPT_isysroot)) {<br>
       if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {<br>
         StringRef isysroot = A->getValue();<br>
-        // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk<br>
-        size_t BeginSDK = isysroot.rfind("SDKs/");<br>
-        size_t EndSDK = isysroot.rfind(".sdk");<br>
-        if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {<br>
-          StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);<br>
+        StringRef SDK = getSDKName(isysroot);<br>
+        if (SDK.size() > 0) {<br>
           // Slice the version number out.<br>
           // Version number is between the first and the last number.<br>
           size_t StartVer = SDK.find_first_of("0123456789");<br>
@@ -697,6 +724,17 @@ void Darwin::AddDeploymentTarget(Derived<br>
     Platform = WatchOSSimulator;<br>
<br>
   setTarget(Platform, Major, Minor, Micro);<br>
+<br>
+  if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {<br>
+    StringRef SDK = getSDKName(A->getValue());<br>
+    if (SDK.size() > 0) {<br>
+      size_t StartVer = SDK.find_first_of("0123456789");<br>
+      StringRef SDKName = SDK.slice(0, StartVer);<br>
+      if (!SDKName.startswith(getPlatformFamily()))<br>
+        getDriver().Diag(diag::warn_incompatible_sysroot)<br>
+            << SDKName << getPlatformFamily();<br>
+    }<br>
+  }<br>
 }<br>
<br>
 void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=268127&r1=268126&r2=268127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=268127&r1=268126&r2=268127&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.h (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Apr 29 17:28:34 2016<br>
@@ -496,6 +496,8 @@ protected:<br>
     return TargetVersion < VersionTuple(V0, V1, V2);<br>
   }<br>
<br>
+  StringRef getPlatformFamily() const;<br>
+  static StringRef getSDKName(StringRef isysroot);<br>
   StringRef getOSLibraryNameSuffix() const;<br>
<br>
 public:<br>
<br>
Added: cfe/trunk/test/Driver/incompatible_sysroot.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/incompatible_sysroot.c?rev=268127&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/incompatible_sysroot.c?rev=268127&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/incompatible_sysroot.c (added)<br>
+++ cfe/trunk/test/Driver/incompatible_sysroot.c Fri Apr 29 17:28:34 2016<br>
@@ -0,0 +1,12 @@<br>
+// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS %s<br>
+// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -mwatchos-version-min=2.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-WATCHOS %s<br>
+// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/iPhoneOS9.2.sdk -mtvos-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-TVOS %s<br>
+// RUN: %clang -Wincompatible-sysroot -isysroot SDKs/iPhoneSimulator9.2.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-IOS-IOSSIM %s<br>
+// RUN: %clang -Wno-incompatible-sysroot -isysroot SDKs/MacOSX10.9.sdk -mios-version-min=9.0 -S -o - %s 2>&1 | FileCheck -check-prefix CHECK-OSX-IOS-DISABLED %s<br>
+<br>
+int main() { return 0; }<br>
+// CHECK-OSX-IOS: warning: using sysroot for 'MacOSX' but targeting 'iPhone'<br>
+// CHECK-IOS-WATCHOS: warning: using sysroot for 'iPhoneOS' but targeting 'Watch'<br>
+// CHECK-IOS-TVOS: warning: using sysroot for 'iPhoneOS' but targeting 'AppleTV'<br>
+// CHECK-IOS-IOSSIM-NOT: warning: using sysroot for '{{.*}}' but targeting '{{.*}}'<br>
+// CHECK-OSX-IOS-DISABLED-NOT: warning: using sysroot for '{{.*}}' but targeting '{{.*}}'<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></blockquote></body></html>