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

Daniel Dunbar daniel at zuster.org
Fri Sep 18 01:15:04 PDT 2009


Author: ddunbar
Date: Fri Sep 18 03:15:03 2009
New Revision: 82212

URL: http://llvm.org/viewvc/llvm-project?rev=82212&view=rev
Log:
Lift AddLinkRuntimeLibArgs into Darwin tool chain.

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=82212&r1=82211&r2=82212&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Sep 18 03:15:03 2009
@@ -154,6 +154,52 @@
                                        "/../../.."));
 }
 
+void Darwin::AddLinkRuntimeLibArgs(const ArgList &Args,
+                                   ArgStringList &CmdArgs) const {
+  unsigned MacosxVersionMin[3];
+  getMacosxVersionMin(Args, MacosxVersionMin);
+
+  // Derived from libgcc and lib specs but refactored.
+  if (Args.hasArg(options::OPT_static)) {
+    CmdArgs.push_back("-lgcc_static");
+  } else {
+    if (Args.hasArg(options::OPT_static_libgcc)) {
+      CmdArgs.push_back("-lgcc_eh");
+    } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
+      // Derived from darwin_iphoneos_libgcc spec.
+      if (isIPhone()) {
+        CmdArgs.push_back("-lgcc_s.1");
+      } else {
+        CmdArgs.push_back("-lgcc_s.10.5");
+      }
+    } else if (Args.hasArg(options::OPT_shared_libgcc) ||
+               // FIXME: -fexceptions -fno-exceptions means no exceptions
+               Args.hasArg(options::OPT_fexceptions) ||
+               Args.hasArg(options::OPT_fgnu_runtime)) {
+      // FIXME: This is probably broken on 10.3?
+      if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+        CmdArgs.push_back("-lgcc_s.10.4");
+      else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+        CmdArgs.push_back("-lgcc_s.10.5");
+    } else {
+      if (isMacosxVersionLT(MacosxVersionMin, 10, 3, 9))
+        ; // Do nothing.
+      else if (isMacosxVersionLT(MacosxVersionMin, 10, 5))
+        CmdArgs.push_back("-lgcc_s.10.4");
+      else if (isMacosxVersionLT(MacosxVersionMin, 10, 6))
+        CmdArgs.push_back("-lgcc_s.10.5");
+    }
+
+    if (isIPhone() || isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
+      CmdArgs.push_back("-lgcc");
+      CmdArgs.push_back("-lSystem");
+    } else {
+      CmdArgs.push_back("-lSystem");
+      CmdArgs.push_back("-lgcc");
+    }
+  }
+}
+
 void Darwin::getMacosxVersionMin(const ArgList &Args,
                                  unsigned (&Res)[3]) const {
   if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) {

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

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Sep 18 03:15:03 2009
@@ -124,6 +124,10 @@
   /// (prefixed by -L) to.
   void AddLinkSearchPathArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
 
+  /// AddLinkRuntimeLibArgs - Add the linker arguments to link the compiler
+  /// runtime library.
+  void AddLinkRuntimeLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
+
   bool isIPhone() const { return IsIPhone; }
 
   /// }

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

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 18 03:15:03 2009
@@ -2020,49 +2020,8 @@
 
     // link_ssp spec is empty.
 
-    // Derived from libgcc and lib specs but refactored.
-    if (Args.hasArg(options::OPT_static)) {
-      CmdArgs.push_back("-lgcc_static");
-    } else {
-      if (Args.hasArg(options::OPT_static_libgcc)) {
-        CmdArgs.push_back("-lgcc_eh");
-      } else if (Args.hasArg(options::OPT_miphoneos_version_min_EQ)) {
-        // Derived from darwin_iphoneos_libgcc spec.
-        if (getDarwinToolChain().isIPhone()) {
-          CmdArgs.push_back("-lgcc_s.1");
-        } else {
-          CmdArgs.push_back("-lgcc_s.10.5");
-        }
-      } else if (Args.hasArg(options::OPT_shared_libgcc) ||
-                 // FIXME: -fexceptions -fno-exceptions means no exceptions
-                 Args.hasArg(options::OPT_fexceptions) ||
-                 Args.hasArg(options::OPT_fgnu_runtime)) {
-        // FIXME: This is probably broken on 10.3?
-        if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
-          CmdArgs.push_back("-lgcc_s.10.4");
-        else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
-                                                        10, 6))
-          CmdArgs.push_back("-lgcc_s.10.5");
-      } else {
-        if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 3, 9))
-          ; // Do nothing.
-        else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
-                                                        10, 5))
-          CmdArgs.push_back("-lgcc_s.10.4");
-        else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
-                                                        10, 6))
-          CmdArgs.push_back("-lgcc_s.10.5");
-      }
-
-      if (getDarwinToolChain().isIPhone() ||
-          getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6)) {
-        CmdArgs.push_back("-lgcc");
-        CmdArgs.push_back("-lSystem");
-      } else {
-        CmdArgs.push_back("-lSystem");
-        CmdArgs.push_back("-lgcc");
-      }
-    }
+    // Let the tool chain choose which runtime library to link.
+    getDarwinToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
   }
 
   if (!Args.hasArg(options::OPT_A) &&





More information about the cfe-commits mailing list