[PATCH] hppa64-hpux: Create dummy milli.a archives for binutils and ld testsuites

John David Anglin dave.anglin@bell.net
Sat Apr 4 20:28:05 GMT 2026


Okay?

I had to hack default_link_ld to append LDFLAGS and modify the
binutils default.exp to include procs from the ld testsuite.

Tested on hppa64-hp-hpux11.11 and x86_64-pc-linux-gnu.

Dave
---

hppa64-hpux: Create dummy milli.a archives for binutils and ld testsuites

The hppa64-*-hpux* target has to always link against the milli.a
archive to resolve various millicode routines.  However, this
breaks the binutils and ld testsuites on hosts without the milli.a
archive.

This change adds dummy milli.a archives on the hppa64-*-hpux* target
if ld cannot find the file.  The procedure is similar to that used
for alpha*-*-*vms* but we also need it for the binutils testsuite.

Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>

2026-04-04  John David Anglin  <danglin@gcc.gnu.org>

binutils/ChangeLog:

	* testsuite/config/default.exp: Load ld-lib.exp.
	(ld_assemble, ld_link): New procs.
	Create dummy missing libraries for hppa*64-*-hpux*
	target.  Append " -Ltmpdir" to LDFLAGS.

ld/ChangeLog:

	* testsuite/config/default.exp: Create dummy missing
	libraries for hppa*64-*-hpux* target.  Append
	" -Ltmpdir" to LDFLAGS.
	* testsuite/lib/ld-lib.exp (default_ld_link): Append
	LDFLAGS to flags variable.

diff --git a/binutils/testsuite/config/default.exp b/binutils/testsuite/config/default.exp
index 25bd1e64222..9dca734a27c 100644
--- a/binutils/testsuite/config/default.exp
+++ b/binutils/testsuite/config/default.exp
@@ -20,6 +20,7 @@
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
 load_lib utils-lib.exp
+load_lib ../../../ld/testsuite/lib/ld-lib.exp
 
 if ![info exists AS] then {
     set AS [findfile $base_dir/../gas/as-new $base_dir/../gas/as-new [transform as]]
@@ -120,6 +121,41 @@ proc link_or_copy { src dst } {
     catch "exec cp -fpu ../$src tmpdir/gas/$dst" status
 }
 
+#
+# ld_assemble
+#       assemble a file
+#
+proc ld_assemble { as source object } {
+        default_ld_assemble $as "" $source $object
+}
+
+#
+# ld_link
+#       link a program using ld
+#
+proc ld_link { ld target objects } {
+        default_ld_link $ld $target $objects
+}
+
+if { [istarget hppa*64-*-hpux*] } {
+    set src tmpdir/empty.s
+    set f [open $src "w"]
+    close $f
+    if { [ld_assemble $AS $src tmpdir/empty.o]
+	 && ![ld_link $LD tmpdir/empty tmpdir/empty.o]
+	 && [regsub -all {[^\n]*: cannot find ([^\n :]*)[^\n]*} $exec_output {tmpdir/\1 } missing_libs] } {
+	regsub -all {\$} $missing_libs {\\\$} missing_libs
+	for { set i 0 } { $i < [llength $missing_libs] } { incr i } {
+	    set f [lindex $missing_libs $i]
+	    verbose -log "creating dummy $f"
+	    ar_simple_create $AR {} $f tmpdir/empty.o
+	}
+	append LDFLAGS " -Ltmpdir"
+	unset i missing_libs
+    }
+    unset f src
+}
+
 if {[file isfile gas/as-new[exe_ext]]} then {
     link_or_copy gas/as-new[exe_ext] as[exe_ext]
 } else {
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 2796f719f22..cc0576b3975 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -552,6 +552,26 @@ if { [istarget alpha*-*-*vms*] } {
     unset f src
 }
 
+# Provide dummy milli.a that hppa64-hpux-ld always loads
+if { [istarget hppa*64-*-hpux*] } {
+    set src tmpdir/empty.s
+    set f [open $src "w"]
+    close $f
+    if { [ld_assemble $as $src tmpdir/empty.o]
+	 && ![ld_link $LD tmpdir/empty tmpdir/empty.o]
+	 && [regsub -all {[^\n]*: cannot find ([^\n :]*)[^\n]*} $exec_output {tmpdir/\1 } missing_libs] } {
+	regsub -all {\$} $missing_libs {\\\$} missing_libs
+	for { set i 0 } { $i < [llength $missing_libs] } { incr i } {
+	    set f [lindex $missing_libs $i]
+	    verbose -log "creating dummy $f"
+	    ar_simple_create $ar {} $f tmpdir/empty.o
+	}
+	append LDFLAGS " -Ltmpdir"
+	unset i missing_libs
+    }
+    unset f src
+}
+
 set plug_opt ""
 if { [check_compiler_available] } {
     set plugin_names {
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index d37d33cd96c..d1b6f2e058f 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -231,11 +231,13 @@ proc get_board_flags {} {
 proc default_ld_link { ld target objects } {
     global host_triplet
     global exec_output
+    global LDFLAGS
 
     set flags ""
     if [is_endian_output_format $objects] then {
 	set flags [big_or_little_endian]
     }
+    set flags "$flags $LDFLAGS"
 
     # When using GCC as the linker driver, we need to specify board cflags when
     # linking because cflags may contain linker options.  For example when
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260404/8cb242f5/attachment.sig>


More information about the Binutils mailing list