Skip to content

Commit a6c8407

Browse files
authored
[CLANG][DWARF] Do not emit -ggnu-pubnames for LLDB tuning, unless -ggnu-pubnames is specified. (#83331)
When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. This is used by GDB, but not by LLDB. Changed so that these sections are not emitted for LLDB tuning, unless flag is passed explicitly.
1 parent 6494f9b commit a6c8407

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,13 @@
124124
// G1_NOSPLIT: "-debug-info-kind=line-tables-only"
125125
// G1_NOSPLIT-NOT: "-split-dwarf-file"
126126
// G1_NOSPLIT-NOT: "-split-dwarf-output"
127+
128+
/// Do not generate -ggnu-pubnames for -glldb
129+
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT
130+
131+
// GLLDBSPLIT-NOT: "-ggnu-pubnames"
132+
133+
/// Generate -ggnu-pubnames for -glldb when it is explicitly enabled
134+
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb -ggnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT2
135+
136+
// GLLDBSPLIT2: "-ggnu-pubnames"

0 commit comments

Comments
 (0)