I often find it useful to run "make -k check" on a cross-compiler even
without a supporting toolchain to perform compile-only testing.
This works for the gcc and gfortran testsuites, but I'm currently
seeing no results reported for g++ due to:

Running /home/roger/GCC/combined/gcc/testsuite/g++.dg/analyzer/analyzer.exp
...
sh:
/home/roger/GCC/buildas2/arc-linux/./libstdc++-v3/scripts/testsuite_flags: N
o such file or directory
    while executing
"exec sh ${odir}/scripts/testsuite_flags --build-includes"
    (procedure "g++_include_flags" line 16)
    invoked from within
"g++_include_flags [get_multilibs] "
...

This patch adds a defensive test to lib/g++.exp to check for the
existence of a (script) file before attempting to execute it.
The real issue may be figuring out why scripts/testsuite_flags isn't
being created, but there's no harm in (also) confirming that it
exists in g++_include_flags.

This patch has been tested on x86_64-pc-linux-gnu (where it allows
a cross-compiler to arc-linux to produce g++ compilation results).
Ok for mainline?


2024-07-22  Roger Sayle  <ro...@nextmovesoftware.com>

gcc/testsuite/ChangeLog
        * lib/g++.exp (g++_include_flags): Check that the testsuite_flags
        script exists before executing it.


Thanks in advance,
Roger
--

diff --git a/gcc/testsuite/lib/g++.exp b/gcc/testsuite/lib/g++.exp
index a6b34d5d3a2..ef68879dbb4 100644
--- a/gcc/testsuite/lib/g++.exp
+++ b/gcc/testsuite/lib/g++.exp
@@ -93,7 +93,9 @@ proc g++_include_flags { paths } {
 
     set odir [lookfor_file ${gccpath} libstdc++-v3]
     if { ${odir} != "" } {
-      append flags [exec sh ${odir}/scripts/testsuite_flags --build-includes]  
+      if [file exists "${odir}/scripts/testsuite_flags"] {
+        append flags [exec sh ${odir}/scripts/testsuite_flags 
--build-includes]  
+      }
     }
 
     return "$flags"

Reply via email to