[PATCH] lto: testsuite: Fix incr-link tests on wrapped targets

Lewis Hyatt <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
Hello-

This patch was discussed here:
https://gcc.gnu.org/pipermail/gcc-patches/2026-August/726564.html

I thought I should resend it since it was buried in that thread.

It was tested by me on x86-64 (with and without a target board enabling the
test glue wrapper), and by Torbjörn on arm-none-eabi where the issue was
first noticed. Is it OK please? Thanks!

-Lewis

-- >8 --

For targets that use a gluefile wrapper object, the extra object should not
be included in the link for the new LTO incr-link mode.

gcc/testsuite/ChangeLog:

	* lib/lto.exp (lto-link-and-maybe-run): Unset gluefile for the
	incremental link step, since the wrapper is not needed there and
	does not contain LTO sections.
---
 gcc/testsuite/lib/lto.exp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/lto.exp b/gcc/testsuite/lib/lto.exp
index 7243547a52d..a6532e22076 100644
--- a/gcc/testsuite/lib/lto.exp
+++ b/gcc/testsuite/lib/lto.exp
@@ -375,6 +375,7 @@ proc lto-link-and-maybe-run { testname objlist dest optall optfile optstr } {
     global tool
     global compile_type
     global board_info
+    global gluefile
 
     upvar dg-messages-by-file dg-messages-by-file
 
@@ -408,16 +409,28 @@ proc lto-link-and-maybe-run { testname objlist dest optall optfile optstr } {
 	set board_info($target_board,ldscript) ""
     }
 
+    set is_incr_link [string equal "incr-link" $optstr]
+    if { $is_incr_link && [info exists gluefile] } {
+	set sav_gluefile $gluefile
+	# Setting gluefile to an empty string arranges that we still pass the needed
+	# -wrap flags to the linker, but we don't include the object file.
+	set gluefile ""
+    }
+
     # Link the objects into an executable.
     set comp_output [${tool}_target_compile "$objlist" $dest executable \
 		     "$options"]
 
+    if { [info exists sav_gluefile] } {
+	set gluefile $sav_gluefile
+    }
+
     if { $relocatable } {
 	set board_info($target_board,ldscript) $saved_ldscript
     }
 
     # Check for diagnostics specified by directives
-    if { ! [string equal "incr-link" $optstr] } {
+    if { ! $is_incr_link } {
 	set comp_output [lto_handle_diagnostics $comp_output $optstr]
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.