[clang] 04615b6 - [clang][LTO] Setting Desired Default AIX Debugging Options

Qiongsi Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 18 07:49:19 PDT 2022


Author: Qiongsi Wu
Date: 2022-10-18T10:43:19-04:00
New Revision: 04615b695aadf5f3860e3be9631131518227f410

URL: https://github.com/llvm/llvm-project/commit/04615b695aadf5f3860e3be9631131518227f410
DIFF: https://github.com/llvm/llvm-project/commit/04615b695aadf5f3860e3be9631131518227f410.diff

LOG: [clang][LTO] Setting Desired Default AIX Debugging Options

On AIX, `strict-dwarf` defaults to `true`.  This patch implement this default behaviour. Additionally, it adds debug tuning tests.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D135908

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp
    clang/test/Driver/lto-aix.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ca8fc7b93972f..58e452418fa26 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -589,6 +589,18 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
           Args.MakeArgString(Twine(PluginOptPrefix) + "-debugger-tune=gdb"));
   }
 
+  if (IsOSAIX) {
+    // On AIX, clang assumes strict-dwarf is true if any debug option is
+    // specified, unless it 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) + "-strict-dwarf=true"));
+  }
+
   bool UseSeparateSections =
       isUseSeparateSections(ToolChain.getEffectiveTriple());
 

diff  --git a/clang/test/Driver/lto-aix.c b/clang/test/Driver/lto-aix.c
index 89b5d5aeb8ef5..1689c2638410f 100644
--- a/clang/test/Driver/lto-aix.c
+++ b/clang/test/Driver/lto-aix.c
@@ -4,3 +4,30 @@
 //
 // 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-prefixes=STRICT,NODEBUGGER-TUNE %s
+// RUN: %clang --target=powerpc64-ibm-aix-xcoff -### %s -flto -g 2>&1 \
+// RUN:   | FileCheck -check-prefixes=STRICT,NODEBUGGER-TUNE %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"
+// NODEBUGGER-TUNE-NOT: "-bplugin_opt:-debugger-tune="
+//
+// STRICT:       "-bplugin_opt:-strict-dwarf=true"
+// NOSTRICT-NOT: "-bplugin_opt:-strict-dwarf=true"


        


More information about the cfe-commits mailing list