Skip to content

Commit 7d58760

Browse files
committed
[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5.
When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. For DWARF5 we have functional .debug_names. TBH not sure what the right behavior should be. Should we not generate anything at all by default or generate .debug_names? Doing some archeological digging initially -gnu-pubnames was always generated to be in line with what gcc does.. It was then changed so that it was generated when split-dwarf was enabled: 6586452#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf141777761dfb545c5d228 For LLDB these gnu sections are not useful and just waste space. Maybe a better check is to be based on tunning?
1 parent d37affb commit 7d58760

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,14 +4478,20 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
44784478
Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames,
44794479
options::OPT_gpubnames, options::OPT_gno_pubnames);
44804480
if (DwarfFission != DwarfFissionKind::None ||
4481-
(PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
4482-
if (!PubnamesArg ||
4483-
(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
4484-
!PubnamesArg->getOption().matches(options::OPT_gno_pubnames)))
4481+
(PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) {
4482+
const bool OptionSet =
4483+
(PubnamesArg &&
4484+
(PubnamesArg->getOption().matches(options::OPT_gpubnames) ||
4485+
PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames)));
4486+
if ((DebuggerTuning != llvm::DebuggerKind::LLDB || OptionSet) &&
4487+
(!PubnamesArg ||
4488+
(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
4489+
!PubnamesArg->getOption().matches(options::OPT_gno_pubnames))))
44854490
CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches(
44864491
options::OPT_gpubnames)
44874492
? "-gpubnames"
44884493
: "-ggnu-pubnames");
4494+
}
44894495
const auto *SimpleTemplateNamesArg =
44904496
Args.getLastArg(options::OPT_gsimple_template_names,
44914497
options::OPT_gno_simple_template_names);

clang/test/Driver/split-debug.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// NOINLINE-NOT: "-fsplit-dwarf-inlining"
1212
// SPLIT-NOT: "-dumpdir"
1313
// SPLIT: "-debug-info-kind=constructor"
14-
// SPLIT-SAME: "-ggnu-pubnames"
1514
// SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
1615

1716
// RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT
@@ -124,3 +123,13 @@
124123
// G1_NOSPLIT: "-debug-info-kind=line-tables-only"
125124
// G1_NOSPLIT-NOT: "-split-dwarf-file"
126125
// G1_NOSPLIT-NOT: "-split-dwarf-output"
126+
127+
/// Do not generate -ggnu-pubnames for -glldb
128+
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT
129+
130+
// GLLDBSPLIT-NOT: "-ggnu-pubnames"
131+
132+
/// Generate -ggnu-pubnames for -glldb when it is explicitly enabled
133+
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb -ggnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT2
134+
135+
// GLLDBSPLIT2: "-ggnu-pubnames"

0 commit comments

Comments
 (0)