[cfe-commits] r56943 - /cfe/trunk/Driver/clang.cpp

Daniel Dunbar daniel at zuster.org
Wed Oct 1 18:21:33 PDT 2008


Author: ddunbar
Date: Wed Oct  1 20:21:33 2008
New Revision: 56943

URL: http://llvm.org/viewvc/llvm-project?rev=56943&view=rev
Log:
(llvm up) If the target triple is unspecified, automatically set the
OS version part to that of the host on darwin.

Modified:
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=56943&r1=56942&r2=56943&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Oct  1 20:21:33 2008
@@ -45,6 +45,7 @@
 #include "llvm/Config/config.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/System/Host.h"
 #include "llvm/System/Path.h"
 #include "llvm/System/Signals.h"
 using namespace clang;
@@ -672,7 +673,18 @@
   // Initialize base triple.  If a -triple option has been specified, use
   // that triple.  Otherwise, default to the host triple.
   std::string Triple = TargetTriple;
-  if (Triple.empty()) Triple = LLVM_HOSTTRIPLE;
+  if (Triple.empty()) {
+    Triple = LLVM_HOSTTRIPLE;
+
+    // On darwin, we want to update the version to match that of the
+    // host.    
+    std::string::size_type DarwinDashIdx = Triple.find("-darwin");
+    if (DarwinDashIdx != std::string::npos) {
+      Triple.resize(DarwinDashIdx + strlen("-darwin"));
+
+      Triple += llvm::sys::osVersion();
+    }
+  }
   
   // If -arch foo was specified, remove the architecture from the triple we have
   // so far and replace it with the specified one.





More information about the cfe-commits mailing list