r205022 - Revert "Link in profile library on Linux using --whole-archive"

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Mar 28 10:53:17 PDT 2014


Author: dexonsmith
Date: Fri Mar 28 12:53:17 2014
New Revision: 205022

URL: http://llvm.org/viewvc/llvm-project?rev=205022&view=rev
Log:
Revert "Link in profile library on Linux using --whole-archive"

This reverts commit r205012.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/coverage-ld.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=205022&r1=205021&r2=205022&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar 28 12:53:17 2014
@@ -1817,16 +1817,18 @@ static void addProfileRT(
         Args.hasArg(options::OPT_coverage)))
     return;
 
+  // Pull in runtime for -fprofile-inst-generate.  This is required since there
+  // are no calls to the runtime in the code.
+  if (Args.hasArg(options::OPT_fprofile_instr_generate)) {
+    CmdArgs.push_back("-u");
+    CmdArgs.push_back("___llvm_profile_runtime");
+  }
+
   SmallString<128> LibProfile = getCompilerRTLibDir(TC);
   llvm::sys::path::append(LibProfile,
       Twine("libclang_rt.profile-") + getArchNameForCompilerRTLib(TC) + ".a");
 
-  SmallVector<const char *, 3> LibProfileArgs;
-  LibProfileArgs.push_back("-whole-archive");
-  LibProfileArgs.push_back(Args.MakeArgString(LibProfile));
-  LibProfileArgs.push_back("-no-whole-archive");
-
-  CmdArgs.insert(CmdArgs.end(), LibProfileArgs.begin(), LibProfileArgs.end());
+  CmdArgs.push_back(Args.MakeArgString(LibProfile));
 }
 
 static void addSanitizerRTLinkFlags(

Modified: cfe/trunk/test/Driver/coverage-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/coverage-ld.c?rev=205022&r1=205021&r2=205022&view=diff
==============================================================================
--- cfe/trunk/test/Driver/coverage-ld.c (original)
+++ cfe/trunk/test/Driver/coverage-ld.c Fri Mar 28 12:53:17 2014
@@ -16,11 +16,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
 //
 // CHECK-LINUX-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-LINUX-X86-64: "-whole-archive"
-// CHECK-LINUX-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-x86_64.a"
-// CHECK-LINUX-X86-64: "-no-whole-archive"
-// CHECK-LINUX-X86-64: "-lc"
-
+// CHECK-LINUX-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
+//
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target x86_64-unknown-freebsd --coverage \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \





More information about the cfe-commits mailing list