Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/hip: Prepare for DWARF-assembler-based HIP testcases
@ 2026-07-07 11:15 Pedro Alves
  2026-07-08 17:53 ` Lancelot SIX
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2026-07-07 11:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot SIX

Compiling a testcase with debug info (by passing passing "debug" as
gdb_compile option) has the effect of passing -g to the compiler.  -g
in turn enables an LLVM option that is essential for debugging:
'-mllvm -amdgpu-spill-cfi-saved-regs'.

That option affects code generation, and some features of the DWARF
assembler machinery rely on code generated by the compiler without -g
to be the exact same as the code generated with -g.

This patch addresses that by always compiling with the LLVM option
that -g would enable.

Change-Id: I64a938edf97c85d0ea9fc34b37071daa560de7e7
---
 gdb/testsuite/lib/gdb.exp | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a19e8ba6729..a40c87c6727 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6745,11 +6745,35 @@ proc gdb_compile {source dest type options} {
 	lappend new_options "early_flags=-fno-stack-protector"
     }
 
-    # hipcc defaults to -O2, so add -O0 to early flags for the hip language.
-    # If "optimize" is also requested, another -O flag (e.g. -O2) will be added
-    # to the flags, overriding this -O0.
     if {[lsearch -exact $options hip] != -1} {
-	lappend new_options "early_flags=-O0"
+	# The -g option enables an LLVM option that is essential for
+	# debugging (-mllvm -amdgpu-spill-cfi-saved-regs), but that
+	# unfortunately also affects code generation.  We don't want
+	# to hardcode -g here though, because some tests want to test
+	# debugging without debug info, and yet others want to compile
+	# their binary without debug info or with -gline-info-only,
+	# and then use the DWARF assembler to generate their own debug
+	# info.  Some features of the DWARF assembler rely on nodebug
+	# and debug binaries having the exact same generated code, so,
+	# explicitly compile with the LLVM option that -g would
+	# enable, and leave adding -g to the testcase, via the "debug"
+	# option, as normal.
+	#
+	# Disable -Wunused-command-line-argument to avoid warnings
+	# like:
+	#
+	#  clang: warning: argument unused during compilation: \
+	#    '-mllvm=-amdgpu-spill-cfi-saved-regs' [-Wunused-command-line-argument]
+	#
+	# These happen when we're compiling an executable _and_ all
+	# the input files are .o files, like: hipcc foo.o -o foo ...
+	#
+	# HIPCC defaults to -O2, so add -O0 to early flags for the HIP
+	# language.  If "optimize" is also requested, another -O flag
+	# (e.g. -O2) will be added to the flags, overriding this -O0.
+	lappend new_options "early_flags=-O0\
+			     -mllvm=-amdgpu-spill-cfi-saved-regs\
+			     -Wno-unused-command-line-argument"
     }
 
     # Because we link with libraries using their basename, we may need

base-commit: 57d9dfcf39cd3c2897bb76c2dbd7074f065685df
-- 
2.54.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-09 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-07 11:15 [PATCH] gdb/hip: Prepare for DWARF-assembler-based HIP testcases Pedro Alves
2026-07-08 17:53 ` Lancelot SIX
2026-07-09 14:02   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox