Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2728,7 +2728,8 @@ DwarfVersion = getToolChain().GetDefaultDwarfVersion(); } - // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now. + // We ignore flag -gstrict-dwarf for now. + // And we handle flag -grecord-gcc-switches later with DwarfDebugFlags. Args.ClaimAllArgs(options::OPT_g_flags_Group); // Column info is included by default for everything except PS4 and CodeView. @@ -4321,7 +4322,10 @@ // Optionally embed the -cc1 level arguments into the debug info, for build // analysis. - if (getToolChain().UseDwarfDebugFlags()) { + // Also record command line arguments into the debug info if + // -grecord-gcc-switches options is set on. + if (getToolChain().UseDwarfDebugFlags() || + Args.hasArg(options::OPT_grecord_gcc_switches)) { ArgStringList OriginalArgs; for (const auto &Arg : Args) Arg->render(Args, OriginalArgs); Index: test/CodeGen/debug-info-grecord-gcc-switches.c =================================================================== --- /dev/null +++ test/CodeGen/debug-info-grecord-gcc-switches.c @@ -0,0 +1,6 @@ +// RUN: %clang -g -grecord-gcc-switches -S -emit-llvm -o - %s | FileCheck %s +int main (void) { + return 0; +} + +// CHECK: -g -grecord-gcc-switches -S -emit-llvm