]> granicus.if.org Git - clang/commitdiff
clang-cl: make /Gy imply -fdata-sections in addition to -ffunction-sections
authorHans Wennborg <hans@hanshq.net>
Tue, 25 Mar 2014 17:50:25 +0000 (17:50 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 25 Mar 2014 17:50:25 +0000 (17:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204736 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/cl-options.c

index 49d73f678fc18d21f6b639c4c94519d0efb533e9..ef3e00329dda6b5c1d1adf9adb6c7975ced4d49c 100644 (file)
@@ -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);
index b3623b75e01edb9a70485c2f270c650bef18c777..6bae7e6cb8f84be33d53ee90c9ce7f736d3561d6 100644 (file)
 // 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