[PATCH 07/27] gdb/testsuite: Use /IMPLIB on windows-msvc to name import libraries

Pedro Alves <[email protected]> Thu, 23 Jul 2026 14:00:58 +0100
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
When building a shared library for a test, gdb_compile_shlib asks the
linker to write an import library named after the DLL, so that the
test executable can later link against it.  This currently always uses
GNU ld's --out-implib switch.

lld-link, the linker Clang drives on a windows-msvc target, does not
understand --out-implib.  It only accepts MSVC's link.exe slash-style
flags.  Use /IMPLIB instead, which names the import library the same
way.

Change-Id: I3deb3f0d16c27891b69e40f01656944ed5d52210
---
 gdb/testsuite/lib/gdb.exp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 25f01ed9727..c9ee8e9753d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -7308,7 +7308,11 @@ proc gdb_compile_shlib_1 {sources dest options} {
 	    } else {
 		set name ${dest}
 	    }
-	    lappend link_options "ldflags=-Wl,--out-implib,${name}.a"
+	    if { [istarget "*-*-windows-msvc*"] } {
+		lappend link_options "ldflags=-Wl,/IMPLIB:${name}.a"
+	    } else {
+		lappend link_options "ldflags=-Wl,--out-implib,${name}.a"
+	    }
 	} else {
 	    # Set the soname of the library.  This causes the linker on ELF
 	    # systems to create the DT_NEEDED entry in the executable referring
-- 
2.54.0