zhizhouy updated this revision to Diff 92885. zhizhouy retitled this revision from "Record command lines in objects built by clang" to "Record command lines in objects built by clang, Clang part". zhizhouy edited the summary of this revision. zhizhouy added a reviewer: aprantl. zhizhouy added a comment.
I am reusing the DwarfDebugFlags to try to solve this bug now. DwarfDebugFlags only records the command line options for Apple Darwin and will generate DW_AT_APPLE_flags into debug info. I decide not to touch those parts for now. When -grecord-gcc-switches is set, I record command line options into DwarfDebugFlags no matter what ToolChain currently is. This patch also modified LLVM side, which can be referred to: name <https://reviews.llvm.org/D31315> https://reviews.llvm.org/D30760 Files: lib/Driver/ToolChains/Clang.cpp test/CodeGen/debug-info-grecord-gcc-switches.c 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 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 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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits