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

Message ID adQCzWcRFWyLkdjb@mx3210.local
State New
Headers
Series hppa64-hpux: Create dummy milli.a archives for binutils and ld testsuites [v2] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

John David Anglin April 6, 2026, 7 p.m. UTC
  In v2, I reworked the change to default.exp in the binutils testsuite to
avoid usings procs from the ld testsuite.

Tested on hppa64-hp-hpux11.11 and x86_64-pc-linux-gnu.  Fixes all fails
due to missing milli.a archive.

Okay?

Dave
---

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

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
in the binutils and ld testsuites if ld cannot find the file.  The
method used is similar to that for alpha*-*-*vms*.

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: 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.
  

Comments

Maciej W. Rozycki April 15, 2026, 5:10 p.m. UTC | #1
On Mon, 6 Apr 2026, John David Anglin wrote:

> In v2, I reworked the change to default.exp in the binutils testsuite to
> avoid usings procs from the ld testsuite.
> 
> Tested on hppa64-hp-hpux11.11 and x86_64-pc-linux-gnu.  Fixes all fails
> due to missing milli.a archive.

 I can see:

hppa64-hp-hpux11.23  -FAIL: objcopy executable (pr25662)
hppa64-hp-hpux11.23  +FAIL: ld-elf/pr30791b
hppa64-hp-hpux11.23  +FAIL: relocatable with script

compared to commit 77cb5ee0f268 ("gas: pru: Add flag to select core 
revision") after which linking `milli.a' was added; I hope it's expected.

> 2026-04-04  John David Anglin  <danglin@gcc.gnu.org>
> 
> binutils/ChangeLog:
> 
> 	* testsuite/config/default.exp: 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.

 Hmm, I think it would be safer long-term (even if nothing breaks right 
away) if our dummy `milli.a' library lived on its own in a separate 
directory such as `tmpdir/milli' that isn't expected to be ever used by 
any tests, in particular generic ones.  This way adding " -Ltmpdir/milli" 
won't interfere with tests that want or don't want to have `tmpdir' in the 
library search path for some reason.

 I can see `alpha*-*-*vms*' already uses " -Ltmpdir", so we have previous 
art, but I'd rather fix it (separately, definitely an expectation for you 
to do it) than add another case.

> 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"

 Why is this addition required for `hppa*64-*-hpux*' while not for 
`alpha*-*-*vms*'?

  Maciej
  
John David Anglin April 15, 2026, 11:28 p.m. UTC | #2
On 2026-04-15 1:10 p.m., Maciej W. Rozycki wrote:
> On Mon, 6 Apr 2026, John David Anglin wrote:
> 
>> In v2, I reworked the change to default.exp in the binutils testsuite to
>> avoid usings procs from the ld testsuite.
>>
>> Tested on hppa64-hp-hpux11.11 and x86_64-pc-linux-gnu.  Fixes all fails
>> due to missing milli.a archive.
> 
>  I can see:
> 
> hppa64-hp-hpux11.23  -FAIL: objcopy executable (pr25662)

This test now passes.

> hppa64-hp-hpux11.23  +FAIL: ld-elf/pr30791b

Note I said "Fixes all fails due to missing milli.a archive".  There are
about 23 fails on x86_64-pc-linux-gnu for the hppa64-hpux target which I
haven't had time to investigate.  There are more fails on hpux.  I see about
59 ld fails on alpha-vms.

I believe this fail is caused by the following:

static void
hppa64elf_after_parse (void)
{
  /* Stop the linker merging .text sections on relocatable links.  */
  if (bfd_link_relocatable (&link_info))
    lang_add_unique (".text");

This was done in preparation for improved stub support for long branches.
The above was taken from the 32-bit hppaelf.em file.  Maybe there is a better
way?

The pr30791b.d file has:
#source: pr30791c.s
#source: pr30791d.s
#ld: -r
#readelf: -S --wide
#xfail: hppa-*-* z80-*-*
# hppa fails since .text sections aren't merged for relocatable link.

The xfail isn't correct, and doesn't handle hppa64 or other 32-bit target
names (e.g., hppa2.0).

> hppa64-hp-hpux11.23  +FAIL: relocatable with script

This fails for the same reason.  The relocatable.d has:
#name: relocatable with script
#source: simple.s
#ld: -r -T relocatable.t
#readelf: -S --wide
#xfail: hppa-*-* hppa[12]*-*-*
> compared to commit 77cb5ee0f268 ("gas: pru: Add flag to select core 
> revision") after which linking `milli.a' was added; I hope it's expected.
> 
>> 2026-04-04  John David Anglin  <danglin@gcc.gnu.org>
>>
>> binutils/ChangeLog:
>>
>> 	* testsuite/config/default.exp: 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.
> 
>  Hmm, I think it would be safer long-term (even if nothing breaks right 
> away) if our dummy `milli.a' library lived on its own in a separate 
> directory such as `tmpdir/milli' that isn't expected to be ever used by 
> any tests, in particular generic ones.  This way adding " -Ltmpdir/milli" 
> won't interfere with tests that want or don't want to have `tmpdir' in the 
> library search path for some reason.

Will adjust change.  Maybe it's better to use "hppa" instead of "milli"
for the directory name?  That would work better on alpha.  I don't know
the names of the libraries that are always linked against on alpha-vms.
>  I can see `alpha*-*-*vms*' already uses " -Ltmpdir", so we have previous 
> art, but I'd rather fix it (separately, definitely an expectation for you 
> to do it) than add another case.
> 
>> 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"
> 
>  Why is this addition required for `hppa*64-*-hpux*' while not for 
> `alpha*-*-*vms*'?

This addition fixes the following tests for hppa64-hp-hpux11.11 on x86_64-pc-linux-gnu:

-FAIL: Link eh-group.o to eh-group
+PASS: Link eh-group.o to eh-group

-FAIL: assignment of ELF sections to segments (same page)
-FAIL: assignment of ELF sections to segments (adjacent pages)
-FAIL: assignment of ELF sections to segments (disjoint pages)
+PASS: assignment of ELF sections to segments (same page)
+PASS: assignment of ELF sections to segments (adjacent pages)
+PASS: assignment of ELF sections to segments (disjoint pages)

-FAIL: ALIGNOF
+PASS: ALIGNOF

-FAIL: section-flags-1
-FAIL: section-flags-2
+PASS: section-flags-1
+PASS: section-flags-2

 PASS: ld-scripts/section-match-1

-FAIL: weak undefined data symbols
-FAIL: weak undefined function symbols in shared lib
+PASS: weak undefined data symbols
+PASS: weak undefined function symbols in shared lib
+PASS: weak undefined function symbols in dynamic exe

For example in the eh-group.o test, we have without the addition:

./ld-new   -o tmpdir/eh-group -e _start tmpdir/eh-group.o
Executing on host: sh -c {./ld-new   -o tmpdir/eh-group -e _start tmpdir/eh-group.o 2>&1}  /dev/null ld.tmp (timeout = 300)
spawn [open ...]
/home/dave/gnu/binutils/objdir64/ld/ld-new: cannot find milli.a: No such file or directory
/home/dave/gnu/binutils/objdir64/ld/ld-new: cannot find milli.a: No such file or directory

FAIL: Link eh-group.o to eh-group

That's why I added the above addition.

The change didn't affect the test results for alpha-vms on x86_64-pc-linux-gnu.

Dave
  
Maciej W. Rozycki April 19, 2026, 9:49 p.m. UTC | #3
On Wed, 15 Apr 2026, John David Anglin wrote:

> > hppa64-hp-hpux11.23  +FAIL: ld-elf/pr30791b
> 
> Note I said "Fixes all fails due to missing milli.a archive".  There are
> about 23 fails on x86_64-pc-linux-gnu for the hppa64-hpux target which I
> haven't had time to investigate.  There are more fails on hpux.  I see about
> 59 ld fails on alpha-vms.

 No worries, just double-checking new failures between the test runs.  
I'm not concerned about existing regressions except for targets I look 
after myself (i.e. MIPS stuff).

> I believe this fail is caused by the following:
> 
> static void
> hppa64elf_after_parse (void)
> {
>   /* Stop the linker merging .text sections on relocatable links.  */
>   if (bfd_link_relocatable (&link_info))
>     lang_add_unique (".text");
> 
> This was done in preparation for improved stub support for long branches.
> The above was taken from the 32-bit hppaelf.em file.  Maybe there is a better
> way?

 No idea offhand.

 Overall I'd expect the linker to precisely follow the linker script used, 
possibly one supplied by the user, and if merging .text sections is not 
expected for incremental links, then perhaps the default script used for 
such links ought to instruct the linker to keep .text sections intact?  

 ISTM we might be missing the linker script syntax required to achieve the 
effect though, possibly a UNIQUE (and, for completeness, NOUNIQUE) output 
section keyword.

> The pr30791b.d file has:
> #source: pr30791c.s
> #source: pr30791d.s
> #ld: -r
> #readelf: -S --wide
> #xfail: hppa-*-* z80-*-*
> # hppa fails since .text sections aren't merged for relocatable link.
> 
> The xfail isn't correct, and doesn't handle hppa64 or other 32-bit target
> names (e.g., hppa2.0).

 As it stands I agree.

> > hppa64-hp-hpux11.23  +FAIL: relocatable with script
> 
> This fails for the same reason.  The relocatable.d has:
> #name: relocatable with script
> #source: simple.s
> #ld: -r -T relocatable.t
> #readelf: -S --wide
> #xfail: hppa-*-* hppa[12]*-*-*

 Ditto.

> >> 	* 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.
> > 
> >  Hmm, I think it would be safer long-term (even if nothing breaks right 
> > away) if our dummy `milli.a' library lived on its own in a separate 
> > directory such as `tmpdir/milli' that isn't expected to be ever used by 
> > any tests, in particular generic ones.  This way adding " -Ltmpdir/milli" 
> > won't interfere with tests that want or don't want to have `tmpdir' in the 
> > library search path for some reason.
> 
> Will adjust change.  Maybe it's better to use "hppa" instead of "milli"
> for the directory name?  That would work better on alpha.  I don't know
> the names of the libraries that are always linked against on alpha-vms.

 No preference here, please pick whatever suits you best.  AFAICT it's 
`-limagelib -lstarlet -lsys$public_vectors' on `alpha*-*-*vms*'.

> >> 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"
> > 
> >  Why is this addition required for `hppa*64-*-hpux*' while not for 
> > `alpha*-*-*vms*'?
> 
> This addition fixes the following tests for hppa64-hp-hpux11.11 on x86_64-pc-linux-gnu:
> 
> -FAIL: Link eh-group.o to eh-group
> +PASS: Link eh-group.o to eh-group

 Hmm, that describes the effect of the change, but does not really answer 
my question.

 I went ahead and dug into it and the actual answer is: the ultimate cause 
is some tests use low-level `ld_link' rather than `run_ld_link_tests', and 
the former procedure fails to take $LDFLAGS into account.  And evidently 
no test that makes direct use of `ld_link' is run for `alpha*-*-*vms*'.

 So this is clearly a preexisting issue, the fix for which I think should 
go in first, by combining your proposed change to `default_ld_link' (but 
please write it as `append flags " $LDFLAGS"' and separate it with a new 
line) with the removal of references to LDFLAGS from `run_ld_link_tests'.

  Maciej
  

Patch

diff --git a/binutils/testsuite/config/default.exp b/binutils/testsuite/config/default.exp
index 25bd1e64222..4a8ee3ddce9 100644
--- a/binutils/testsuite/config/default.exp
+++ b/binutils/testsuite/config/default.exp
@@ -120,6 +120,29 @@  proc link_or_copy { src dst } {
     catch "exec cp -fpu ../$src tmpdir/gas/$dst" status
 }
 
+if { [istarget hppa*64-*-hpux*] } {
+    set src tmpdir/empty.s
+    set f [open $src "w"]
+    close $f
+    if [is_remote host] {
+        set src [remote_download host $src]
+    }
+    remote_exec host "$AS -o tmpdir/empty.o $src"
+    set cmd "$LD -o tmpdir/empty tmpdir/empty.o"
+    set exec_output [remote_exec host $cmd]
+    if { [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"
+	    remote_exec host "$AR rc $f tmpdir/empty.o"
+	}
+	append LDFLAGS " -Ltmpdir"
+	unset i missing_libs
+    }
+    unset exec_output 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