From: Hans Wennborg Date: Tue, 25 Mar 2014 17:50:25 +0000 (+0000) Subject: clang-cl: make /Gy imply -fdata-sections in addition to -ffunction-sections X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5893c8b7b46be793d9f6fd9a1217bf9355373ed;p=clang clang-cl: make /Gy imply -fdata-sections in addition to -ffunction-sections git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204736 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 49d73f678f..ef3e00329d 100644 --- a/lib/Driver/Tools.cpp +++ b/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/test/Driver/cl-options.c b/test/Driver/cl-options.c index b3623b75e0..6bae7e6cb8 100644 --- a/test/Driver/cl-options.c +++ b/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