[gcc r17-3275] lto: testsuite: Fix incr-link tests on wrapped targets

Lewis Hyatt via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:1b9420378621b9b882243f4ccb8c2f8fdd8c979b

commit r17-3275-g1b9420378621b9b882243f4ccb8c2f8fdd8c979b
Author: Lewis Hyatt <[email protected]>
Date:   Thu Aug 13 21:43:19 2026 -0400

    lto: testsuite: Fix incr-link tests on wrapped targets
    
    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.

Diff:
---
 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 7243547a52d8..a6532e220760 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.