summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Driver/Tools.cpp6
-rw-r--r--clang/test/Driver/cl-options.c2
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 49d73f678fc..ef3e00329dd 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -4135,6 +4135,12 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
if (!Args.hasArg(options::OPT_frtti, options::OPT_fno_rtti))
CmdArgs.push_back("-fno-rtti");
+ // Let -ffunction-sections imply -fdata-sections.
+ if (Arg * A = Args.getLastArg(options::OPT_ffunction_sections,
+ options::OPT_fno_function_sections))
+ if (A->getOption().matches(options::OPT_ffunction_sections))
+ CmdArgs.push_back("-fdata-sections");
+
const Driver &D = getToolChain().getDriver();
Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index b3623b75e01..6bae7e6cb8f 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -25,9 +25,11 @@
// GR_: -fno-rtti
// RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
+// Gy: -fdata-sections
// Gy: -ffunction-sections
// RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
+// Gy_-NOT: -fdata-sections
// Gy_-NOT: -ffunction-sections
// RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
OpenPOWER on IntegriCloud