Fix linker option for -fprofile-arcs -ftest-coverage

Summary:
Linux toolchain accidentally added "-u__llvm_runtime_variable" when "-fprofile-arcs -ftest-coverage", this is not added when "--coverage" option is used.
Using "-u__llvm_runtime_variable" generates an empty default.profraw file while an application built with  "-fprofile-arcs -ftest-coverage" is running. 

Reviewers: calixte, marco-c, sylvestre.ledru

Reviewed By: marco-c

Subscribers: vsk, cfe-commits

Differential Revision: https://reviews.llvm.org/D54195

llvm-svn: 347677
This commit is contained in:
Marco Castelluccio 2018-11-27 17:31:08 +00:00
parent 1b2ead17d6
commit 9123bfddd7
2 changed files with 5 additions and 1 deletions

View File

@ -1019,7 +1019,7 @@ void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
// Add linker option -u__llvm_runtime_variable to cause runtime
// initialization module to be linked in.
if (!Args.hasArg(options::OPT_coverage))
if ((!Args.hasArg(options::OPT_coverage)) && (!Args.hasArg(options::OPT_ftest_coverage)))
CmdArgs.push_back(Args.MakeArgString(
Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
ToolChain::addProfileRTLibs(Args, CmdArgs);

View File

@ -85,6 +85,10 @@
// CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
// CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
// RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
// RUN: %clang -### --coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
// CHECK-u-NOT: "-u{{.*}}"
// RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
// RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
// RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s