https://gcc.gnu.org/g:c12a31fe1ae7f05af3880a6c9f28fee532fe36b5
commit r16-8497-gc12a31fe1ae7f05af3880a6c9f28fee532fe36b5 Author: Torbjörn SVENSSON <[email protected]> Date: Tue Apr 7 10:40:06 2026 +0200 testsuite: cache various python3 effective target checks There is no need to check the version of python multiple times in a single run. Cache the result and avoid the extra tool invocation. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_recent_python3): Cache result of check. (check_effective_target_python3_module): Likewise. (check_effective_target_pytest3): Likewise. Signed-off-by: Torbjörn SVENSSON <[email protected]> Diff: --- gcc/testsuite/lib/target-supports.exp | 48 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 4e2ef968c4e6..1316254a06a9 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -14334,37 +14334,43 @@ proc check_effective_target___OPTIMIZE__ {} { # Return 1 if python3 (>= 3.6) is available. proc check_effective_target_recent_python3 { } { - set result [remote_exec host "python3 -c \"import sys; assert sys.version_info >= (3, 6)\""] - set status [lindex $result 0] - if { $status == 0 } then { - return 1; - } else { - return 0; - } + return [check_cached_effective_target recent_python3 { + set result [remote_exec host "python3 -c \"import sys; assert sys.version_info >= (3, 6)\""] + set status [lindex $result 0] + if { $status == 0 } then { + return 1; + } else { + return 0; + } + }] } # Return 1 if python3 contains a module proc check_effective_target_python3_module { module } { - set result [remote_exec host "python3 -c \"import $module\""] - set status [lindex $result 0] - if { $status == 0 } then { - return 1; - } else { - return 0; - } + return [check_cached_effective_target python3_module_$module { + set result [remote_exec host "python3 -c \"import $module\""] + set status [lindex $result 0] + if { $status == 0 } then { + return 1; + } else { + return 0; + } + }] } # Return 1 if pytest module is available for python3. proc check_effective_target_pytest3 { } { - set result [remote_exec host "python3 -m pytest --color=no -rap -s --tb=no --version"] - set status [lindex $result 0] - if { $status == 0 } then { - return 1; - } else { - return 0; - } + return [check_cached_effective_target pytest3 { + set result [remote_exec host "python3 -m pytest --color=no -rap -s --tb=no --version"] + set status [lindex $result 0] + if { $status == 0 } then { + return 1; + } else { + return 0; + } + }] } proc check_effective_target_property_1_needed { } {
