From: Duncan P. N. Exon Smith Date: Fri, 28 Mar 2014 17:53:17 +0000 (+0000) Subject: Revert "Link in profile library on Linux using --whole-archive" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d12127df41ba85d7bbf46219c8c0f665d7a12ace;p=clang Revert "Link in profile library on Linux using --whole-archive" This reverts commit r205012. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205022 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e4af66b783..2141cc9656 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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 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( diff --git a/test/Driver/coverage-ld.c b/test/Driver/coverage-ld.c index bb70fe56c8..0e39249a2f 100644 --- a/test/Driver/coverage-ld.c +++ b/test/Driver/coverage-ld.c @@ -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 \