]> granicus.if.org Git - clang/commitdiff
[Driver] -noprofilelib flag
authorPetr Hosek <phosek@chromium.org>
Thu, 11 Jul 2019 19:06:38 +0000 (19:06 +0000)
committerPetr Hosek <phosek@chromium.org>
Thu, 11 Jul 2019 19:06:38 +0000 (19:06 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365808 91177308-0d34-0410-b5e6-96231b3b80d8

docs/ClangCommandLineReference.rst
include/clang/Driver/Options.td
lib/Driver/ToolChain.cpp
test/Driver/noprofilelib.c [new file with mode: 0644]

index b7f94e98d494607dbfb7241baa07d2b5a4aa259d..4c1fe07be3a6265873df7901262e1b20b4c757a0 100644 (file)
@@ -346,6 +346,8 @@ Disable builtin #include directories
 
 .. option:: -noprebind
 
+.. option:: -noprofilelib
+
 .. option:: -noseglinkedit
 
 .. option:: -nostartfiles
index 011abdd0095d37436057f3f4b458752868f1b845..08af5ad20afac7e75c21415d3dc493d71e5754ff 100644 (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]>;
index 6d6e4c4dd243b533863059bbcd1bd41e2c251050..b1fddb0af55d2252e9a837f890ba8e2c4cb9caa2 100644 (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) ||
diff --git a/test/Driver/noprofilelib.c b/test/Driver/noprofilelib.c
new file mode 100644 (file)
index 0000000..2a6970c
--- /dev/null
@@ -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