[cfe-commits] r94641 - in /cfe/trunk/lib/Driver: ToolChains.cpp ToolChains.h Tools.cpp

Daniel Dunbar daniel at zuster.org
Tue Jan 26 16:57:03 PST 2010


Author: ddunbar
Date: Tue Jan 26 18:57:03 2010
New Revision: 94641

URL: http://llvm.org/viewvc/llvm-project?rev=94641&view=rev
Log:
Driver/Darwin: Simplify target version checks.

Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=94641&r1=94640&r2=94641&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jan 26 18:57:03 2010
@@ -241,8 +241,7 @@
 
 void DarwinGCC::AddLinkRuntimeLibArgs(const ArgList &Args,
                                       ArgStringList &CmdArgs) const {
-  unsigned MacosxVersionMin[3];
-  getMacosxVersionMin(Args, MacosxVersionMin);
+  // Note that this routine is only used for targetting OS X.
 
   // Derived from libgcc and lib specs but refactored.
   if (Args.hasArg(options::OPT_static)) {
@@ -262,20 +261,20 @@
                             options::OPT_fno_exceptions) ||
                Args.hasArg(options::OPT_fgnu_runtime)) {
       // FIXME: This is probably broken on 10.3?
-      if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+      if (isMacosxVersionLT(10, 5))
         CmdArgs.push_back("-lgcc_s.10.4");
-      else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+      else if (isMacosxVersionLT(10, 6))
         CmdArgs.push_back("-lgcc_s.10.5");
     } else {
-      if (isMacosxVersionLT(MacosxVersionMin, 10, 3, 9))
+      if (isMacosxVersionLT(10, 3, 9))
         ; // Do nothing.
-      else if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+      else if (isMacosxVersionLT(10, 5))
         CmdArgs.push_back("-lgcc_s.10.4");
-      else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+      else if (isMacosxVersionLT(10, 6))
         CmdArgs.push_back("-lgcc_s.10.5");
     }
 
-    if (isTargetIPhoneOS() || isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
+    if (isTargetIPhoneOS() || isMacosxVersionLT(10, 6)) {
       CmdArgs.push_back("-lgcc");
       CmdArgs.push_back("-lSystem");
     } else {
@@ -328,20 +327,17 @@
     if (getDarwinArchName(Args) == "armv6")
       DarwinStaticLib = "libclang_rt.armv6.a";
   } else {
-    unsigned MacosxVersionMin[3];
-    getMacosxVersionMin(Args, MacosxVersionMin);
-
     // The dynamic runtime library was merged with libSystem for 10.6 and
     // beyond; only 10.4 and 10.5 need an additional runtime library.
-    if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+    if (isMacosxVersionLT(10, 5))
       CmdArgs.push_back("-lgcc_s.10.4");
-    else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+    else if (isMacosxVersionLT(10, 6))
       CmdArgs.push_back("-lgcc_s.10.5");
 
     // For OS X, we only need a static runtime library when targetting 10.4, to
     // provide versions of the static functions which were omitted from
     // 10.4.dylib.
-    if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+    if (isMacosxVersionLT(10, 5))
       DarwinStaticLib = "libclang_rt.10.4.a";
   }
 
@@ -362,21 +358,6 @@
   }
 }
 
-void Darwin::getMacosxVersionMin(const ArgList &Args,
-                                 unsigned (&Res)[3]) const {
-  if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) {
-    bool HadExtra;
-    if (!Driver::GetReleaseVersion(A->getValue(Args), Res[0], Res[1], Res[2],
-                                   HadExtra) ||
-        HadExtra) {
-      const Driver &D = getDriver();
-      D.Diag(clang::diag::err_drv_invalid_version_number)
-        << A->getAsString(Args);
-    }
-  } else
-    return getMacosxVersion(Res);
-}
-
 DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
                                       const char *BoundArch) const {
   DerivedArgList *DAL = new DerivedArgList(Args, false);

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=94641&r1=94640&r2=94641&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Jan 26 18:57:03 2010
@@ -112,22 +112,12 @@
     Res[2] = DarwinVersion[2];
   }
 
