]> granicus.if.org Git - clang/commitdiff
clang/Darwin: Use the compiler-rt provided profile library.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 17 Nov 2011 00:36:57 +0000 (00:36 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 17 Nov 2011 00:36:57 +0000 (00:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144869 91177308-0d34-0410-b5e6-96231b3b80d8

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

index b232bc0584a144bea9b4952178b273c3b030278f..f4209ad08a299e47abacdf17fd5d69d7b0e53c21 100644 (file)
@@ -454,6 +454,19 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
     return;
   }
 
+  // If we are building profile support, link that library in.
+  if (Args.hasArg(options::OPT_fprofile_arcs) ||
+      Args.hasArg(options::OPT_fprofile_generate) ||
+      Args.hasArg(options::OPT_fcreate_profile) ||
+      Args.hasArg(options::OPT_coverage)) {
+    // Select the appropriate runtime library for the target.
+    if (isTargetIPhoneOS()) {
+      AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a");
+    } else {
+      AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a");
+    }
+  }
+
   // Otherwise link libSystem, then the dynamic runtime library, and finally any
   // target specific static runtime library.
   CmdArgs.push_back("-lSystem");
index 52438cc34d73e99fc6ce5d466abf6d57491d163b..906f2ae0db7b5ec0973f96ac5ec16a6b867a849c 100644 (file)
@@ -160,13 +160,6 @@ static void addProfileRT(const ToolChain &TC, const ArgList &Args,
   std::string ProfileRT =
     std::string(TC.getDriver().Dir) + "/../lib/libprofile_rt.a";
 
-  if (Triple.isOSDarwin()) {
-    // On Darwin, if the static library doesn't exist try the dylib.
-    bool Exists;
-    if (llvm::sys::fs::exists(ProfileRT, Exists) || !Exists)
-      ProfileRT.replace(ProfileRT.size() - 1, 1, "dylib");
-  }
-
   CmdArgs.push_back(Args.MakeArgString(ProfileRT));
 }
 
@@ -3589,8 +3582,6 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
     // endfile_spec is empty.
   }
 
-  addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
-
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_F);
 
index 8963c393f38b0aff29e4d640a036e24ff3a47e47..bba8fb304810abc84e6d7bcf33dae8ab78221b41 100644 (file)
@@ -76,7 +76,9 @@ ifeq ($(shell test -d $(COMPILERRT_SRC_ROOT) && echo OK),OK)
 RuntimeDirs :=
 ifeq ($(OS),Darwin)
 RuntimeDirs += darwin
-RuntimeLibrary.darwin.Configs := eprintf 10.4 osx ios cc_kext
+RuntimeLibrary.darwin.Configs := \
+       eprintf 10.4 osx ios cc_kext \
+       profile_osx profile_ios
 
 # On Darwin, fake Clang into using the iOS assembler (since compiler-rt wants to
 # build ARM bits).