diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3292,6 +3292,7 @@ def gmodules : Flag <["-"], "gmodules">, Group, HelpText<"Generate debug info with external references to clang modules" " or precompiled headers">; +def gno_modules : Flag <["-"], "gno-modules">, Group; def gz_EQ : Joined<["-"], "gz=">, Group, HelpText<"DWARF debug sections compression type">; def gz : Flag<["-"], "gz">, Alias, AliasArgs<["zlib"]>, Group; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4219,9 +4219,11 @@ CmdArgs.push_back("-gno-column-info"); // FIXME: Move backend command line options to the module. - // If -gline-tables-only or -gline-directives-only is the last option it wins. - if (const Arg *A = Args.getLastArg(options::OPT_gmodules)) - if (checkDebugInfoOption(A, Args, D, TC)) { + if (Args.hasFlag(options::OPT_gmodules, options::OPT_gno_modules, false)) { + // If -gline-tables-only or -gline-directives-only is the last option it + // wins. + if (checkDebugInfoOption(Args.getLastArg(options::OPT_gmodules), Args, D, + TC)) { if (DebugInfoKind != codegenoptions::DebugLineTablesOnly && DebugInfoKind != codegenoptions::DebugDirectivesOnly) { DebugInfoKind = codegenoptions::DebugInfoConstructor; @@ -4229,6 +4231,7 @@ CmdArgs.push_back("-fmodule-format=obj"); } } + } if (T.isOSBinFormatELF() && SplitDWARFInlining) CmdArgs.push_back("-fsplit-dwarf-inlining"); diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -300,6 +300,9 @@ // RUN: %clang -### -target %itanium_abi_triple -gmodules -gline-directives-only %s 2>&1 \ // RUN: | FileCheck -check-prefix=GLIO_ONLY %s // +// RUN: %clang -### -gmodules -gno-modules %s 2>&1 \ +// RUN: | FileCheck -check-prefix=NOGEXTREFS %s +// // NOG_PS: "-cc1" // NOG_PS-NOT: "-dwarf-version= // NOG_PS: "-generate-arange-section" @@ -407,6 +410,7 @@ // // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" // GEXTREFS: "-debug-info-kind={{standalone|constructor}}" +// NOGEXTREFS-NOT: -dwarf-ext-refs // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'