-  void getMacosxVersion(unsigned (&Res)[3]) const {
-    Res[0] = 10;
-    Res[1] = DarwinVersion[0] - 4;
-    Res[2] = DarwinVersion[1];
-  }
-
   /// getDarwinArchName - Get the "Darwin" arch name for a particular compiler
   /// invocation. For example, Darwin treats different ARM variations as
   /// distinct architectures.
   llvm::StringRef getDarwinArchName(const ArgList &Args) const;
 
-  /// getMacosxVersionMin - Get the effective -mmacosx-version-min, which is
-  /// either the -mmacosx-version-min, or the current version if unspecified.
-  void getMacosxVersionMin(const ArgList &Args, unsigned (&Res)[3]) const;
-
-  static bool isMacosxVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
+  static bool isVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
     for (unsigned i=0; i < 3; ++i) {
       if (A[i] > B[i]) return false;
       if (A[i] < B[i]) return true;
@@ -135,16 +125,16 @@
     return false;
   }
 
-  static bool isMacosxVersionLT(unsigned (&A)[3],
-                                unsigned V0, unsigned V1=0, unsigned V2=0) {
+  bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
+    assert(isTargetIPhoneOS() && "Unexpected call for OS X target!");
     unsigned B[3] = { V0, V1, V2 };
-    return isMacosxVersionLT(A, B);
+    return isVersionLT(TargetVersion, B);
   }
 
-  bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
-    assert(isTargetIPhoneOS() && "Unexpected call for OS X target!");
+  bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
+    assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!");
     unsigned B[3] = { V0, V1, V2 };
-    return isMacosxVersionLT(TargetVersion, B);
+    return isVersionLT(TargetVersion, B);
   }
 
   /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=94641&r1=94640&r2=94641&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan 26 18:57:03 2010
@@ -2029,10 +2029,6 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-
-  unsigned MacosxVersionMin[3];
-  getDarwinToolChain().getMacosxVersionMin(Args, MacosxVersionMin);
-
   if (!Args.hasArg(options::OPT_A) &&
       !Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
@@ -2043,9 +2039,9 @@
         if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
           CmdArgs.push_back("-ldylib1.o");
       } else {
-        if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
+        if (getDarwinToolChain().isMacosxVersionLT(10, 5))
           CmdArgs.push_back("-ldylib1.o");
-        else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10,6))
+        else if (getDarwinToolChain().isMacosxVersionLT(10, 6))
           CmdArgs.push_back("-ldylib1.10.5.o");
       }
     } else {
@@ -2056,7 +2052,7 @@
             if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
               CmdArgs.push_back("-lbundle1.o");
           } else {
-            if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
+            if (getDarwinToolChain().isMacosxVersionLT(10, 6))
               CmdArgs.push_back("-lbundle1.o");
           }
         }
@@ -2083,24 +2079,24 @@
                 CmdArgs.push_back("-lcrt1.o");
               else
                 CmdArgs.push_back("-lcrt1.3.1.o");
-            } else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
-                                                              10, 5))
-              CmdArgs.push_back("-lcrt1.o");
-            else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
-                                                            10, 6))
-              CmdArgs.push_back("-lcrt1.10.5.o");
-            else
-              CmdArgs.push_back("-lcrt1.10.6.o");
+            } else {
+              if (getDarwinToolChain().isMacosxVersionLT(10, 5))
+                CmdArgs.push_back("-lcrt1.o");
+              else if (getDarwinToolChain().isMacosxVersionLT(10, 6))
+                CmdArgs.push_back("-lcrt1.10.5.o");
+              else
+                CmdArgs.push_back("-lcrt1.10.6.o");
 
-            // darwin_crt2 spec is empty.
+              // darwin_crt2 spec is empty.
+            }
           }
         }
       }
     }
 
-    if (Args.hasArg(options::OPT_shared_libgcc) &&
-        !Args.hasArg(options::OPT_miphoneos_version_min_EQ) &&
-        getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5)) {
+    if (!getDarwinToolChain().isTargetIPhoneOS() &&
+        Args.hasArg(options::OPT_shared_libgcc) &&
+        getDarwinToolChain().isMacosxVersionLT(10, 5)) {
       const char *Str =
         Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o"));
       CmdArgs.push_back(Str);





More information about the cfe-commits mailing list