[PATCH] D17947: [Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 7 16:32:16 PST 2016


beanz created this revision.
beanz added reviewers: zaks.anna, bogner.
beanz added a subscriber: cfe-commits.

isTarget*() calls are order-dependent. This is because iOS Sim *is* iOS. This means checks for the simulator version of the platform must always be ahead of checks for the embedded platform.

http://reviews.llvm.org/D17947

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/darwin-ld.c

Index: test/Driver/darwin-ld.c
===================================================================
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -152,6 +152,12 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
+// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
+// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
+// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
 // LINK_TVOS_ARM64: {{ld(.exe)?"}}
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -359,24 +359,24 @@
   const char *Library = "libclang_rt.profile_osx.a";
 
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOS()) {
-    Library = "libclang_rt.profile_watchos.a";
-  } else if (isTargetWatchOSSimulator()) {
+  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 (isTargetWatchOS()) {
+    Library = "libclang_rt.profile_watchos.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 (isTargetTvOS()) {
+    Library = "libclang_rt.profile_tvos.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 if (isTargetIPhoneOS()) {
+    Library = "libclang_rt.profile_ios.a";
   } else {
     assert(isTargetMacOS() && "unexpected non MacOS platform");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17947.50008.patch
Type: text/x-patch
Size: 2409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160308/c82af39c/attachment.bin>


More information about the cfe-commits mailing list