beanz created this revision.
beanz added a reviewer: bogner.
beanz added a subscriber: cfe-commits.

This code is a bit undesirable, but it gets clang to work with the autoconf and 
cmake-built libclang_rt.profile libraries.

http://reviews.llvm.org/D14847

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -323,21 +323,35 @@
                               ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  auto library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-                      /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-                      /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-                      /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+    library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+    llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+    library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+                                 : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+    library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+    llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+    library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+                                 : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+    library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+    llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+    library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+                                 : "libclang_rt.profile_ios.a";
   } else {
     assert(isTargetMacOS() && "unexpected non MacOS platform");
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-                      /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, library,
+                    /*AlwaysLink*/ true);
   return;
 }
 


Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -323,21 +323,35 @@
                               ArgStringList &CmdArgs) const {
   if (!needsProfileRT(Args)) return;
 
+  // TODO: Clean this up once autoconf is gone
+  SmallString<128> P(getDriver().ResourceDir);
+  llvm::sys::path::append(P, "lib", "darwin");
+  auto library = "libclang_rt.profile_osx.a";
+
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOSBased()) {
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_watchos.a",
-                      /*AlwaysLink*/ true);
-  } else if (isTargetTvOSBased()) {
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_tvos.a",
-                      /*AlwaysLink*/ true);
-  } else if (isTargetIOSBased()) {
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a",
-                      /*AlwaysLink*/ true);
+  if (isTargetWatchOS()) {
+    library = "libclang_rt.profile_watchos.a";
+  } else if (isTargetWatchOSSimulator()) {
+    llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
+    library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
+                                 : "libclang_rt.profile_watchos.a";
+  } else if (isTargetTvOS()) {
+    library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetTvOSSimulator()) {
+    llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
+    library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
+                                 : "libclang_rt.profile_tvos.a";
+  } else if (isTargetIPhoneOS()) {
+    library = "libclang_rt.profile_ios.a";
+  } else if (isTargetIOSSimulator()) {
+    llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
+    library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
+                                 : "libclang_rt.profile_ios.a";
   } else {
     assert(isTargetMacOS() && "unexpected non MacOS platform");
-    AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a",
-                      /*AlwaysLink*/ true);
   }
+  AddLinkRuntimeLib(Args, CmdArgs, library,
+                    /*AlwaysLink*/ true);
   return;
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to