diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index b7f94e98d494..4c1fe07be3a6 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -346,6 +346,8 @@ Disable builtin #include directories .. option:: -noprebind +.. option:: -noprofilelib + .. option:: -noseglinkedit .. option:: -nostartfiles diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 011abdd0095d..08af5ad20afa 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/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/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 6d6e4c4dd243..b1fddb0af55d 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/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/clang/test/Driver/noprofilelib.c b/clang/test/Driver/noprofilelib.c new file mode 100644 index 000000000000..2a6970cc2cfc --- /dev/null +++ b/clang/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