[gcc r17-2760] libstdc++: fix testing with uninstalled compilers, redux

Arsen Arsenovic via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <20260728175310.4B4DA4BB3BA9__26758.6610558041$1785261199$gmane$org@sourceware.org>
https://gcc.gnu.org/g:0531c407b983f322ade13feef6966b3593b8b989

commit r17-2760-g0531c407b983f322ade13feef6966b3593b8b989
Author: Arsen Arsenović <[email protected]>
Date:   Thu Jul 23 23:25:56 2026 +0200

    libstdc++: fix testing with uninstalled compilers, redux
    
    In r17-2449-g7f2bba0d2d0821 I attempted to make this change, but
    accidentally broke the testsuite parallelization logic.
    
    This happened because gcc-defs and libstdc++ both did:
    
      rename runtest_file_p gcc_parallelize_saved_runtest_file_p
    
    ... in order to replace runtest_file_p with a version that returns true
    if the test, besides the usual check, also falls into the partition a
    given parallelized runtest instance executes.
    
    This meant that each call to runtest_file_p was incrementing the
    partition counter twice (because it called gcc_parallel_test_run_p
    twice; once through gcc_parallelize_saved_runtest_file_p - which now
    became the gcc-defs copy of the replaced runtest_file_p - and once
    directly).
    
    The copy of this logic in libstdc++ is supposed to be identical (and
    indeed was up to an accidental divergence as a result of copy-pastery)
    to the one in gcc-defs, so we simply remove the former.
    
    gcc-defs also defines other things that have parallels in the libstdc++
    testsuite logic.  To avoid clobbering the libstdc++ definitions, I've
    moved the load_libs that loaded them later.
    
    This seems to have been the intention (a comment above the load_lib
    block states "compiler routines, then ours") at some point.
    
    It may be worth looking into this again to see whether we can
    deduplicate more code.  But, when I looked at it, the logic seemed
    distinct enough not to risk removing it for now.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/lib/libstdc++.exp: Load gcc-defs.exp.  Load
            prune.exp and dg-options.exp after GCC testsuite libs.
            (libstdc++_init): Use gcc-set-multilib-library-path to calculate
            LD_LIBRARY_PATH for installed G++ compilers.

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 91 ++++----------------------------
 1 file changed, 9 insertions(+), 82 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index b44c240fa526..cda231246cb0 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -65,8 +65,6 @@ load_lib libgloss.exp
 # compiler routines, then ours
 load_gcc_lib target-supports.exp
 load_gcc_lib target-supports-dg.exp
-load_lib prune.exp
-load_lib dg-options.exp
 load_gcc_lib scanasm.exp
 load_gcc_lib scandump.exp
 load_gcc_lib scantree.exp
@@ -75,7 +73,10 @@ load_gcc_lib timeout.exp
 load_gcc_lib timeout-dg.exp
 load_gcc_lib wrapper.exp
 load_gcc_lib target-utils.exp
+load_gcc_lib gcc-defs.exp
 load_gcc_lib dg-test-cleanup.exp
+load_lib prune.exp
+load_lib dg-options.exp
 
 # Useful for debugging.  Pass the name of a variable and the verbosity
 # threshold (number of -v's on the command line).
@@ -247,13 +248,14 @@ proc libstdc++_init { testfile } {
 	    }
 	  }
 	}
-
-	set_ld_library_path_env_vars
-	if [info exists env(LD_LIBRARY_PATH)] {
-	  verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
-	}
     } else {
 	set compiler [transform "g++"]
+	append ld_library_path [gcc-set-multilib-library-path $compiler]
+    }
+
+    set_ld_library_path_env_vars
+    if [info exists env(LD_LIBRARY_PATH)] {
+	verbose -log "LD_LIBRARY_PATH = $env(LD_LIBRARY_PATH)"
     }
 
     # Set the default timeout for v3 tests.
@@ -1641,81 +1643,6 @@ proc check_effective_target_tzdb { } {
 
 set additional_prunes ""
 
-if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
-     && [info procs runtest_file_p] != [list] \
-     && [info procs gcc_parallelize_saved_runtest_file_p] == [list] } then {
-    global gcc_runtest_parallelize_counter
-    global gcc_runtest_parallelize_counter_minor
-    global gcc_runtest_parallelize_enable
-    global gcc_runtest_parallelize_dir
-    global gcc_runtest_parallelize_last
-
-    set gcc_runtest_parallelize_counter 0
-    set gcc_runtest_parallelize_counter_minor 0
-    set gcc_runtest_parallelize_enable 1
-    set gcc_runtest_parallelize_dir [getenv GCC_RUNTEST_PARALLELIZE_DIR]
-    set gcc_runtest_parallelize_last 0
-
-    proc gcc_parallel_test_run_p { testcase } {
-	global gcc_runtest_parallelize_counter
-	global gcc_runtest_parallelize_counter_minor
-	global gcc_runtest_parallelize_enable
-	global gcc_runtest_parallelize_dir
-	global gcc_runtest_parallelize_last
-
-	if { $gcc_runtest_parallelize_enable == 0 } {
-	    return 1
-	}
-
-	# Only test the filesystem every 10th iteration
-	incr gcc_runtest_parallelize_counter_minor
-	if { $gcc_runtest_parallelize_counter_minor == 10 } {
-	    set gcc_runtest_parallelize_counter_minor 0
-	}
-	if { $gcc_runtest_parallelize_counter_minor != 1 } {
-	    #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter $gcc_runtest_parallelize_last"
-	    return $gcc_runtest_parallelize_last
-	}
-
-	set path $gcc_runtest_parallelize_dir/$gcc_runtest_parallelize_counter
-
-	if {![catch {open $path {RDWR CREAT EXCL} 0600} fd]} {
-	    close $fd
-	    set gcc_runtest_parallelize_last 1
-	    #verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 1"
-	    incr gcc_runtest_parallelize_counter
-	    return 1
-	}
-	set gcc_runtest_parallelize_last 0
-	#verbose -log "gcc_parallel_test_run_p $testcase $gcc_runtest_parallelize_counter 0"
-	incr gcc_runtest_parallelize_counter
-	return 0
-    }
-
-    proc gcc_parallel_test_enable { val } {
-	global gcc_runtest_parallelize_enable
-	set gcc_runtest_parallelize_enable $val
-    }
-
-    rename runtest_file_p gcc_parallelize_saved_runtest_file_p
-    proc runtest_file_p { runtests testcase } {
-	if ![gcc_parallelize_saved_runtest_file_p $runtests $testcase] {
-	    return 0
-	}
-	return [gcc_parallel_test_run_p $testcase]
-    }
-
-} else {
-
-    proc gcc_parallel_test_run_p { testcase } {
-	return 1
-    }
-
-    proc gcc_parallel_test_enable { val } {
-    }
-
-}
-
 # Utility functions, invoked via dg-final.
 
 # Compare output file written by test to expected result.
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.