[PATCH v2] libstdc++: fix testing with uninstalled compilers, redux

Arsen Arsenović aarsenovic@baylibre.com
Sat Jul 25 22:14:54 GMT 2026


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. Remove
	local copy of parallelization logic.
	(libstdc++_init): Use gcc-set-multilib-library-path to calculate
	LD_LIBRARY_PATH for installed G++ compilers.
---
No changes in libstdc++ testsuite with this applied.

The command:

  sort normal*/libstdc++.sum.sep | uniq -c | awk '$1 != 1'

... produces the results listed below.  These were also there before,
AFAICT (same command produces the "same" output when applied to the old
.sep files; I say "same" because obviously they differ in timestamps and
such).

Tested on x86_64-linux-gnu.  OK for trunk?

      2 PASS: 18_support/launder/requirements_neg.cc  -std=gnu++20  (test for errors, line )
      6 PASS: 20_util/any/misc/any_cast_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/bind/dangling_ref.cc  -std=gnu++20  (test for errors, line )
      5 PASS: 20_util/expected/illformed_neg.cc  -std=gnu++23  (test for errors, line )
      5 PASS: 20_util/expected/illformed_neg.cc  -std=gnu++29  (test for errors, line )
      2 PASS: 20_util/forward_like/2_neg.cc  -std=gnu++23  (test for errors, line )
      2 PASS: 20_util/forward_like/2_neg.cc  -std=gnu++29  (test for errors, line )
      3 PASS: 20_util/function_objects/121782.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/function_objects/bind_back/111327.cc  -std=gnu++23  (test for errors, line )
      2 PASS: 20_util/function_objects/bind_back/111327.cc  -std=gnu++29  (test for errors, line )
      2 PASS: 20_util/function_objects/bind_back/nttp_neg.cc  -std=gnu++26  (test for errors, line )
      2 PASS: 20_util/function_objects/bind_back/nttp_neg.cc  -std=gnu++29  (test for errors, line )
      2 PASS: 20_util/function_objects/bind_front/nttp_neg.cc  -std=gnu++26  (test for errors, line )
      2 PASS: 20_util/function_objects/bind_front/nttp_neg.cc  -std=gnu++29  (test for errors, line )
      4 PASS: 20_util/function_objects/not_fn/111327.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 20_util/integer_sequence/tuple_access_neg.cc  -std=gnu++26  (test for errors, line )
      3 PASS: 20_util/integer_sequence/tuple_access_neg.cc  -std=gnu++29  (test for errors, line )
      3 PASS: 20_util/ratio/cons/cons_overflow_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 20_util/ratio/operations/ops_overflow_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/ratio/operations/ops_overflow_neg.cc  -std=gnu++20  (test for errors, line 28)
      2 PASS: 20_util/scoped_allocator/69293_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/specialized_algorithms/memory_management_tools/destroy_n_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/unique_ptr/cons/deduction_neg.cc  -std=gnu++20  (test for errors, line 28)
      2 PASS: 20_util/unique_ptr/cons/deduction_neg.cc  -std=gnu++20  (test for errors, line 31)
      2 PASS: 20_util/uses_allocator/69293_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/uses_allocator/cons_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 20_util/variant/types_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/array/cons/deduction_neg.cc  -std=gnu++20  (test for errors, line 25)
      2 PASS: 23_containers/array/cons/deduction_neg.cc  -std=gnu++20  (test for errors, line 26)
      3 PASS: 23_containers/map/48101_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 23_containers/multimap/48101_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/multiset/48101_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/set/48101_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/unordered_map/48101_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/unordered_multimap/48101_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 23_containers/unordered_multiset/48101_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 23_containers/unordered_set/48101_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/vector/cons/89164.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/vector/cons/destructible_debug_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 23_containers/vector/cons/destructible_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 24_iterators/range_access/range_access_cpp20_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 24_iterators/range_generators/lwg3900.cc  -std=gnu++23  (test for errors, line )
      3 PASS: 24_iterators/range_generators/lwg3900.cc  -std=gnu++29  (test for errors, line )
      2 PASS: 26_numerics/gcd/gcd_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 26_numerics/lcm/105844.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 26_numerics/lcm/lcm_neg.cc  -std=gnu++20  (test for errors, line )
      4 PASS: 27_io/ios_base/types/fmtflags/bitmask_operators.cc  -std=gnu++20  (test for warnings, line )
      4 PASS: 27_io/ios_base/types/iostate/bitmask_operators.cc  -std=gnu++20  (test for warnings, line )
      4 PASS: 27_io/ios_base/types/openmode/bitmask_operators.cc  -std=gnu++20  (test for warnings, line )
      3 PASS: 29_atomics/atomic/requirements/types_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 30_threads/future/requirements/lwg3458.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 30_threads/packaged_task/cons/dangling_ref.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 30_threads/packaged_task/cons/lwg4154_neg.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 30_threads/promise/requirements/lwg3466.cc  -std=gnu++20  (test for errors, line )
      3 PASS: 30_threads/shared_future/requirements/lwg3458.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 30_threads/stop_token/stop_callback/destructible_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: 30_threads/stop_token/stop_callback/invocable_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: ext/verify_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: std/format/arguments/args_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: std/format/string_neg.cc  -std=gnu++20  (test for errors, line )
      2 PASS: std/ranges/subrange/lwg3282_neg.cc  -std=gnu++20  (test for errors, line 37)
      2 PASS: std/ranges/subrange/lwg3282_neg.cc  -std=gnu++20  (test for errors, line 39)
      3 PASS: tr1/2_general_utilities/shared_ptr/assign/shared_ptr_neg.cc  -std=gnu++20  (test for errors, line )


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



More information about the Libstdc++ mailing list