<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Sure. I can do that.<div><br><div><div>On Jan 31, 2012, at 1:43 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Tue, Jan 31, 2012 at 1:30 PM, Bob Wilson <span dir="ltr"><<a href="mailto:bob.wilson@apple.com">bob.wilson@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":ar0">Author: bwilson<br>
Date: Tue Jan 31 15:30:03 2012<br>
New Revision: 149422<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=149422&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=149422&view=rev</a><br>
Log:<br>
Fix more fallout from the introduction of "macosx" and "ios" triples.<br>
<br>
The Darwin toolchain constructor was assuming that all Darwin triples would<br>
have an OS string starting with "darwin".  Triples starting with "macosx"<br>
would misinterpret the version number, and "ios" triples would completely<br>
miss the version number (or worse) because the OS name is not 6 characters<br>
long.  We lose some sanity checking of triple strings here, since the<br>
Triple.getOSVersion function doesn't do all the checking that the previous<br>
code did, but this still seems like a step in the right direction.<br></div></blockquote><div><br></div><div>Could we sink this down into the llvm:Triple? It's quite possible that it doesn't belong there, but I don't see why not yet... If it doesn't belong there, it might be nice to add some comments about why the Driver has to have special handling of the OS versions here.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":ar0">
<br>
Modified:<br>
    cfe/trunk/lib/Driver/ToolChains.cpp<br>
    cfe/trunk/test/Driver/darwin-ld.c<br>
    cfe/trunk/test/Driver/rewrite-objc.m<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=149422&r1=149421&r2=149422&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=149422&r1=149421&r2=149422&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jan 31 15:30:03 2012<br>
@@ -50,17 +50,44 @@<br>
     ARCRuntimeForSimulator(ARCSimulator_None),<br>
     LibCXXForSimulator(LibCXXSimulator_None)<br>
 {<br>
-  // Compute the initial Darwin version based on the host.<br>
-  bool HadExtra;<br>
-  std::string OSName = Triple.getOSName();<br>
-  if (!Driver::GetReleaseVersion(&OSName.c_str()[6],<br>
-                                 DarwinVersion[0], DarwinVersion[1],<br>
-                                 DarwinVersion[2], HadExtra))<br>
-    getDriver().Diag(diag::err_drv_invalid_darwin_version) << OSName;<br>
-<br>
+  // Compute the initial Darwin version from the triple<br>
+  unsigned Major, Minor, Micro;<br>
+  Triple.getOSVersion(Major, Minor, Micro);<br>
+  switch (Triple.getOS()) {<br>
+  default: assert(0 && "unexpected OS for Darwin triple");<br>
+  case llvm::Triple::Darwin:<br>
+    // Default to darwin4, i.e., MacOSX 10.0.0.<br>
+    if (Major == 0)<br>
+      Major = 4;<br>
+    if (Major < 4)<br>
+      getDriver().Diag(diag::err_drv_invalid_darwin_version) <<<br>
+        Triple.getOSName();<br>
+    Micro = 0;<br>
+    Minor = Major - 4;<br>
+    Major = 10;<br></div></blockquote><div><br></div><div>A comment about what the mapping is from 'darwin' versions to 'masox' versions would clarify this a lot.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":ar0">
+    break;<br>
+  case llvm::Triple::MacOSX:<br>
+    // Default to MacOSX 10.<br>
+    if (Major == 0)<br>
+      Major = 10;<br>
+    if (Major != 10)<br>
+      getDriver().Diag(diag::err_drv_invalid_darwin_version) <<<br>
+        Triple.getOSName();<br>
+    break;<br>
+  case llvm::Triple::IOS:<br>
+    // Ignore the version from the triple.<br>
+    Major = 10;<br>
+    Minor = 0;<br>
+    Micro = 0;<br>
+    break;<br>
+  }<br>
+  // FIXME: DarwinVersion is only used to find GCC's libexec directory.<br>
+  // It should be removed when we stop supporting that.<br>
+  DarwinVersion[0] = Minor + 4;<br>
+  DarwinVersion[1] = Micro;<br>
+  DarwinVersion[2] = 0;<br>
   llvm::raw_string_ostream(MacosxVersionMin)<br>
-    << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'<br>
-    << DarwinVersion[1];<br>
+    << Major << '.' << Minor << '.' << Micro;</div></blockquote></div><br>
</blockquote></div><br></div></body></html>