<div><div dir="auto">Why does -nodefaultlibs work for your use case?</div></div><div dir="auto"><br></div><div dir="auto">Thank you,</div><div dir="auto"> Filipe </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 11 Jul 2019 at 08:11, Petr Hosek via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">phosek created this revision.<br>
phosek added reviewers: smeenai, davidxl.<br>
Herald added projects: LLVM, Sanitizers.<br>
Herald added subscribers: Sanitizers, llvm-commits.<br>
<br>
This flag is analoguous to other flags like -nostdlib or -nolibc<br>
and could be used to disable linking of profile runtime library.<br>
This is useful in certain environments like kernel, where profile<br>
instrumentation is still desirable, but we cannot use the standard<br>
runtime library.<br>
<br>
<br>
Repository:<br>
  rCRT Compiler Runtime<br>
<br>
<a href="https://reviews.llvm.org/D64547" rel="noreferrer" target="_blank">https://reviews.llvm.org/D64547</a><br>
<br>
Files:<br>
  clang/docs/ClangCommandLineReference.rst<br>
  clang/include/clang/Driver/Options.td<br>
  clang/lib/Driver/ToolChain.cpp<br>
  clang/test/Driver/noprofilelib.c<br>
<br>
<br>
Index: clang/test/Driver/noprofilelib.c<br>
===================================================================<br>
--- /dev/null<br>
+++ clang/test/Driver/noprofilelib.c<br>
@@ -0,0 +1,5 @@<br>
+// RUN: %clang -target i686-pc-linux-gnu -### %s 2>&1 \<br>
+// RUN:     -fprofile-generate -noprofilelib | FileCheck %s<br>
+// RUN: %clang -target i686-pc-linux-gnu -### %s 2>&1 \<br>
+// RUN:     -fprofile-instr-generate -noprofilelib | FileCheck %s<br>
+// CHECK-NOT: clang_rt.profile<br>
Index: clang/lib/Driver/ToolChain.cpp<br>
===================================================================<br>
--- clang/lib/Driver/ToolChain.cpp<br>
+++ clang/lib/Driver/ToolChain.cpp<br>
@@ -450,6 +450,9 @@<br>
 }<br>
<br>
 bool ToolChain::needsProfileRT(const ArgList &Args) {<br>
+  if (Args.hasArg(options::OPT_noprofilelib))<br>
+    return false;<br>
+<br>
   if (needsGCovInstrumentation(Args) ||<br>
       Args.hasArg(options::OPT_fprofile_generate) ||<br>
       Args.hasArg(options::OPT_fprofile_generate_EQ) ||<br>
Index: clang/include/clang/Driver/Options.td<br>
===================================================================<br>
--- clang/include/clang/Driver/Options.td<br>
+++ clang/include/clang/Driver/Options.td<br>
@@ -2512,6 +2512,7 @@<br>
 def nopie : Flag<["-"], "nopie">;<br>
 def no_pie : Flag<["-"], "no-pie">, Alias<nopie>;<br>
 def noprebind : Flag<["-"], "noprebind">;<br>
+def noprofilelib : Flag<["-"], "noprofilelib">;<br>
 def noseglinkedit : Flag<["-"], "noseglinkedit">;<br>
 def nostartfiles : Flag<["-"], "nostartfiles">;<br>
 def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>;<br>
Index: clang/docs/ClangCommandLineReference.rst<br>
===================================================================<br>
--- clang/docs/ClangCommandLineReference.rst<br>
+++ clang/docs/ClangCommandLineReference.rst<br>
@@ -346,6 +346,8 @@<br>
<br>
 .. option:: -noprebind<br>
<br>
+.. option:: -noprofilelib<br>
+<br>
 .. option:: -noseglinkedit<br>
<br>
 .. option:: -nostartfiles<br>
<br>
<br>
</blockquote></div></div>