[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-27 Thread Alexander Yermolovich via cfe-commits

ayermolo wrote:

https://github.com/llvm/llvm-project/pull/83206

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-27 Thread Alexander Yermolovich via cfe-commits

ayermolo wrote:

> It's been a few hours. Time to revert and analyze offline?

I think I have a fix. Just takes forever to setup and build on my laptop to 
test it.
Basically I think mac defaults to LLDB tuning, and test that fails explicitly 
passes the flag in.

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-27 Thread Nico Weber via cfe-commits

nico wrote:

It's been a few hours. Time to revert and analyze offline?

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-27 Thread Alexander Yermolovich via cfe-commits

ayermolo wrote:

> Looks this breaks tests on macOS: http://45.33.8.238/macm1/79435/step_7.txt
> 
> Please take a look and revert for now if it takes a while to fix.



> Looks this breaks tests on macOS: http://45.33.8.238/macm1/79435/step_7.txt
> 
> Please take a look and revert for now if it takes a while to fix.

Looks like it's just one test that checks for -ggnu-pubnames. Let me take a 
look.

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-27 Thread Nico Weber via cfe-commits

nico wrote:

Looks this breaks tests on macOS: http://45.33.8.238/macm1/79435/step_7.txt

Please take a look and revert for now if it takes a while to fix.

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-27 Thread Alexander Yermolovich via cfe-commits

https://github.com/ayermolo closed 
https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-26 Thread David Blaikie via cfe-commits

https://github.com/dwblaikie approved this pull request.


https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-26 Thread Alexander Yermolovich via cfe-commits

https://github.com/ayermolo updated 
https://github.com/llvm/llvm-project/pull/82840

>From 1ac054cc8d5ee99169547ae09da0411b6e8e48e8 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Fri, 23 Feb 2024 14:52:04 -0800
Subject: [PATCH 1/2] [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:
https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228

For LLDB these gnu sections are not useful and just waste space. Maybe a better
check is to be based on tunning?
---
 clang/lib/Driver/ToolChains/Clang.cpp | 7 ---
 clang/test/Driver/split-debug.c   | 1 -
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6e1b7e8657d0dc..27a5aef17c8d71 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-if (!PubnamesArg ||
-(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
- !PubnamesArg->getOption().matches(options::OPT_gno_pubnames)))
+if (EffectiveDWARFVersion < 5 &&
+(!PubnamesArg ||
+ (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
+  !PubnamesArg->getOption().matches(options::OPT_gno_pubnames
   CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches(
options::OPT_gpubnames)
 ? "-gpubnames"
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 968f33b4cc035c..1d5f0fa42fdeea 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -11,7 +11,6 @@
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
-// SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT

>From 69028ca2940e6e033718a34c4acd6c079343c5d3 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Fri, 23 Feb 2024 17:35:36 -0800
Subject: [PATCH 2/2] changred to tunning, added test

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 clang/test/Driver/split-debug.c   | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 27a5aef17c8d71..dbfc729bba24c7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4479,7 +4479,7 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-if (EffectiveDWARFVersion < 5 &&
+if (DebuggerTuning != llvm::DebuggerKind::LLDB &&
 (!PubnamesArg ||
  (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
   !PubnamesArg->getOption().matches(options::OPT_gno_pubnames
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 1d5f0fa42fdeea..a2a3dc02354503 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -11,6 +11,7 @@
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
+// SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT
@@ -123,3 +124,8 @@
 // G1_NOSPLIT: "-debug-info-kind=line-tables-only"
 // G1_NOSPLIT-NOT: "-split-dwarf-file"
 // G1_NOSPLIT-NOT: "-split-dwarf-output"
+
+/// Do not generate -ggnu-pubnames for -glldb
+// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | 
FileCheck %s --check-prefixes=GLLDBSPLIT
+
+// GLLDBSPLIT-NOT: "-ggnu-pubnames"

___

[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread Alexander Yermolovich via cfe-commits

ayermolo wrote:

Changed to tunning.

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread Alexander Yermolovich via cfe-commits

https://github.com/ayermolo updated 
https://github.com/llvm/llvm-project/pull/82840

>From 714cc804f2716bbd3c666d8922403299e4c19893 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Fri, 23 Feb 2024 14:52:04 -0800
Subject: [PATCH 1/2] [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:
https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228

For LLDB these gnu sections are not useful and just waste space. Maybe a better
check is to be based on tunning?
---
 clang/lib/Driver/ToolChains/Clang.cpp | 7 ---
 clang/test/Driver/split-debug.c   | 1 -
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6e1b7e8657d0dc..27a5aef17c8d71 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-if (!PubnamesArg ||
-(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
- !PubnamesArg->getOption().matches(options::OPT_gno_pubnames)))
+if (EffectiveDWARFVersion < 5 &&
+(!PubnamesArg ||
+ (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
+  !PubnamesArg->getOption().matches(options::OPT_gno_pubnames
   CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches(
options::OPT_gpubnames)
 ? "-gpubnames"
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 968f33b4cc035c..1d5f0fa42fdeea 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -11,7 +11,6 @@
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
-// SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT

>From 8784b440cd3792925179ea1e058b762397bcdf6a Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Fri, 23 Feb 2024 17:35:36 -0800
Subject: [PATCH 2/2] changred to tunning, added test

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 clang/test/Driver/split-debug.c   | 6 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 27a5aef17c8d71..dbfc729bba24c7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4479,7 +4479,7 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-if (EffectiveDWARFVersion < 5 &&
+if (DebuggerTuning != llvm::DebuggerKind::LLDB &&
 (!PubnamesArg ||
  (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
   !PubnamesArg->getOption().matches(options::OPT_gno_pubnames
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 1d5f0fa42fdeea..a2a3dc02354503 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -11,6 +11,7 @@
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
+// SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT
@@ -123,3 +124,8 @@
 // G1_NOSPLIT: "-debug-info-kind=line-tables-only"
 // G1_NOSPLIT-NOT: "-split-dwarf-file"
 // G1_NOSPLIT-NOT: "-split-dwarf-output"
+
+/// Do not generate -ggnu-pubnames for -glldb
+// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | 
FileCheck %s --check-prefixes=GLLDBSPLIT
+
+// GLLDBSPLIT-NOT: "-ggnu-pubnames"

___

[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread Greg Clayton via cfe-commits

clayborg wrote:

I just noticed the naming difference. I am thinking of the standard older 
`.debug_pubnames` and `.debug_pubtypes`. Are the `.debug_gnu_pubnames` and 
`.debug_gnu_pubtypes` more complete and usable by debuggers? If so, then we 
should use the `-dlldb` to disable these GNU specific pubnames and pubtypes 
sections. And ensure that `-ggdb` enables these if GDB still uses them and if 
it doesn't support `.debug_names` very well.

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread Greg Clayton via cfe-commits

clayborg wrote:

I am fine with `-glldb` doing the right thing for LLDB. 

That being said, I don't believe that LLDB or GDB use `.debug_pubnames` or 
`.debug_pubtypes` as they are incomplete and can't be relied upon. So I would 
say we should never emit these tables unless these older GNU tables unless the 
user explicitly asks for them.

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread David Blaikie via cfe-commits

dwblaikie wrote:

If you're debugging with lldb you should probably be using -glldb - if you're 
doing that, certainly gnu-pubnames should not be enabled by default or 
implicitly by gsplit-dwarf.

I'd say -gsplit-dwarf -glldb probably doesn't need any names/accelerator table 
by default (any more than the non-split dwarf should default enable names in 
-glldb - which, maybe it should be, since it is the default on apple platforms, 
I think?) - split dwarf for gcc needed to (& I think should still be the 
default, under -ggdb (the default on Linux etc)) enable gnuoubnames by default 
for correctness (gdb would assume it was present/accurate and fail lookups, 
rather than falling back to slow performance/exhaustive search)

https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexander Yermolovich (ayermolo)


Changes

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:
https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228

For LLDB these gnu sections are not useful and just waste space. Maybe a better
check is to be based on tunning?


---
Full diff: https://github.com/llvm/llvm-project/pull/82840.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+4-3) 
- (modified) clang/test/Driver/split-debug.c (-1) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6e1b7e8657d0dc..27a5aef17c8d71 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-if (!PubnamesArg ||
-(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
- !PubnamesArg->getOption().matches(options::OPT_gno_pubnames)))
+if (EffectiveDWARFVersion < 5 &&
+(!PubnamesArg ||
+ (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
+  !PubnamesArg->getOption().matches(options::OPT_gno_pubnames
   CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches(
options::OPT_gpubnames)
 ? "-gpubnames"
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 968f33b4cc035c..1d5f0fa42fdeea 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -11,7 +11,6 @@
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
-// SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT

``




https://github.com/llvm/llvm-project/pull/82840
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (PR #82840)

2024-02-23 Thread Alexander Yermolovich via cfe-commits

https://github.com/ayermolo created 
https://github.com/llvm/llvm-project/pull/82840

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:
https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228

For LLDB these gnu sections are not useful and just waste space. Maybe a better
check is to be based on tunning?


>From 714cc804f2716bbd3c666d8922403299e4c19893 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich 
Date: Fri, 23 Feb 2024 14:52:04 -0800
Subject: [PATCH] [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:
https://github.com/llvm/llvm-project/commit/658645241bf0c624d4b7a67c195c239bbc193e3f#diff-bac41c71569f27df21a843bcd74d2e604ed508afbdf14161dfb545c5d228

For LLDB these gnu sections are not useful and just waste space. Maybe a better
check is to be based on tunning?
---
 clang/lib/Driver/ToolChains/Clang.cpp | 7 ---
 clang/test/Driver/split-debug.c   | 1 -
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6e1b7e8657d0dc..27a5aef17c8d71 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4479,9 +4479,10 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-if (!PubnamesArg ||
-(!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
- !PubnamesArg->getOption().matches(options::OPT_gno_pubnames)))
+if (EffectiveDWARFVersion < 5 &&
+(!PubnamesArg ||
+ (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
+  !PubnamesArg->getOption().matches(options::OPT_gno_pubnames
   CmdArgs.push_back(PubnamesArg && PubnamesArg->getOption().matches(
options::OPT_gpubnames)
 ? "-gpubnames"
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index 968f33b4cc035c..1d5f0fa42fdeea 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -11,7 +11,6 @@
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
 // SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
-// SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" 
"split-debug.dwo"
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits