Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] gdb/testsuite: Make windows-msvc test with lld-link + DWARF
@ 2026-08-11  0:36 Pedro Alves
  2026-08-11  0:36 ` [PATCH 1/2] gdb/testsuite: Force lld-link linker on windows-msvc Pedro Alves
  2026-08-11  0:37 ` [PATCH 2/2] gdb/testsuite: Force DWARF debug info " Pedro Alves
  0 siblings, 2 replies; 3+ messages in thread
From: Pedro Alves @ 2026-08-11  0:36 UTC (permalink / raw)
  To: gdb-patches

This series continues teaching the GDB testsuite about Windows targets
whose triplet uses the "windows" OS and the MSVC ABI, as produced by
Clang (e.g. x86_64-pc-windows-msvc), so that a MinGW-hosted GDB
configured with:

 --host=x86_64-w64-mingw32 --target=x86_64-pc-windows-msvc

can be exercised against a matching Clang.

This builds on the series that added base support for windows-msvc to
the testsuite:

  https://inbox.sourceware.org/gdb-patches/20260723130118.206735-1-pedro@palves.net/T/#t
  [PATCH 00/27] Teach the testsuite about the Windows/MSVC target

This short series forces lld-link and DWARF on windows-msvc.

See individual commits for details.

Pedro Alves (2):
  gdb/testsuite: Force lld-link linker on windows-msvc
  gdb/testsuite: Force DWARF debug info on windows-msvc

 gdb/testsuite/lib/gdb.exp | 94 ++++++++++++++++++++++++++++++++-------
 1 file changed, 79 insertions(+), 15 deletions(-)


base-commit: a80fede20bc1330eca5e419392c6595bb3a6ac1d
-- 
2.54.0


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

* [PATCH 1/2] gdb/testsuite: Force lld-link linker on windows-msvc
  2026-08-11  0:36 [PATCH 0/2] gdb/testsuite: Make windows-msvc test with lld-link + DWARF Pedro Alves
@ 2026-08-11  0:36 ` Pedro Alves
  2026-08-11  0:37 ` [PATCH 2/2] gdb/testsuite: Force DWARF debug info " Pedro Alves
  1 sibling, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2026-08-11  0:36 UTC (permalink / raw)
  To: gdb-patches

clang windows-msvc defaults to using the Microsoft link.exe linker.
That does not work with DWARF though, we have to use lld-link instead.
That is why the whole windows-msvc support in the testsuite assumes
the linker in use is lld-link.

So far, I've been running the testsuite with
CC_FOR_TARGET/CXX_FOR_TARGET pointing at a clang wrapper script that
adds "-fuse-ld=lld-link", but I think this belongs in the testsuite
directly, since it's not really optional.

Change-Id: I5bcafa408696b349b829b4ffbd75037be25b3f3b
---
 gdb/testsuite/lib/gdb.exp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 6fb04869605..912ddf1cd54 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6660,6 +6660,15 @@ proc gdb_compile {source dest type options} {
 	}
     }
 
+    if {[istarget "*-*-windows-msvc*"]} {
+	# Clang wants to use the Microsoft linker by default.  That
+	# doesn't support DWARF, so link with lld-link instead, which
+	# does support DWARF (and PDB/CodeView).  Pass -Xarch_host so
+	# that when we're compiling HIP code, we only affect the host
+	# linker.
+	lappend new_options "early_flags=-Xarch_host -fuse-ld=lld-link"
+    }
+
     # If the 'build-id' option is used, then ensure that we generate a
     # build-id.  It is possible that the compiler is configured to do
     # so automatically, but at least for GCC the configure option
-- 
2.54.0


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

* [PATCH 2/2] gdb/testsuite: Force DWARF debug info on windows-msvc
  2026-08-11  0:36 [PATCH 0/2] gdb/testsuite: Make windows-msvc test with lld-link + DWARF Pedro Alves
  2026-08-11  0:36 ` [PATCH 1/2] gdb/testsuite: Force lld-link linker on windows-msvc Pedro Alves
@ 2026-08-11  0:37 ` Pedro Alves
  1 sibling, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2026-08-11  0:37 UTC (permalink / raw)
  To: gdb-patches

Clang's windows-msvc targets default to outputting PDB debug info for
host code, which GDB does not understand.  This commit makes the
testsuite tell the compiler/linker to emit DWARF instead.

There is a block in gdb_compile already doing this for AIX, so we
extend it.

Extra care is taken to make it possible to run the testsuite with
another debug format, by passing the (pre-existing) debug_format flag,
like this for example on the command line:

 $ make check RUNTESTFLAGS="--target_board unix/gdb:debug_flags=-gcodeview"

or with a custom board that sets debug_flags.

Change-Id: I5bcafa408696b349b829b4ffbd75037be25b3f3b
---
 gdb/testsuite/lib/gdb.exp | 85 ++++++++++++++++++++++++++++++++-------
 1 file changed, 70 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 912ddf1cd54..0d3497fa3f2 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6747,21 +6747,76 @@ proc gdb_compile {source dest type options} {
 	}
     }
 
-    # On AIX systems, until GCC 12 (maybe later), stabs was the default
-    # debug option, but we'd like to have dwarf instead.
-    # If we're running on one of those systems and debug was requested,
-    # but no explicit -g<format> option was given, use -gdwarf to force
-    # that as the debug info for the inferior.
-    # This list should be exhaustive:
-    set debug_format "btf|ctf|stabs|vms|coff|xcoff"
-    # Since additional_flags is a comma separated list, identify if there
-    # are other (optional) flags in the list.
-    set other_options "-\[a-zA-Z0-9\]*,"
-    set full_regexp "^additional_flags=\($other_options\)*-g\($debug_format\)"
-    if { [istarget *-*-aix*]
-	 && [lsearch -exact $options debug] != -1
-	 && [lsearch -regexp $options $full_regexp] == -1} {
-	lappend new_options "additional_flags=-gdwarf"
+    # Some systems default to debug formats other than DWARF, but we'd
+    # like to have DWARF instead:
+    #
+    # - On AIX systems, until GCC 12 (maybe later), stabs was the
+    #   default debug option.
+    #
+    # - windows-msvc targets default to PDB/CodeView debug info, which
+    #   we don't support.
+    #
+    # If we're running on one of those systems and debug was
+    # requested, but no explicit -g<format> option was given, nor has
+    # a specific debug format been requested via debug_flags in the
+    # target board, use -gdwarf to force DWARF as the debug info for
+    # the inferior.
+    if {[lsearch -exact $options debug] != -1} {
+	# This list should be exhaustive:
+	set debug_format "btf|ctf|stabs|vms|coff|xcoff|dwarf|codeview"
+	# True if we're using DWARF.
+	set using_dwarf 0
+	# Since additional_flags is a comma separated list, identify
+	# if there are other (optional) flags in the list.
+	set other_options "-\[a-zA-Z0-9\]*,"
+	set full_regexp "^additional_flags=\($other_options\)*-g\($debug_format\)"
+	if { ([istarget *-*-aix*] || [istarget *-*-windows-msvc*])
+	     && ![board_info [target_info name] exists debug_flags]
+	     && [lsearch -regexp $options $full_regexp] == -1} {
+	    # Nothing is explicitly choosing a debug format.  Emit
+	    # DWARF.
+	    lappend new_options "additional_flags=-gdwarf"
+	    set using_dwarf 1
+	}
+
+	# On windows-msvc, if we're targeting DWARF, we need a couple
+	# extra linker (lld-link) options.  This is a separate check
+	# from the above because we need to check whether the board
+	# file selects DWARF via debug_flags.
+	if { [istarget *-*-windows-msvc*] } {
+	    set dwarf_regexp "^additional_flags=\($other_options\)*-gdwarf"
+	    if { [board_info [target_info name] exists debug_flags] } {
+		# The board wants a specific debug format.  Check
+		# whether it's DWARF.
+		set board_debug_flags "[board_info [target_info name] debug_flags]"
+		if { [lsearch -regexp $board_debug_flags "-gdwarf"] != -1 } {
+		    set using_dwarf 1
+		}
+	    } elseif { [lsearch -regexp $options $dwarf_regexp] == -1 } {
+		# The testcase explicitly requested DWARF.
+		set using_dwarf 1
+	    }
+
+	    if {$using_dwarf} {
+		# Passing "-debug:dwarf" to lld-link suppresses:
+		#  lld-link: warning: section name .debug_info is longer
+		#    than 8 characters and will use a non-standard string table
+		#
+		# -Wl,/ignore:longsections would also work, but
+		# telling lld-link we're outputting DWARF does more
+		# than suppress the warning.
+		#
+		# Passing -debug:none before -debug:dwarf is necessary
+		# to disable PDB emission.  This is because Clang
+		# passes -debug to lld-link if you specify _any_ -g
+		# option, including -gdwarf, and -debug makes lld-link
+		# emit a PDB file.  IOW, even plain -gdwarf still
+		# emits a (mostly empty and useless) PDB file.
+		# -debug:dwarf does not disable PDB emission (by
+		# design), but "-debug:none" does disable it.
+		lappend new_options "ldflags=-Wl,-debug:none -Wl,-debug:dwarf"
+	    }
+	}
     }
 
     set shlib_found 0
-- 
2.54.0


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

end of thread, other threads:[~2026-08-11  0:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-11  0:36 [PATCH 0/2] gdb/testsuite: Make windows-msvc test with lld-link + DWARF Pedro Alves
2026-08-11  0:36 ` [PATCH 1/2] gdb/testsuite: Force lld-link linker on windows-msvc Pedro Alves
2026-08-11  0:37 ` [PATCH 2/2] gdb/testsuite: Force DWARF debug info " Pedro Alves

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