[PATCH] D135908: [clang][LTO] Setting Desired Default AIX Debugging Options
Qiongsi Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 13 12:26:40 PDT 2022
qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: shchenz, lkail, w2yehia, daltenty, MaskRay.
qiongsiwu1 added a project: clang.
Herald added subscribers: ormris, StephenFan, steven_wu, hiraditya, inglorion.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added a subscriber: cfe-commits.
Two debug options defaults on AIX are different from other platforms:
1. The default debugger is `dbx` instead of `gdb`.
2. `strict-dwarf` defaults to `true`.
This patch implements these two default behaviours for AIX.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135908
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/lto-aix.c
Index: clang/test/Driver/lto-aix.c
===================================================================
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,3 +4,28 @@
//
// LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
// MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
+//
+// Test debugging options
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN: | FileCheck -check-prefix=STRICT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN: | FileCheck -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -gdbx 2>&1 \
+// RUN: | FileCheck -check-prefix=DBX -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb 2>&1 \
+// RUN: | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb0 2>&1 \
+// RUN: | FileCheck -check-prefix=GDB -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -ggdb1 2>&1 \
+// RUN: | FileCheck -check-prefix=GDB -check-prefix=STRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -g0 2>&1 \
+// RUN: | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -g -gno-strict-dwarf 2>&1 \
+// RUN: | FileCheck -check-prefix=NOSTRICT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -### %s -flto -gstrict-dwarf 2>&1 \
+// RUN: | FileCheck -check-prefix=NOSTRICT %s
+//
+// DBX: "-bplugin_opt:-debugger-tune=dbx"
+// GDB: "-bplugin_opt:-debugger-tune=gdb"
+// STRICT: "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -584,9 +584,27 @@
else if (A->getOption().matches(options::OPT_gdbx))
CmdArgs.push_back(
Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=dbx"));
- else
+ else {
+ // On platforms other than AIX, gdb is the default option.
+ // On AIX, dbx will be automatically pick up in the presense of the
+ // debugger tuning argument, so set gdb only if it is specified.
+ if (!IsOSAIX || A->getOption().matches(options::OPT_ggdb) ||
+ Args.getLastArg(options::OPT_ggdbN_Group))
+ CmdArgs.push_back(
+ Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
+ }
+ }
+
+ if (IsOSAIX) {
+ // On AIX, strict-dwarf is assumed to be true if any debug option is
+ // specified, unless clang is told explicitly not to assume so.
+ Arg *A = Args.getLastArg(options::OPT_g_Group);
+ bool EnableDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+ !A->getOption().matches(options::OPT_ggdb0);
+ if (EnableDebugInfo && Args.hasFlag(options::OPT_gstrict_dwarf,
+ options::OPT_gno_strict_dwarf, true))
CmdArgs.push_back(
- Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
+ Args.MakeArgString(Twine(PluginOptPrefix) + "-strict-dwarf=true"));
}
bool UseSeparateSections =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135908.467567.patch
Type: text/x-patch
Size: 3341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221013/e4de4321/attachment.bin>
More information about the cfe-commits
mailing list