From ed03cf3d19767093e015d026698bcd3bd6a5c2e2 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Thu, 11 Jul 2019 19:06:38 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365808 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ClangCommandLineReference.rst | 2 ++ include/clang/Driver/Options.td | 1 + lib/Driver/ToolChain.cpp | 3 +++ test/Driver/noprofilelib.c | 5 +++++ 4 files changed, 11 insertions(+) create mode 100644 test/Driver/noprofilelib.c diff --git a/docs/ClangCommandLineReference.rst b/docs/ClangCommandLineReference.rst index b7f94e98d4..4c1fe07be3 100644 --- a/docs/ClangCommandLineReference.rst +++ b/docs/ClangCommandLineReference.rst @@ -346,6 +346,8 @@ Disable builtin #include directories .. option:: -noprebind +.. option:: -noprofilelib + .. option:: -noseglinkedit .. option:: -nostartfiles diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 011abdd009..08af5ad20a 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -2512,6 +2512,7 @@ def nomultidefs : Flag<["-"], "nomultidefs">; def nopie : Flag<["-"], "nopie">; def no_pie : Flag<["-"], "no-pie">, Alias; def noprebind : Flag<["-"], "noprebind">; +def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; def nostartfiles : Flag<["-"], "nostartfiles">; def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>; diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index 6d6e4c4dd2..b1fddb0af5 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -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 index 0000000000..2a6970cc2c --- /dev/null +++ b/test/Driver/noprofilelib.c @@ -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 -- 2.40.0