[Driver] -noprofilelib flag

This flag is analoguous to other flags like -nostdlib or -nolibc
and could be used to disable linking of profile runtime library.
This is useful in certain environments like kernel, where profile
instrumentation is still desirable, but we cannot use the standard
runtime library.

llvm-svn: 365808
This commit is contained in:
Petr Hosek 2019-07-11 19:06:38 +00:00
parent 5011b83237
commit 08cb342afa
4 changed files with 11 additions and 0 deletions

View File

@ -346,6 +346,8 @@ Disable builtin #include directories
.. option:: -noprebind
.. option:: -noprofilelib
.. option:: -noseglinkedit
.. option:: -nostartfiles

View File

@ -2512,6 +2512,7 @@ def nomultidefs : Flag<["-"], "nomultidefs">;
def nopie : Flag<["-"], "nopie">;
def no_pie : Flag<["-"], "no-pie">, Alias<nopie>;
def noprebind : Flag<["-"], "noprebind">;
def noprofilelib : Flag<["-"], "noprofilelib">;
def noseglinkedit : Flag<["-"], "noseglinkedit">;
def nostartfiles : Flag<["-"], "nostartfiles">;
def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>;

View File

@ -450,6 +450,9 @@ std::string ToolChain::getArchSpecificLibPath() const {
}
bool ToolChain::needsProfileRT(const ArgList &Args) {
if (Args.hasArg(options::OPT_noprofilelib))
return false;
if (needsGCovInstrumentation(Args) ||
Args.hasArg(options::OPT_fprofile_generate) ||
Args.hasArg(options::OPT_fprofile_generate_EQ) ||

View File

@ -0,0 +1,5 @@
// RUN: %clang -target i686-pc-linux-gnu -### %s 2>&1 \
// RUN: -fprofile-generate -noprofilelib | FileCheck %s
// RUN: %clang -target i686-pc-linux-gnu -### %s 2>&1 \
// RUN: -fprofile-instr-generate -noprofilelib | FileCheck %s
// CHECK-NOT: clang_rt.profile