]> granicus.if.org Git - clang/commitdiff
Build and use libcompiler_rt whenever possible.
authorEric Christopher <echristo@apple.com>
Wed, 22 Jun 2011 17:41:40 +0000 (17:41 +0000)
committerEric Christopher <echristo@apple.com>
Wed, 22 Jun 2011 17:41:40 +0000 (17:41 +0000)
Patch by Jean-Daniel Dupas!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133624 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
runtime/compiler-rt/Makefile

index e9bea426ae090dec372e732c9436c9f02fe714d7..4cd96beb05e2de5bdc1df1227f05f8a7e2deedd9 100644 (file)
@@ -365,6 +365,21 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args,
   CmdArgs.push_back(Args.MakeArgString(s));
 }
 
+void DarwinClang::AddLinkRuntimeLib(const ArgList &Args,
+                                    ArgStringList &CmdArgs, 
+                                    const char *DarwinStaticLib) const {
+  llvm::sys::Path P(getDriver().ResourceDir);
+  P.appendComponent("lib");
+  P.appendComponent("darwin");
+  P.appendComponent(DarwinStaticLib);
+  
+  // For now, allow missing resource libraries to support developers who may
+  // not have compiler-rt checked out or integrated into their build.
+  bool Exists;
+  if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
+    CmdArgs.push_back(Args.MakeArgString(P.str()));
+}
+
 void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
                                         ArgStringList &CmdArgs) const {
   // Darwin doesn't support real static executables, don't link any runtime
@@ -386,7 +401,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
   CmdArgs.push_back("-lSystem");
 
   // Select the dynamic runtime library and the target specific static library.
-  const char *DarwinStaticLib = 0;
   if (isTargetIPhoneOS()) {
     // If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1,
     // it never went into the SDK.
@@ -394,7 +408,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
         CmdArgs.push_back("-lgcc_s.1");
 
     // We currently always need a static runtime library for iOS.
-    DarwinStaticLib = "libclang_rt.ios.a";
+    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ios.a");
   } else {
     // The dynamic runtime library was merged with libSystem for 10.6 and
     // beyond; only 10.4 and 10.5 need an additional runtime library.
@@ -412,26 +426,13 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
     // libSystem. Therefore, we still must provide a runtime library just for
     // the tiny tiny handful of projects that *might* use that symbol.
     if (isMacosxVersionLT(10, 5)) {
-      DarwinStaticLib = "libclang_rt.10.4.a";
+      AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
     } else {
       if (getTriple().getArch() == llvm::Triple::x86)
-        DarwinStaticLib = "libclang_rt.eprintf.a";
+        AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+      AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
     }
   }
-
-  /// Add the target specific static library, if needed.
-  if (DarwinStaticLib) {
-    llvm::sys::Path P(getDriver().ResourceDir);
-    P.appendComponent("lib");
-    P.appendComponent("darwin");
-    P.appendComponent(DarwinStaticLib);
-
-    // For now, allow missing resource libraries to support developers who may
-    // not have compiler-rt checked out or integrated into their build.
-    bool Exists;
-    if (!llvm::sys::fs::exists(P.str(), Exists) && Exists)
-      CmdArgs.push_back(Args.MakeArgString(P.str()));
-  }
 }
 
 static inline llvm::StringRef SimulatorVersionDefineName() {
index 732587447391aae24c569f01f6d8486489b485af..9ed0dc2ef8e922d29b04df93c45ea62f7dcd4036 100644 (file)
@@ -175,7 +175,7 @@ public:
   /// runtime library.
   virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
                                      ArgStringList &CmdArgs) const = 0;
-
+  
   /// }
   /// @name ToolChain Implementation
   /// {
@@ -266,7 +266,9 @@ public:
 
   virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
                                      ArgStringList &CmdArgs) const;
-
+  void AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, 
+                         const char *DarwinStaticLib) const;
+  
   virtual void AddCXXStdlibLibArgs(const ArgList &Args,
                                    ArgStringList &CmdArgs) const;
 
index dcdd4f5ec03f6b36ab951c03e1c451d24eca2c93..0d770db17c4710cd22647396e733168d013cd258 100644 (file)
@@ -42,7 +42,7 @@ ifeq ($(shell test -d $(COMPILERRT_SRC_ROOT) && echo OK),OK)
 RuntimeDirs :=
 ifeq ($(OS),Darwin)
 RuntimeDirs += darwin
-RuntimeLibrary.darwin.Configs = eprintf 10.4 ios cc_kext
+RuntimeLibrary.darwin.Configs = eprintf 10.4 osx ios cc_kext
 
 # On Darwin, fake Clang into using the iOS assembler (since compiler-rt wants to
 # build ARM bits).