public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgomp testsuite: (not) using a specific driver for C++, Fortran?
@ 2014-10-15 15:52 Thomas Schwinge
  2014-11-04 12:14 ` Thomas Schwinge
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2014-10-15 15:52 UTC (permalink / raw)
  To: Jakub Jelinek, Richard Henderson, gcc-patches
  Cc: Rainer Orth, Mike Stump, Janis Johnson

[-- Attachment #1: Type: text/plain, Size: 4575 bytes --]

Hi!

No matter whether it's C, C++, or Fortran source code, the libgomp
testsuite always uses (for build-tree testing) gcc/xgcc, or (for
installed testing) GCC_UNDER_TEST.  It doesn't make use of
GXX_UNDER_TEST, GFORTRAN_UNDER_TEST.  To support the latter two
languages' needs, some -l[...] flags are then added via lang_link_flags.
For example, for Fortran this is -lgfortran.  This is, however, not what
would happen if using the gfortran driver to build (which is what a user
would be doing -- which we should replicate as much as possible at least
for installed testing): the gfortran driver also adds -lquadmath, if
applicable.

Now, I wonder why to re-invent all that in the libgomp testsuite, if the
respective driver already has that knowledge, via spec files, for
example?  (Also, the regular GCC compiler tests, gcc/testsuite/, are
doing the right thing.)  Why is libgomp testsuite implemented this way --
just a legacy of the past, or is there a need for that (that I'm not
seeing)?

Maybe the question also is: why isn't the libgomp testsuite using more of
the infrastructure for specific languages, that is already implemented in
gcc/testsuite/lib/?  (That is, why does libgomp have to use
libgomp_target_compile, instead of [language]_target_compile, for
example.)

And maybe that problem also applied to additional target libraries'
testsuites; I have not yet looked.

Anyway, here is a prototype patch to describe how I began to address this
for the issue I stumbled upon, which is that the linker complained:

    Executing on host: x86_64-none-linux-gnu-gcc [...]/libgomp/testsuite/libgomp.fortran/aligned1.f03 [...] -fopenmp   -O0  -fopenmp -fcray-pointer   -lgfortran -lm   -o ./aligned1.exe    (timeout = 300)
    [...]/ld: warning: libquadmath.so.0, needed by [...]/libgfortran.so, not found (try using -rpath or -rpath-link)
    [...]/libgfortran.so: undefined reference to `logq@QUADMATH_1.0'
    [...]

(That goes away if I add -lquadmath to the command line, but that's not
the point I'm making here.)

Am I on the right track with the following?

--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -210,7 +210,6 @@ proc libgomp_target_compile { source dest type options } {
 
     lappend options "additional_flags=[libio_include_flags]"
     lappend options "timeout=[timeout_value]"
-    lappend options "compiler=$GCC_UNDER_TEST"
 
     set options [concat $libgomp_compile_options $options]
 
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -4,6 +4,7 @@ load_gcc_lib gcc-dg.exp
 global shlib_ext
 
 set shlib_ext [get_shlib_extension]
+#TODO
 set lang_link_flags "-lstdc++"
 set lang_test_file_found 0
 set lang_library_path "../libstdc++-v3/src/.libs"
@@ -41,6 +42,11 @@ if { $blddir != "" } {
 }
 
 if { $lang_test_file_found } {
+    if ![info exists GXX_UNDER_TEST] then {
+	set GXX_UNDER_TEST $GCC_UNDER_TEST
+    }
+    lappend libgomp_compile_options "compiler=$GXX_UNDER_TEST"
+
     # Gather a list of all tests.
     set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
 
--- libgomp/testsuite/libgomp.c/c.exp
+++ libgomp/testsuite/libgomp.c/c.exp
@@ -23,6 +23,8 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
 # Gather a list of all tests.
 set tests [lsort [find $srcdir/$subdir *.c]]
 
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -7,6 +7,7 @@ global ALWAYS_CFLAGS
 
 set shlib_ext [get_shlib_extension]
 set lang_library_path	"../libgfortran/.libs"
+#TODO
 set lang_link_flags	"-lgfortran"
 if [info exists lang_include_flags] then {
     unset lang_include_flags
@@ -44,6 +45,11 @@ if { $blddir != "" } {
 }
 
 if { $lang_test_file_found } {
+    if ![info exists GFORTRAN_UNDER_TEST] then {
+	set GFORTRAN_UNDER_TEST $GCC_UNDER_TEST
+    }
+    lappend libgomp_compile_options "compiler=$GFORTRAN_UNDER_TEST"
+
     # Gather a list of all tests.
     set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
--- libgomp/testsuite/libgomp.graphite/graphite.exp
+++ libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -48,6 +48,8 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
 # Gather a list of all tests.
 set tests [lsort [find $srcdir/$subdir *.c]]
 


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: libgomp testsuite: (not) using a specific driver for C++, Fortran?
  2014-10-15 15:52 libgomp testsuite: (not) using a specific driver for C++, Fortran? Thomas Schwinge
@ 2014-11-04 12:14 ` Thomas Schwinge
  2014-11-04 18:32   ` Mike Stump
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2014-11-04 12:14 UTC (permalink / raw)
  To: Jakub Jelinek, Richard Henderson, gcc-patches
  Cc: Rainer Orth, Mike Stump, Janis Johnson

[-- Attachment #1: Type: text/plain, Size: 41522 bytes --]

Hi!

On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
> No matter whether it's C, C++, or Fortran source code, the libgomp
> testsuite always uses (for build-tree testing) gcc/xgcc, or (for
> installed testing) GCC_UNDER_TEST.  It doesn't make use of
> GXX_UNDER_TEST, GFORTRAN_UNDER_TEST.  To support the latter two
> languages' needs, some -l[...] flags are then added via lang_link_flags.
> For example, for Fortran this is -lgfortran.  This is, however, not what
> would happen if using the gfortran driver to build (which is what a user
> would be doing -- which we should replicate as much as possible at least
> for installed testing): the gfortran driver also adds -lquadmath, if
> applicable.
> 
> Now, I wonder why to re-invent all that in the libgomp testsuite, if the
> respective driver already has that knowledge, via spec files, for
> example?  (Also, the regular GCC compiler tests, gcc/testsuite/, are
> doing the right thing.)  Why is libgomp testsuite implemented this way --
> just a legacy of the past, or is there a need for that (that I'm not
> seeing)?
> 
> Maybe the question also is: why isn't the libgomp testsuite using more of
> the infrastructure for specific languages, that is already implemented in
> gcc/testsuite/lib/?  (That is, why does libgomp have to use
> libgomp_target_compile, instead of [language]_target_compile, for
> example.)

(I decided not to look into that latter idea, at the moment.)

> And maybe that problem also applied to additional target libraries'
> testsuites; I have not yet looked.

(It does, but I'm not addressing that with the following patches.)

> Anyway, here is a prototype patch to describe how I began to address this
> for the issue I stumbled upon, which is that the linker complained:
> 
>     Executing on host: x86_64-none-linux-gnu-gcc [...]/libgomp/testsuite/libgomp.fortran/aligned1.f03 [...] -fopenmp   -O0  -fopenmp -fcray-pointer   -lgfortran -lm   -o ./aligned1.exe    (timeout = 300)
>     [...]/ld: warning: libquadmath.so.0, needed by [...]/libgfortran.so, not found (try using -rpath or -rpath-link)
>     [...]/libgfortran.so: undefined reference to `logq@QUADMATH_1.0'
>     [...]
> 
> (That goes away if I add -lquadmath to the command line, but that's not
> the point I'm making here.)
> 
> Am I on the right track with the following?

Nobody commented, which also means nobody disagreed -- so, here are first
a bunch of cleanup patches, refactoring, and then a patch to enable usage
of GXX_UNDER_TEST, GFORTRAN_UNDER_TEST for installed testing.  OK to
commit all that to trunk?  I tested (that is, diffed the libgomp.log
file) each step incrementally, both in non-installed and in installed
testing scenarios.

commit 6229e75038b47a09638454a812fb9eff5f31d761
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Mon Nov 3 09:58:38 2014 +0100

    libgomp testsuite: Only use blddir if set.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_init): Only use blddir if
    	set.
    	* testsuite/libgomp.c++/c++.exp: Likewise.
    
    (It is unclear to me why the current working directory needs to be in
    LD_LIBRARY_PATH.)
---
 libgomp/testsuite/lib/libgomp.exp     | 5 +++--
 libgomp/testsuite/libgomp.c++/c++.exp | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 094e5ed..4234d4f 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -53,7 +53,6 @@ proc libgomp_init { args } {
     global srcdir blddir objdir tool_root_dir
     global libgomp_initialized
     global tmpdir
-    global blddir
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global CFLAGS
@@ -105,7 +104,7 @@ proc libgomp_init { args } {
     }
 
     # Compute what needs to be put into LD_LIBRARY_PATH
-    set always_ld_library_path ".:${blddir}/.libs"
+    set always_ld_library_path "."
 
     # Compute what needs to be added to the existing LD_LIBRARY_PATH.
     if {$gccdir != ""} {
@@ -139,6 +138,8 @@ proc libgomp_init { args } {
         lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
         lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
         lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
+
+	append always_ld_library_path ":${blddir}/.libs"
     }
     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
 
diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index a9cf41a..c2288c8 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -53,7 +53,8 @@ if { $lang_test_file_found } {
     set_ld_library_path_env_vars
 
     set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-    if { [file exists $flags_file] } {
+    if { $blddir != "" \
+	 && [file exists $flags_file] } {
 	set libstdcxx_includes [exec sh $flags_file --build-includes]
     } else {
 	set libstdcxx_includes ""

commit 6d8f949c98e04966e6757c80094a63ce5eb2b334
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Fri Oct 31 16:49:14 2014 +0100

    libgomp testsuite: Don't compute blddir twice in C++ testing.
    
    	libgomp/
    	* testsuite/libgomp.c++/c++.exp (blddir): Don't set.
    
    It has already been set in lib/libgomp.exp:libgomp_init.
---
 libgomp/testsuite/libgomp.c++/c++.exp | 3 ---
 1 file changed, 3 deletions(-)

diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index c2288c8..b04fd2d 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -17,9 +17,6 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
-set blddir [lookfor_file [get_multilibs] libgomp]
-
-
 if { $blddir != "" } {
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {

commit 0e6586e5e965461d24203e745c1db5c6f99b8252
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Fri Oct 31 17:38:03 2014 +0100

    libgomp testsuite: Use lang_test_file_found instead of lang_test_file.
    
    	libgomp/
    	* testsuite/libgomp.c++/c++.exp: Don't set lang_test_file.
    	* testsuite/libgomp.fortran/fortran.exp: Likewise.
    	* testsuite/libgomp.c/c.exp: Unset lang_test_file_found instead of
    	lang_test_file.
    	* testsuite/libgomp.graphite/graphite.exp: Likewise.
    	* testsuite/lib/libgomp.exp (libgomp_target_compile): Look for
    	lang_test_file_found instead of lang_test_file.
---
 libgomp/testsuite/lib/libgomp.exp               | 4 ++--
 libgomp/testsuite/libgomp.c++/c++.exp           | 4 ----
 libgomp/testsuite/libgomp.c/c.exp               | 4 ++--
 libgomp/testsuite/libgomp.fortran/fortran.exp   | 4 ----
 libgomp/testsuite/libgomp.graphite/graphite.exp | 4 ++--
 5 files changed, 6 insertions(+), 14 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 4234d4f..4864db3 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -182,13 +182,13 @@ proc libgomp_target_compile { source dest type options } {
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global GCC_UNDER_TEST
-    global lang_test_file
+    global lang_test_file_found
     global lang_library_path
     global lang_link_flags
     global lang_include_flags
     global lang_source_re
 
-    if { [info exists lang_test_file] } {
+    if { [info exists lang_test_file_found] } {
         if { $blddir != "" } {
             # Some targets use libgfortran.a%s in their specs, so they need
             # a -B option for uninstalled testing.
diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index b04fd2d..f0efb04 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -20,19 +20,15 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 if { $blddir != "" } {
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file "${lang_library_path}/libstdc++.a"
         set lang_test_file_found 1
         # We may have a shared only build, so look for a shared libstdc++.
     } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}"
         set lang_test_file_found 1
     } else {
         puts "No libstdc++ library found, will not execute c++ tests"
     }
 } elseif { [info exists GXX_UNDER_TEST] } {
     set lang_test_file_found 1
-    # Needs to exist for libgomp.exp.
-    set lang_test_file ""
 } else {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
 }
diff --git libgomp/testsuite/libgomp.c/c.exp libgomp/testsuite/libgomp.c/c.exp
index 300b921..e7f9e85 100644
--- libgomp/testsuite/libgomp.c/c.exp
+++ libgomp/testsuite/libgomp.c/c.exp
@@ -2,8 +2,8 @@ if [info exists lang_library_path] then {
     unset lang_library_path
     unset lang_link_flags
 }
-if [info exists lang_test_file] then {
-    unset lang_test_file
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
 }
 if [info exists lang_include_flags] then {
     unset lang_include_flags
diff --git libgomp/testsuite/libgomp.fortran/fortran.exp libgomp/testsuite/libgomp.fortran/fortran.exp
index 9e6b643..18a151e 100644
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -26,19 +26,15 @@ if { $blddir != "" } {
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
     # Look for a static libgfortran first.
     if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file "${lang_library_path}/libgfortran.a"
         set lang_test_file_found 1
 	# We may have a shared only build, so look for a shared libgfortran.
     } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}"
         set lang_test_file_found 1
     } else {
         puts "No libgfortran library found, will not execute fortran tests"
     }
 } elseif [info exists GFORTRAN_UNDER_TEST] {
     set lang_test_file_found 1
-    # Needs to exist for libgomp.exp.
-    set lang_test_file ""
 } else {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
 }
diff --git libgomp/testsuite/libgomp.graphite/graphite.exp libgomp/testsuite/libgomp.graphite/graphite.exp
index 190f557..78a269b 100644
--- libgomp/testsuite/libgomp.graphite/graphite.exp
+++ libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -18,8 +18,8 @@ if [info exists lang_library_path] then {
     unset lang_library_path
     unset lang_link_flags
 }
-if [info exists lang_test_file] then {
-    unset lang_test_file
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
 }
 if [info exists lang_include_flags] then {
     unset lang_include_flags

commit 01a792a3156fdc541e349071d3dde0144b013d03
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Sat Nov 1 16:25:26 2014 +0100

    libgomp testsuite: Remove lang_test_file_found usage.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_target_compile): Don't look
    	for lang_test_file_found.
    	* testsuite/libgomp.c/c.exp: Don't unset it.
    	* testsuite/libgomp.graphite/graphite.exp: Likewise.  Move target
    	pthread and fgraphite checks after initialization.
    	* testsuite/libgomp.c++/c++.exp: Don't set and use it, and instead
    	return early if not able to test.  Simplify population of
    	ld_library_path.
    	* testsuite/libgomp.fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/lib/libgomp.exp               | 35 ++++++------
 libgomp/testsuite/libgomp.c++/c++.exp           | 63 ++++++++++------------
 libgomp/testsuite/libgomp.c/c.exp               | 15 ++----
 libgomp/testsuite/libgomp.fortran/fortran.exp   | 71 +++++++++++--------------
 libgomp/testsuite/libgomp.graphite/graphite.exp | 29 ++++------
 5 files changed, 92 insertions(+), 121 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 4864db3..27f777b 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -182,24 +182,27 @@ proc libgomp_target_compile { source dest type options } {
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global GCC_UNDER_TEST
-    global lang_test_file_found
+
+    global lang_source_re lang_include_flags
+    # Only add these flags if actually compiling a file for the respective
+    # language.  This is important, because this function is also invoked to
+    # probe for compiler features, which might be done with a front end that
+    # does not like lang_include_flags.
+    if { [info exists lang_include_flags] \
+	 && [regexp ${lang_source_re} ${source}] } {
+	lappend options "additional_flags=${lang_include_flags}"
+    }
+
     global lang_library_path
+    if { [info exists lang_library_path] } {
+	# Some targets use libgfortran.a%s in their specs, so they need
+	# a -B option for uninstalled testing.
+	lappend options "additional_flags=-B${blddir}/${lang_library_path}"
+	lappend options "ldflags=-L${blddir}/${lang_library_path}"
+    }
     global lang_link_flags
-    global lang_include_flags
-    global lang_source_re
-
-    if { [info exists lang_test_file_found] } {
-        if { $blddir != "" } {
-            # Some targets use libgfortran.a%s in their specs, so they need
-            # a -B option for uninstalled testing.
-            lappend options "additional_flags=-B${blddir}/${lang_library_path}"
-            lappend options "ldflags=-L${blddir}/${lang_library_path}"
-        }
-        lappend options "ldflags=${lang_link_flags}"
-	if { [info exists lang_include_flags] \
-	     && [regexp ${lang_source_re} ${source}] } {
-	    lappend options "additional_flags=${lang_include_flags}"
-	}
+    if { [info exists lang_link_flags] } {
+	lappend options "ldflags=${lang_link_flags}"
     }
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index f0efb04..6523c4b 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -4,12 +4,10 @@ load_gcc_lib gcc-dg.exp
 global shlib_ext
 
 set shlib_ext [get_shlib_extension]
+
+unset -nocomplain lang_include_flags
+unset -nocomplain lang_library_path
 set lang_link_flags "-lstdc++"
-set lang_test_file_found 0
-set lang_library_path "../libstdc++-v3/src/.libs"
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
 
 # Initialize dg.
 dg-init
@@ -18,44 +16,37 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 if { $blddir != "" } {
-    # Look for a static libstdc++ first.
-    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file_found 1
-        # We may have a shared only build, so look for a shared libstdc++.
-    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libstdc++ library found, will not execute c++ tests"
+    set lang_library_path "../libstdc++-v3/src/.libs"
+    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"] \
+	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+	puts "No libstdc++ library found, will not execute c++ tests"
+	return
     }
-} elseif { [info exists GXX_UNDER_TEST] } {
-    set lang_test_file_found 1
-} else {
+} elseif { ![info exists GXX_UNDER_TEST] } {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+    return
 }
 
-if { $lang_test_file_found } {
-    # Gather a list of all tests.
-    set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
+# Gather a list of all tests.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
 
-    if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
-    }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-
-    set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-    if { $blddir != "" \
-	 && [file exists $flags_file] } {
-	set libstdcxx_includes [exec sh $flags_file --build-includes]
-    } else {
-	set libstdcxx_includes ""
-    }
+set ld_library_path "$always_ld_library_path"
+if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+}
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
 
-    # Main loop.
-    dg-runtest $tests "" $libstdcxx_includes
+set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
+if { $blddir != "" \
+     && [file exists $flags_file] } {
+    set libstdcxx_includes [exec sh $flags_file --build-includes]
+} else {
+    set libstdcxx_includes ""
 }
 
+# Main loop.
+dg-runtest $tests "" $libstdcxx_includes
+
 # All done.
 dg-finish
diff --git libgomp/testsuite/libgomp.c/c.exp libgomp/testsuite/libgomp.c/c.exp
index e7f9e85..c2e8d35 100644
--- libgomp/testsuite/libgomp.c/c.exp
+++ libgomp/testsuite/libgomp.c/c.exp
@@ -1,17 +1,10 @@
-if [info exists lang_library_path] then {
-    unset lang_library_path
-    unset lang_link_flags
-}
-if [info exists lang_test_file_found] then {
-    unset lang_test_file_found
-}
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
-
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
+unset -nocomplain lang_include_flags
+unset -nocomplain lang_library_path
+unset -nocomplain lang_link_flags
+
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
     set DEFAULT_CFLAGS "-O2"
diff --git libgomp/testsuite/libgomp.fortran/fortran.exp libgomp/testsuite/libgomp.fortran/fortran.exp
index 18a151e..7739049 100644
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -6,14 +6,10 @@ global shlib_ext
 global ALWAYS_CFLAGS
 
 set shlib_ext [get_shlib_extension]
-set lang_library_path	"../libgfortran/.libs"
-set lang_link_flags	"-lgfortran"
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
-set lang_test_file_found 0
-set quadmath_library_path "../libquadmath/.libs"
 
+unset -nocomplain lang_include_flags
+unset -nocomplain lang_library_path
+set lang_link_flags "-lgfortran"
 
 # Initialize dg.
 dg-init
@@ -24,46 +20,41 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
-    # Look for a static libgfortran first.
-    if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file_found 1
-	# We may have a shared only build, so look for a shared libgfortran.
-    } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libgfortran library found, will not execute fortran tests"
+
+    set lang_library_path "../libgfortran/.libs"
+    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"] \
+	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+	puts "No libgfortran library found, will not execute fortran tests"
+	return
     }
-} elseif [info exists GFORTRAN_UNDER_TEST] {
-    set lang_test_file_found 1
-} else {
+} elseif { ![info exists GFORTRAN_UNDER_TEST] } {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+    return
 }
 
-if { $lang_test_file_found } {
-    # Gather a list of all tests.
-    set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
+# Gather a list of all tests.
+set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
-    if { $blddir != "" } {
-	if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
-	     || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
-	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
-	    # Allow for spec subsitution.
-	    lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
-	} else {
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-	}
-    } else {
-        set ld_library_path "$always_ld_library_path"
+set ld_library_path $always_ld_library_path
+if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+
+    set quadmath_library_path "../libquadmath/.libs"
+    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
+	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
+	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
+	# Allow for spec subsitution.
+	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
+	append ld_library_path ":${blddir}/${quadmath_library_path}"
     }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-
-    # For Fortran we're doing torture testing, as Fortran has far more tests
-    # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
-    # typically not the case for C/C++.
-    gfortran-dg-runtest $tests "" ""
 }
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+# For Fortran we're doing torture testing, as Fortran has far more tests
+# with arrays etc. that testing just -O0 or -O2 is insufficient, that is
+# typically not the case for C/C++.
+gfortran-dg-runtest $tests "" ""
 
 # All done.
 dg-finish
diff --git libgomp/testsuite/libgomp.graphite/graphite.exp libgomp/testsuite/libgomp.graphite/graphite.exp
index 78a269b..606f6ba 100644
--- libgomp/testsuite/libgomp.graphite/graphite.exp
+++ libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -14,27 +14,12 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-if [info exists lang_library_path] then {
-    unset lang_library_path
-    unset lang_link_flags
-}
-if [info exists lang_test_file_found] then {
-    unset lang_test_file_found
-}
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
-
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
-if ![check_effective_target_pthread] {
-  return
-}
-
-if ![check_effective_target_fgraphite] {
-  return
-}
+unset -nocomplain lang_include_flags
+unset -nocomplain lang_library_path
+unset -nocomplain lang_link_flags
 
 # Flags for force-parallel-*.c testcases.
 set PARALLEL_CFLAGS "-ansi -pedantic-errors -O2 \
@@ -48,6 +33,14 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
+if ![check_effective_target_pthread] {
+  return
+}
+
+if ![check_effective_target_fgraphite] {
+  return
+}
+
 # Gather a list of all tests.
 set tests [lsort [find $srcdir/$subdir *.c]]
 

commit 2c785bdccabc03a767d40165b448899d58a278bd
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Sat Nov 1 18:03:29 2014 +0100

    libgomp testsuite: Replace lang_source_re with lang_source_suffixes.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_target_compile): Use globbing
    	of lang_source_suffixes instead of regexp matching of
    	lang_source_re.
    	* testsuite/libgomp.fortran/fortran.exp: Set and use
    	lang_source_suffixes instead of lang_source_re.
---
 libgomp/testsuite/lib/libgomp.exp             | 4 ++--
 libgomp/testsuite/libgomp.fortran/fortran.exp | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 27f777b..beb361a 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -183,13 +183,13 @@ proc libgomp_target_compile { source dest type options } {
     global ALWAYS_CFLAGS
     global GCC_UNDER_TEST
 
-    global lang_source_re lang_include_flags
+    global lang_source_suffixes lang_include_flags
     # Only add these flags if actually compiling a file for the respective
     # language.  This is important, because this function is also invoked to
     # probe for compiler features, which might be done with a front end that
     # does not like lang_include_flags.
     if { [info exists lang_include_flags] \
-	 && [regexp ${lang_source_re} ${source}] } {
+	 && [glob -nocomplain -path [file rootname $source] .$lang_source_suffixes] != "" } {
 	lappend options "additional_flags=${lang_include_flags}"
     }
 
diff --git libgomp/testsuite/libgomp.fortran/fortran.exp libgomp/testsuite/libgomp.fortran/fortran.exp
index 7739049..d6f2bff 100644
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -18,7 +18,6 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 if { $blddir != "" } {
-    set lang_source_re {^.*\.[fF](|90|95|03|08)$}
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 
     set lang_library_path "../libgfortran/.libs"
@@ -33,7 +32,8 @@ if { $blddir != "" } {
 }
 
 # Gather a list of all tests.
-set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
+set lang_source_suffixes \[fF\]{,90,95,03,08}
+set tests [lsort [find $srcdir/$subdir "*.$lang_source_suffixes"]]
 
 set ld_library_path $always_ld_library_path
 if { $blddir != "" } {

commit 4bfb65497ef895b3fc348d567dabb81a40c62578
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Sat Nov 1 19:01:35 2014 +0100

    libgomp testsuite: Simplify lang_*.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_init): Initialize
    	lang_source_suffixes, lang_include_flags, lang_library_path,
    	lang_link_flags.
    	* testsuite/libgomp.c++/c++.exp: ... instead of here.
    	* testsuite/libgomp.c/c.exp: Likewise.
    	* testsuite/libgomp.fortran/fortran.exp: Likewise.
    	* testsuite/libgomp.graphite/graphite.exp: Likewise.
---
 libgomp/testsuite/lib/libgomp.exp               | 12 ++++++++++++
 libgomp/testsuite/libgomp.c++/c++.exp           |  6 ++----
 libgomp/testsuite/libgomp.c/c.exp               |  4 ----
 libgomp/testsuite/libgomp.fortran/fortran.exp   |  6 ++----
 libgomp/testsuite/libgomp.graphite/graphite.exp |  4 ----
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index beb361a..902309f 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -170,6 +170,18 @@ proc libgomp_init { args } {
 
     # Disable color diagnostics
     lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
+
+    # The following may be set by specific *.exp files.
+    # A glob list of suffixes for files to which...
+    global lang_source_suffixes
+    unset -nocomplain lang_source_suffixes
+    # ... these compiler flags will be applied.
+    global lang_include_flags
+    unset -nocomplain lang_include_flags
+    global lang_library_path
+    unset -nocomplain lang_library_path
+    global lang_link_flags
+    unset -nocomplain lang_link_flags
 }
 
 #
diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index 6523c4b..36ebec0 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -5,10 +5,6 @@ global shlib_ext
 
 set shlib_ext [get_shlib_extension]
 
-unset -nocomplain lang_include_flags
-unset -nocomplain lang_library_path
-set lang_link_flags "-lstdc++"
-
 # Initialize dg.
 dg-init
 
@@ -27,6 +23,8 @@ if { $blddir != "" } {
     return
 }
 
+set lang_link_flags "-lstdc++"
+
 # Gather a list of all tests.
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
 
diff --git libgomp/testsuite/libgomp.c/c.exp libgomp/testsuite/libgomp.c/c.exp
index c2e8d35..4cc69f9 100644
--- libgomp/testsuite/libgomp.c/c.exp
+++ libgomp/testsuite/libgomp.c/c.exp
@@ -1,10 +1,6 @@
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
-unset -nocomplain lang_include_flags
-unset -nocomplain lang_library_path
-unset -nocomplain lang_link_flags
-
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
     set DEFAULT_CFLAGS "-O2"
diff --git libgomp/testsuite/libgomp.fortran/fortran.exp libgomp/testsuite/libgomp.fortran/fortran.exp
index d6f2bff..2552f38 100644
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -7,10 +7,6 @@ global ALWAYS_CFLAGS
 
 set shlib_ext [get_shlib_extension]
 
-unset -nocomplain lang_include_flags
-unset -nocomplain lang_library_path
-set lang_link_flags "-lgfortran"
-
 # Initialize dg.
 dg-init
 
@@ -31,6 +27,8 @@ if { $blddir != "" } {
     return
 }
 
+set lang_link_flags "-lgfortran"
+
 # Gather a list of all tests.
 set lang_source_suffixes \[fF\]{,90,95,03,08}
 set tests [lsort [find $srcdir/$subdir "*.$lang_source_suffixes"]]
diff --git libgomp/testsuite/libgomp.graphite/graphite.exp libgomp/testsuite/libgomp.graphite/graphite.exp
index 606f6ba..c07447f 100644
--- libgomp/testsuite/libgomp.graphite/graphite.exp
+++ libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -17,10 +17,6 @@
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
-unset -nocomplain lang_include_flags
-unset -nocomplain lang_library_path
-unset -nocomplain lang_link_flags
-
 # Flags for force-parallel-*.c testcases.
 set PARALLEL_CFLAGS "-ansi -pedantic-errors -O2 \
 -ftree-parallelize-loops=4 -floop-parallelize-all \

commit 3ac7c628c59c87cab56cb5749695738724a6bf2d
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Sun Nov 2 17:49:31 2014 +0100

    libgomp testsuite: Generalize lang_library_path into a list lang_library_paths.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_init)
    	(libgomp_target_compile): Generalize lang_library_path into a list
    	lang_library_paths.
    	* testsuite/libgomp.c++/c++.exp: Update accordingly.
    	* testsuite/libgomp.fortran/fortran.exp: Likewise.  Also use it
    	for libquadmath.
---
 libgomp/testsuite/lib/libgomp.exp             | 18 ++++++++++--------
 libgomp/testsuite/libgomp.c++/c++.exp         |  9 +++++----
 libgomp/testsuite/libgomp.fortran/fortran.exp | 25 ++++++++++++++-----------
 3 files changed, 29 insertions(+), 23 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 902309f..0bf19ab 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -178,8 +178,8 @@ proc libgomp_init { args } {
     # ... these compiler flags will be applied.
     global lang_include_flags
     unset -nocomplain lang_include_flags
-    global lang_library_path
-    unset -nocomplain lang_library_path
+    global lang_library_paths
+    unset -nocomplain lang_library_paths
     global lang_link_flags
     unset -nocomplain lang_link_flags
 }
@@ -205,12 +205,14 @@ proc libgomp_target_compile { source dest type options } {
 	lappend options "additional_flags=${lang_include_flags}"
     }
 
-    global lang_library_path
-    if { [info exists lang_library_path] } {
-	# Some targets use libgfortran.a%s in their specs, so they need
-	# a -B option for uninstalled testing.
-	lappend options "additional_flags=-B${blddir}/${lang_library_path}"
-	lappend options "ldflags=-L${blddir}/${lang_library_path}"
+    global lang_library_paths
+    if { [info exists lang_library_paths] } {
+	foreach lang_library_path $lang_library_paths {
+	    # Some targets use lib[...].a%s in their specs, so they need
+	    # a -B option for uninstalled testing.
+	    lappend options "additional_flags=-B${blddir}/${lang_library_path}"
+	    lappend options "ldflags=-L${blddir}/${lang_library_path}"
+	}
     }
     global lang_link_flags
     if { [info exists lang_link_flags] } {
diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index 36ebec0..e1e9c3c 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -12,12 +12,13 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 if { $blddir != "" } {
-    set lang_library_path "../libstdc++-v3/src/.libs"
-    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"] \
-	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+    set libstdcxx_library_path "../libstdc++-v3/src/.libs"
+    if { ![file exists "${blddir}/${libstdcxx_library_path}/libstdc++.a"] \
+	 && ![file exists "${blddir}/${libstdcxx_library_path}/libstdc++.${shlib_ext}"] } {
 	puts "No libstdc++ library found, will not execute c++ tests"
 	return
     }
+    lappend lang_library_paths $libstdcxx_library_path
 } elseif { ![info exists GXX_UNDER_TEST] } {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
@@ -30,7 +31,7 @@ set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
 
 set ld_library_path "$always_ld_library_path"
 if { $blddir != "" } {
-    append ld_library_path ":${blddir}/${lang_library_path}"
+    append ld_library_path ":${blddir}/${libstdcxx_library_path}"
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
diff --git libgomp/testsuite/libgomp.fortran/fortran.exp libgomp/testsuite/libgomp.fortran/fortran.exp
index 2552f38..bbe600e 100644
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -16,12 +16,21 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 if { $blddir != "" } {
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 
-    set lang_library_path "../libgfortran/.libs"
-    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"] \
-	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+    set gfortran_library_path "../libgfortran/.libs"
+    if { ![file exists "${blddir}/${gfortran_library_path}/libgfortran.a"] \
+	 && ![file exists "${blddir}/${gfortran_library_path}/libgfortran.${shlib_ext}"] } {
 	puts "No libgfortran library found, will not execute fortran tests"
 	return
     }
+    lappend lang_library_paths $gfortran_library_path
+
+    set quadmath_library_path "../libquadmath/.libs"
+    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"] \
+	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
+	lappend lang_library_paths $quadmath_library_path
+    } else {
+	unset quadmath_library_path
+    }
 } elseif { ![info exists GFORTRAN_UNDER_TEST] } {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
     return
@@ -35,14 +44,8 @@ set tests [lsort [find $srcdir/$subdir "*.$lang_source_suffixes"]]
 
 set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-    append ld_library_path ":${blddir}/${lang_library_path}"
-
-    set quadmath_library_path "../libquadmath/.libs"
-    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
-	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
-	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
-	# Allow for spec subsitution.
-	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
+    append ld_library_path ":${blddir}/${gfortran_library_path}"
+    if { [info exists quadmath_library_path] } {
 	append ld_library_path ":${blddir}/${quadmath_library_path}"
     }
 }

commit 0d528ff752e6a2ace4d9053df38546a8ad479274
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Mon Nov 3 18:14:58 2014 +0100

    libgomp testsuite: Use GXX_UNDER_TEST, GFORTRAN_UNDER_TEST for installed testing.
    
    	libgomp/
    	* testsuite/lib/libgomp.exp (libgomp_init)
    	(libgomp_target_compile): Initialize and use COMPILER_UNDER_TEST,
    	respectively.
    	* testsuite/libgomp.c++/c++.exp: Set it to GXX_UNDER_TEST.  Only
    	for non-installed testing set lang_link_flags, and use
    	GCC_UNDER_TEST.
    	* testsuite/libgomp.fortran/fortran.exp: Likewise for
    	GFORTRAN_UNDER_TEST.
---
 libgomp/testsuite/lib/libgomp.exp             | 18 ++++++++++++------
 libgomp/testsuite/libgomp.c++/c++.exp         |  7 ++++++-
 libgomp/testsuite/libgomp.fortran/fortran.exp |  7 ++++++-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git libgomp/testsuite/lib/libgomp.exp libgomp/testsuite/lib/libgomp.exp
index 0bf19ab..a50ff21 100644
--- libgomp/testsuite/lib/libgomp.exp
+++ libgomp/testsuite/lib/libgomp.exp
@@ -33,10 +33,6 @@ load_gcc_lib fortran-modules.exp
 
 set dg-do-what-default run
 
-#
-# GCC_UNDER_TEST is the compiler under test.
-#
-
 set libgomp_compile_options ""
 
 #
@@ -182,6 +178,8 @@ proc libgomp_init { args } {
     unset -nocomplain lang_library_paths
     global lang_link_flags
     unset -nocomplain lang_link_flags
+    global COMPILER_UNDER_TEST
+    unset -nocomplain COMPILER_UNDER_TEST
 }
 
 #
@@ -193,7 +191,6 @@ proc libgomp_target_compile { source dest type options } {
     global libgomp_compile_options
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
-    global GCC_UNDER_TEST
 
     global lang_source_suffixes lang_include_flags
     # Only add these flags if actually compiling a file for the respective
@@ -226,7 +223,16 @@ proc libgomp_target_compile { source dest type options } {
 
     lappend options "additional_flags=[libio_include_flags]"
     lappend options "timeout=[timeout_value]"
-    lappend options "compiler=$GCC_UNDER_TEST"
+
+    global COMPILER_UNDER_TEST
+    if { [info exists COMPILER_UNDER_TEST] } {
+	set compiler "$COMPILER_UNDER_TEST"
+    } else {
+	# Default to GCC_UNDER_TEST.
+	global GCC_UNDER_TEST
+	set compiler "$GCC_UNDER_TEST"
+    }
+    lappend options "compiler=$compiler"
 
     set options [concat $libgomp_compile_options $options]
 
diff --git libgomp/testsuite/libgomp.c++/c++.exp libgomp/testsuite/libgomp.c++/c++.exp
index e1e9c3c..e960985 100644
--- libgomp/testsuite/libgomp.c++/c++.exp
+++ libgomp/testsuite/libgomp.c++/c++.exp
@@ -12,6 +12,10 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 if { $blddir != "" } {
+    # Use GCC_UNDER_TEST.
+    set GXX_UNDER_TEST "$GCC_UNDER_TEST"
+
+    # Using GCC_UNDER_TEST, we have to manually link in libstdc++.
     set libstdcxx_library_path "../libstdc++-v3/src/.libs"
     if { ![file exists "${blddir}/${libstdcxx_library_path}/libstdc++.a"] \
 	 && ![file exists "${blddir}/${libstdcxx_library_path}/libstdc++.${shlib_ext}"] } {
@@ -19,12 +23,13 @@ if { $blddir != "" } {
 	return
     }
     lappend lang_library_paths $libstdcxx_library_path
+    set lang_link_flags "-lstdc++"
 } elseif { ![info exists GXX_UNDER_TEST] } {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
 }
 
-set lang_link_flags "-lstdc++"
+set COMPILER_UNDER_TEST "$GXX_UNDER_TEST"
 
 # Gather a list of all tests.
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
diff --git libgomp/testsuite/libgomp.fortran/fortran.exp libgomp/testsuite/libgomp.fortran/fortran.exp
index bbe600e..9caeb3b 100644
--- libgomp/testsuite/libgomp.fortran/fortran.exp
+++ libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -14,8 +14,12 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 if { $blddir != "" } {
+    # Use GCC_UNDER_TEST.
+    set GFORTRAN_UNDER_TEST "$GCC_UNDER_TEST"
+
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 
+    # Using GCC_UNDER_TEST, we have to manually link in libgfortran.
     set gfortran_library_path "../libgfortran/.libs"
     if { ![file exists "${blddir}/${gfortran_library_path}/libgfortran.a"] \
 	 && ![file exists "${blddir}/${gfortran_library_path}/libgfortran.${shlib_ext}"] } {
@@ -23,6 +27,7 @@ if { $blddir != "" } {
 	return
     }
     lappend lang_library_paths $gfortran_library_path
+    set lang_link_flags "-lgfortran"
 
     set quadmath_library_path "../libquadmath/.libs"
     if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"] \
@@ -36,7 +41,7 @@ if { $blddir != "" } {
     return
 }
 
-set lang_link_flags "-lgfortran"
+set COMPILER_UNDER_TEST "$GFORTRAN_UNDER_TEST"
 
 # Gather a list of all tests.
 set lang_source_suffixes \[fF\]{,90,95,03,08}


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: libgomp testsuite: (not) using a specific driver for C++, Fortran?
  2014-11-04 12:14 ` Thomas Schwinge
@ 2014-11-04 18:32   ` Mike Stump
  2023-05-09 12:36     ` libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
                       ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Mike Stump @ 2014-11-04 18:32 UTC (permalink / raw)
  To: Thomas Schwinge
  Cc: Jakub Jelinek, Richard Henderson, gcc-patches, Rainer Orth,
	Janis Johnson

On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
> 
> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>> No matter whether it's C, C++, or Fortran source code, the libgomp
>> testsuite always uses (for build-tree testing) gcc/xgcc, or (for
>> installed testing) GCC_UNDER_TEST.  It doesn't make use of
>> GXX_UNDER_TEST, GFORTRAN_UNDER_TEST.  To support the latter two
>> languages' needs, some -l[...] flags are then added via lang_link_flags.
>> For example, for Fortran this is -lgfortran.  This is, however, not what
>> would happen if using the gfortran driver to build (which is what a user
>> would be doing -- which we should replicate as much as possible at least
>> for installed testing): the gfortran driver also adds -lquadmath, if
>> applicable.
>> 
>> Now, I wonder why to re-invent all that in the libgomp testsuite, if the
>> respective driver already has that knowledge, via spec files, for
>> example?  (Also, the regular GCC compiler tests, gcc/testsuite/, are
>> doing the right thing.)  Why is libgomp testsuite implemented this way --
>> just a legacy of the past, or is there a need for that (that I'm not
>> seeing)?
>> 
>> Maybe the question also is: why isn't the libgomp testsuite using more of
>> the infrastructure for specific languages, that is already implemented in
>> gcc/testsuite/lib/?  (That is, why does libgomp have to use
>> libgomp_target_compile, instead of [language]_target_compile, for
>> example.)
> 
> (I decided not to look into that latter idea, at the moment.)
> 
>> And maybe that problem also applied to additional target libraries'
>> testsuites; I have not yet looked.
> 
> (It does, but I'm not addressing that with the following patches.)
> 
>> Anyway, here is a prototype patch to describe how I began to address this
>> for the issue I stumbled upon, which is that the linker complained:
>> 
>>    Executing on host: x86_64-none-linux-gnu-gcc [...]/libgomp/testsuite/libgomp.fortran/aligned1.f03 [...] -fopenmp   -O0  -fopenmp -fcray-pointer   -lgfortran -lm   -o ./aligned1.exe    (timeout = 300)
>>    [...]/ld: warning: libquadmath.so.0, needed by [...]/libgfortran.so, not found (try using -rpath or -rpath-link)
>>    [...]/libgfortran.so: undefined reference to `logq@QUADMATH_1.0'
>>    [...]
>> 
>> (That goes away if I add -lquadmath to the command line, but that's not
>> the point I'm making here.)
>> 
>> Am I on the right track with the following?
> 
> Nobody commented, which also means nobody disagreed

:-)

> OK to commit all that to trunk?

Ok, thanks.

If you could, one minor point, s/puts/verbose “boa bla“ <N>/   I know it was preexisting.

I wonder if any variables that you set that need to be cleared out are, that seems a defect in the api or conventions we use and it can screw following tests with a wrong environment in subtle ways.  I could miss accidental bleed over from the .exp you’re modifying into other unrelated parts of the test suite.  Usually, we just try and be careful and clean it up if it breaks.

Watch for any review points from the libgomp people, they might trickle a few in.  I don’t mean to cut short any review points from them.

Also, please watch for breakage.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)
  2014-11-04 18:32   ` Mike Stump
@ 2023-05-09 12:36     ` Thomas Schwinge
  2023-05-09 12:39       ` libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
  2023-05-09 12:54     ` libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-09 12:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Tobias Burnus, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]

Hi!

On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
> On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>>> [...]
>>>
>>> Am I on the right track with the following?
>>
>> Nobody commented, which also means nobody disagreed
>
> :-)
>
>> OK to commit all that to trunk?
>
> Ok, thanks.

Almost one decade later (eek...) I'm now finally getting back to this.
First, a number of clean-up patches; rebased, adjusted, retested for
current state of affairs (not too much changed in libgomp testsuite
infrastructure, though).

Pushed to master branch commit b7b209843654bb240589251c90c3465a84d704da
"libgomp C++ testsuite: Don't compute 'blddir' twice", see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-C-testsuite-Don-t-compute-blddir-twice.patch --]
[-- Type: text/x-diff, Size: 1736 bytes --]

From b7b209843654bb240589251c90c3465a84d704da Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 31 Oct 2014 16:49:14 +0100
Subject: [PATCH] libgomp C++ testsuite: Don't compute 'blddir' twice

It has already been set in 'libgomp/testsuite/lib/libgomp.exp:libgomp_init'.

	libgomp/
	* testsuite/libgomp.c++/c++.exp (blddir): Don't set.
	* testsuite/libgomp.oacc-c++/c++.exp (blddir): Likewise.
---
 libgomp/testsuite/libgomp.c++/c++.exp      | 3 ---
 libgomp/testsuite/libgomp.oacc-c++/c++.exp | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 5b9a5924ff37..81c188e297a8 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -27,9 +27,6 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-set blddir [lookfor_file [get_multilibs] libgomp]
-
-
 if { $blddir != "" } {
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 0b235ba47f35..09001788bb42 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -33,9 +33,6 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-set blddir [lookfor_file [get_multilibs] libgomp]
-
-
 if { $blddir != "" } {
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))
  2023-05-09 12:36     ` libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
@ 2023-05-09 12:39       ` Thomas Schwinge
  2023-05-09 12:41         ` libgomp testsuite: Use 'lang_test_file_found' instead of 'lang_test_file' (was: libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))) Thomas Schwinge
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-09 12:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Tobias Burnus, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]

Hi!

On 2023-05-09T14:36:53+0200, I wrote:
> On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
>> On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>>> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>>>> [...]
>>>>
>>>> Am I on the right track with the following?
>>>
>>> Nobody commented, which also means nobody disagreed
>>
>> :-)
>>
>>> OK to commit all that to trunk?
>>
>> Ok, thanks.
>
> Almost one decade later (eek...) I'm now finally getting back to this.
> First, a number of clean-up patches; rebased, adjusted, retested for
> current state of affairs (not too much changed in libgomp testsuite
> infrastructure, though).

Pushed to master branch commit fed3dbbfd1b707d7386b14e724056bfe2234e3a5
"libgomp testsuite: Only use 'blddir' if set", see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-Only-use-blddir-if-set.patch --]
[-- Type: text/x-diff, Size: 3091 bytes --]

From fed3dbbfd1b707d7386b14e724056bfe2234e3a5 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Mon, 3 Nov 2014 09:58:38 +0100
Subject: [PATCH] libgomp testsuite: Only use 'blddir' if set

(It is unclear to me why the current working directory needs to be in
'LD_LIBRARY_PATH'; leaving that alone for now.)

	libgomp/
	* testsuite/lib/libgomp.exp (libgomp_init): Only use 'blddir' if
	set.
	* testsuite/libgomp.c++/c++.exp: Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
---
 libgomp/testsuite/lib/libgomp.exp          | 5 +++--
 libgomp/testsuite/libgomp.c++/c++.exp      | 3 ++-
 libgomp/testsuite/libgomp.oacc-c++/c++.exp | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index e12236e9083c..92f650742290 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -66,7 +66,6 @@ proc libgomp_init { args } {
     global srcdir blddir objdir tool_root_dir
     global libgomp_initialized
     global tmpdir
-    global blddir
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global CFLAGS
@@ -118,7 +117,7 @@ proc libgomp_init { args } {
     }
 
     # Compute what needs to be put into LD_LIBRARY_PATH
-    set always_ld_library_path ".:${blddir}/.libs"
+    set always_ld_library_path "."
 
     global offload_additional_lib_paths
     if { $offload_additional_lib_paths != "" } {
@@ -157,6 +156,8 @@ proc libgomp_init { args } {
         lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
         lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
         lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
+
+	append always_ld_library_path ":${blddir}/.libs"
     }
     # The top-level include directory, for gomp-constants.h.
     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include"
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 81c188e297a8..188d1a823561 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -62,7 +62,8 @@ if { $lang_test_file_found } {
     set_ld_library_path_env_vars
 
     set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-    if { [file exists $flags_file] } {
+    if { $blddir != ""
+	 && [file exists $flags_file] } {
 	set lang_source_re {^.*\.[cC]$}
 	set lang_include_flags [exec sh $flags_file --build-includes]
     }
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 09001788bb42..24a4d1f67b96 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -68,7 +68,8 @@ if { $lang_test_file_found } {
     set_ld_library_path_env_vars
 
     set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-    if { [file exists $flags_file] } {
+    if { $blddir != ""
+	 && [file exists $flags_file] } {
 	set lang_source_re {^.*\.[cC]$}
 	set lang_include_flags [exec sh $flags_file --build-includes]
     }
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: Use 'lang_test_file_found' instead of 'lang_test_file' (was: libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)))
  2023-05-09 12:39       ` libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
@ 2023-05-09 12:41         ` Thomas Schwinge
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-09 12:41 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Tobias Burnus, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]

Hi!

On 2023-05-09T14:39:53+0200, I wrote:
> On 2023-05-09T14:36:53+0200, I wrote:
>> On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
>>> On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>>>> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>>>>> [...]
>>>>>
>>>>> Am I on the right track with the following?
>>>>
>>>> Nobody commented, which also means nobody disagreed
>>>
>>> :-)
>>>
>>>> OK to commit all that to trunk?
>>>
>>> Ok, thanks.
>>
>> Almost one decade later (eek...) I'm now finally getting back to this.
>> First, a number of clean-up patches; rebased, adjusted, retested for
>> current state of affairs (not too much changed in libgomp testsuite
>> infrastructure, though).

Pushed to master branch commit 2ed5ceba0fe313ef09bdfe98788ba9377bfec9aa
"libgomp testsuite: Use 'lang_test_file_found' instead of 'lang_test_file'",
see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-Use-lang_test_file_found-instead-o.patch --]
[-- Type: text/x-diff, Size: 8505 bytes --]

From 2ed5ceba0fe313ef09bdfe98788ba9377bfec9aa Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 31 Oct 2014 17:38:03 +0100
Subject: [PATCH] libgomp testsuite: Use 'lang_test_file_found' instead of
 'lang_test_file'

The value of 'lang_test_file' isn't actually used anywhere.

	libgomp/
	* testsuite/libgomp.c++/c++.exp: Don't set 'lang_test_file'.
	* testsuite/libgomp.fortran/fortran.exp: Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
	* testsuite/libgomp.c/c.exp: Unset 'lang_test_file_found' instead of
	'lang_test_file'.
	* testsuite/libgomp.oacc-c/c.exp: Likewise.
	* testsuite/libgomp.graphite/graphite.exp: Likewise.
	* testsuite/lib/libgomp.exp (libgomp_target_compile): Look for
	'lang_test_file_found' instead of 'lang_test_file'.
---
 libgomp/testsuite/lib/libgomp.exp                  | 4 ++--
 libgomp/testsuite/libgomp.c++/c++.exp              | 4 ----
 libgomp/testsuite/libgomp.c/c.exp                  | 4 ++--
 libgomp/testsuite/libgomp.fortran/fortran.exp      | 4 ----
 libgomp/testsuite/libgomp.graphite/graphite.exp    | 4 ++--
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         | 4 ----
 libgomp/testsuite/libgomp.oacc-c/c.exp             | 4 ++--
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp | 4 ----
 8 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 92f650742290..aae7149a97df 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -234,13 +234,13 @@ proc libgomp_target_compile { source dest type options } {
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global GCC_UNDER_TEST
-    global lang_test_file
+    global lang_test_file_found
     global lang_library_path
     global lang_link_flags
     global lang_include_flags
     global lang_source_re
 
-    if { [info exists lang_test_file] } {
+    if { [info exists lang_test_file_found] } {
         if { $blddir != "" } {
             # Some targets use libgfortran.a%s in their specs, so they need
             # a -B option for uninstalled testing.
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 188d1a823561..7dd2d49d568e 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -30,19 +30,15 @@ set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 if { $blddir != "" } {
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file "${lang_library_path}/libstdc++.a"
         set lang_test_file_found 1
         # We may have a shared only build, so look for a shared libstdc++.
     } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}"
         set lang_test_file_found 1
     } else {
         puts "No libstdc++ library found, will not execute c++ tests"
     }
 } elseif { [info exists GXX_UNDER_TEST] } {
     set lang_test_file_found 1
-    # Needs to exist for libgomp.exp.
-    set lang_test_file ""
 } else {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
 }
diff --git a/libgomp/testsuite/libgomp.c/c.exp b/libgomp/testsuite/libgomp.c/c.exp
index 31bdd5795dc2..e67adc8b378c 100644
--- a/libgomp/testsuite/libgomp.c/c.exp
+++ b/libgomp/testsuite/libgomp.c/c.exp
@@ -2,8 +2,8 @@ if [info exists lang_library_path] then {
     unset lang_library_path
     unset lang_link_flags
 }
-if [info exists lang_test_file] then {
-    unset lang_test_file
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
 }
 if [info exists lang_include_flags] then {
     unset lang_include_flags
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index eb701311b6a0..5e8e15e7743e 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -26,19 +26,15 @@ if { $blddir != "" } {
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
     # Look for a static libgfortran first.
     if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file "${lang_library_path}/libgfortran.a"
         set lang_test_file_found 1
 	# We may have a shared only build, so look for a shared libgfortran.
     } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}"
         set lang_test_file_found 1
     } else {
         puts "No libgfortran library found, will not execute fortran tests"
     }
 } elseif [info exists GFORTRAN_UNDER_TEST] {
     set lang_test_file_found 1
-    # Needs to exist for libgomp.exp.
-    set lang_test_file ""
 } else {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
 }
diff --git a/libgomp/testsuite/libgomp.graphite/graphite.exp b/libgomp/testsuite/libgomp.graphite/graphite.exp
index 1260dc91ec21..1c5ea663af34 100644
--- a/libgomp/testsuite/libgomp.graphite/graphite.exp
+++ b/libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -18,8 +18,8 @@ if [info exists lang_library_path] then {
     unset lang_library_path
     unset lang_link_flags
 }
-if [info exists lang_test_file] then {
-    unset lang_test_file
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
 }
 if [info exists lang_include_flags] then {
     unset lang_include_flags
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 24a4d1f67b96..24ab8bb35ff5 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -36,19 +36,15 @@ set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 if { $blddir != "" } {
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file "${lang_library_path}/libstdc++.a"
         set lang_test_file_found 1
         # We may have a shared only build, so look for a shared libstdc++.
     } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}"
         set lang_test_file_found 1
     } else {
         puts "No libstdc++ library found, will not execute c++ tests"
     }
 } elseif { [info exists GXX_UNDER_TEST] } {
     set lang_test_file_found 1
-    # Needs to exist for libgomp.exp.
-    set lang_test_file ""
 } else {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
 }
diff --git a/libgomp/testsuite/libgomp.oacc-c/c.exp b/libgomp/testsuite/libgomp.oacc-c/c.exp
index 4bb2b2ac4949..8a960aafadc1 100644
--- a/libgomp/testsuite/libgomp.oacc-c/c.exp
+++ b/libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -4,8 +4,8 @@ if [info exists lang_library_path] then {
     unset lang_library_path
     unset lang_link_flags
 }
-if [info exists lang_test_file] then {
-    unset lang_test_file
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
 }
 if [info exists lang_include_flags] then {
     unset lang_include_flags
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 7365b320668a..a56c7d903509 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -28,19 +28,15 @@ if { $blddir != "" } {
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
     # Look for a static libgfortran first.
     if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file "${lang_library_path}/libgfortran.a"
         set lang_test_file_found 1
 	# We may have a shared only build, so look for a shared libgfortran.
     } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}"
         set lang_test_file_found 1
     } else {
         puts "No libgfortran library found, will not execute fortran tests"
     }
 } elseif [info exists GFORTRAN_UNDER_TEST] {
     set lang_test_file_found 1
-    # Needs to exist for libgomp.exp.
-    set lang_test_file ""
 } else {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
 }
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)
  2014-11-04 18:32   ` Mike Stump
  2023-05-09 12:36     ` libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
@ 2023-05-09 12:54     ` Thomas Schwinge
  2023-05-09 12:59       ` libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
  2023-05-12  7:26     ` libgomp testsuite: Generalize 'lang_library_path' into a list of 'lang_library_paths' (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
  2023-05-12  8:27     ` libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] " Thomas Schwinge
  3 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-09 12:54 UTC (permalink / raw)
  To: Mike Stump, gcc-patches; +Cc: Jakub Jelinek, Rainer Orth, Tobias Burnus

[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]

Hi!

On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
> I wonder if any variables that you set that need to be cleared out are, that seems a defect in the api or conventions we use and it can screw following tests with a wrong environment in subtle ways.  I could miss accidental bleed over from the .exp you’re modifying into other unrelated parts of the test suite.

Aye, that topic keeps coming back...  ;-\ I'm not aware of any such
defects in my changes, but I do agree that the current structure of the
libgomp testsuite is a bit weird in that regard: that every '*.exp' file
begins with a bunch of conditional 'unset lang_[...]' to clean up what
the previous '*.exp' file left behind.  I propose to simplify this as per
the attached "libgomp testsuite: Localize 'lang_[...]' etc." -- OK to
push?  (That's a new patch, loosely based on/extracted out of my earlier
work.  I'm posting it separately, but given that it's in line with my
earlier work (just a separate step), I intend to push it soon, unless
there are any objections, of course.)


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-Localize-lang_-.-etc.patch --]
[-- Type: text/x-diff, Size: 8089 bytes --]

From 6230d3b0aef9b785c7d62c512e8939cca183fdb4 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 9 May 2023 10:09:35 +0200
Subject: [PATCH] libgomp testsuite: Localize 'lang_[...]' etc.

..., instead of letting them bleed into the next '*.exp' file, requiring
clean-up there.

	libgomp/
	* testsuite/libgomp.c++/c++.exp: Localize 'lang_[...]' etc.
	* testsuite/libgomp.c/c.exp: Likewise.
	* testsuite/libgomp.fortran/fortran.exp: Likewise.
	* testsuite/libgomp.graphite/graphite.exp: Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.oacc-c/c.exp: Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/libgomp.c++/c++.exp             | 11 ++++++++---
 libgomp/testsuite/libgomp.c/c.exp                 | 11 -----------
 libgomp/testsuite/libgomp.fortran/fortran.exp     | 15 ++++++++++-----
 libgomp/testsuite/libgomp.graphite/graphite.exp   | 11 -----------
 libgomp/testsuite/libgomp.oacc-c++/c++.exp        | 11 ++++++++---
 libgomp/testsuite/libgomp.oacc-c/c.exp            | 11 -----------
 .../testsuite/libgomp.oacc-fortran/fortran.exp    | 15 ++++++++++-----
 7 files changed, 36 insertions(+), 49 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 7dd2d49d568..442e9f744d0 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -7,9 +7,6 @@ set shlib_ext [get_shlib_extension]
 set lang_link_flags "-lstdc++"
 set lang_test_file_found 0
 set lang_library_path "../libstdc++-v3/src/.libs"
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
 
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
@@ -71,5 +68,13 @@ if { $lang_test_file_found } {
 # See above.
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
 
+if [info exists lang_include_flags] then {
+    unset lang_source_re
+    unset lang_include_flags
+}
+unset lang_library_path
+unset lang_link_flags
+unset lang_test_file_found
+
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.c/c.exp b/libgomp/testsuite/libgomp.c/c.exp
index e67adc8b378..0ee28ed723e 100644
--- a/libgomp/testsuite/libgomp.c/c.exp
+++ b/libgomp/testsuite/libgomp.c/c.exp
@@ -1,14 +1,3 @@
-if [info exists lang_library_path] then {
-    unset lang_library_path
-    unset lang_link_flags
-}
-if [info exists lang_test_file_found] then {
-    unset lang_test_file_found
-}
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
-
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index 5e8e15e7743..7ea00a25bd9 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -8,12 +8,7 @@ global ALWAYS_CFLAGS
 set shlib_ext [get_shlib_extension]
 set lang_library_path	"../libgfortran/.libs"
 set lang_link_flags	"-lgfortran -foffload=-lgfortran"
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
 set lang_test_file_found 0
-set quadmath_library_path "../libquadmath/.libs"
-
 
 # Initialize dg.
 dg-init
@@ -44,6 +39,7 @@ if { $lang_test_file_found } {
     set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
     if { $blddir != "" } {
+	set quadmath_library_path "../libquadmath/.libs"
 	if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
 	     || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
 	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
@@ -54,6 +50,7 @@ if { $lang_test_file_found } {
 	} else {
 	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
 	}
+	unset quadmath_library_path
     } else {
         set ld_library_path "$always_ld_library_path"
         if { [check_no_compiler_messages has_libquadmath executable {
@@ -71,5 +68,13 @@ if { $lang_test_file_found } {
     gfortran-dg-runtest $tests "" ""
 }
 
+if { $blddir != "" } {
+    unset lang_source_re
+    unset lang_include_flags
+}
+unset lang_library_path
+unset lang_link_flags
+unset lang_test_file_found
+
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.graphite/graphite.exp b/libgomp/testsuite/libgomp.graphite/graphite.exp
index 1c5ea663af3..ff53a31272c 100644
--- a/libgomp/testsuite/libgomp.graphite/graphite.exp
+++ b/libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -14,17 +14,6 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-if [info exists lang_library_path] then {
-    unset lang_library_path
-    unset lang_link_flags
-}
-if [info exists lang_test_file_found] then {
-    unset lang_test_file_found
-}
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
-
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 24ab8bb35ff..5d9dc5d4a3f 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -17,9 +17,6 @@ set shlib_ext [get_shlib_extension]
 set lang_link_flags "-lstdc++"
 set lang_test_file_found 0
 set lang_library_path "../libstdc++-v3/src/.libs"
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
 
 # Initialize dg.
 dg-init
@@ -152,6 +149,14 @@ if { $lang_test_file_found } {
 # See above.
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
 
+if [info exists lang_include_flags] then {
+    unset lang_source_re
+    unset lang_include_flags
+}
+unset lang_library_path
+unset lang_link_flags
+unset lang_test_file_found
+
 # All done.
 torture-finish
 dg-finish
diff --git a/libgomp/testsuite/libgomp.oacc-c/c.exp b/libgomp/testsuite/libgomp.oacc-c/c.exp
index 8a960aafadc..ca61a82937a 100644
--- a/libgomp/testsuite/libgomp.oacc-c/c.exp
+++ b/libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -1,16 +1,5 @@
 # This whole file adapted from libgomp.c/c.exp.
 
-if [info exists lang_library_path] then {
-    unset lang_library_path
-    unset lang_link_flags
-}
-if [info exists lang_test_file_found] then {
-    unset lang_test_file_found
-}
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
-
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib torture-options.exp
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index a56c7d90350..1ac2320ec22 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -10,12 +10,7 @@ global ALWAYS_CFLAGS
 set shlib_ext [get_shlib_extension]
 set lang_library_path	"../libgfortran/.libs"
 set lang_link_flags	"-lgfortran -foffload=-lgfortran"
-if [info exists lang_include_flags] then {
-    unset lang_include_flags
-}
 set lang_test_file_found 0
-set quadmath_library_path "../libquadmath/.libs"
-
 
 # Initialize dg.
 dg-init
@@ -46,6 +41,7 @@ if { $lang_test_file_found } {
     set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
     if { $blddir != "" } {
+	set quadmath_library_path "../libquadmath/.libs"
 	if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
 	     || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
 	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
@@ -56,6 +52,7 @@ if { $lang_test_file_found } {
 	} else {
 	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
 	}
+	unset quadmath_library_path
     } else {
         set ld_library_path "$always_ld_library_path"
         if { [check_no_compiler_messages has_libquadmath executable {
@@ -120,5 +117,13 @@ if { $lang_test_file_found } {
     unset offload_target
 }
 
+if { $blddir != "" } {
+    unset lang_source_re
+    unset lang_include_flags
+}
+unset lang_library_path
+unset lang_link_flags
+unset lang_test_file_found
+
 # All done.
 dg-finish
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))
  2023-05-09 12:54     ` libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
@ 2023-05-09 12:59       ` Thomas Schwinge
  2023-05-09 13:05         ` libgomp testsuite: Get rid of 'lang_test_file_found' (was: libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))) Thomas Schwinge
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-09 12:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Rainer Orth, Tobias Burnus

[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]

Hi!

On 2023-05-09T14:54:21+0200, I wrote:
> [...] libgomp testsuite is a bit weird [...]: that every '*.exp' file
> begins with a bunch of conditional 'unset lang_[...]' to clean up what
> the previous '*.exp' file left behind.  I propose to simplify this as per
> the attached "libgomp testsuite: Localize 'lang_[...]' etc." -- OK to
> push?

On top of this I'd then push the attached
"libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first",
see attached, which again is extracted out of my earlier work.  This is
to enable follow-on clean-up.

> given that it's in line with my
> earlier work (just a separate step), I intend to push it soon, unless
> there are any objections, of course.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-C-Fortran-testsuites-Resolve-lang_test_file_.patch --]
[-- Type: text/x-diff, Size: 8712 bytes --]

From 9b7c6db76c5757a32b246dc8cb912902a3ffdb35 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Sat, 1 Nov 2014 16:25:26 +0100
Subject: [PATCH] libgomp C++, Fortran testsuites: Resolve
 'lang_test_file_found' first

	libgomp/
	* testsuite/libgomp.c++/c++.exp: Resolve 'lang_test_file_found'
	first.
	* testsuite/libgomp.fortran/fortran.exp: Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/libgomp.c++/c++.exp         | 43 +++++++++----------
 libgomp/testsuite/libgomp.fortran/fortran.exp | 30 ++++++-------
 libgomp/testsuite/libgomp.oacc-c++/c++.exp    | 37 ++++++++--------
 .../libgomp.oacc-fortran/fortran.exp          | 31 +++++++------
 4 files changed, 68 insertions(+), 73 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 442e9f744d0..797a05ca870 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -1,12 +1,25 @@
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
-global shlib_ext
-
-set shlib_ext [get_shlib_extension]
-set lang_link_flags "-lstdc++"
 set lang_test_file_found 0
-set lang_library_path "../libstdc++-v3/src/.libs"
+if { $blddir != "" } {
+    set lang_library_path "../libstdc++-v3/src/.libs"
+    set shlib_ext [get_shlib_extension]
+    # Look for a static libstdc++ first.
+    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
+        set lang_test_file_found 1
+        # We may have a shared only build, so look for a shared libstdc++.
+    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
+        set lang_test_file_found 1
+    } else {
+        puts "No libstdc++ library found, will not execute c++ tests"
+    }
+} elseif { [info exists GXX_UNDER_TEST] } {
+    set lang_test_file_found 1
+} else {
+    puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+}
+set lang_link_flags "-lstdc++"
 
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
@@ -24,22 +37,6 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-if { $blddir != "" } {
-    # Look for a static libstdc++ first.
-    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file_found 1
-        # We may have a shared only build, so look for a shared libstdc++.
-    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libstdc++ library found, will not execute c++ tests"
-    }
-} elseif { [info exists GXX_UNDER_TEST] } {
-    set lang_test_file_found 1
-} else {
-    puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
-}
-
 if { $lang_test_file_found } {
     # Gather a list of all tests.
     set tests [lsort [concat \
@@ -72,7 +69,9 @@ if [info exists lang_include_flags] then {
     unset lang_source_re
     unset lang_include_flags
 }
-unset lang_library_path
+if { $blddir != "" } {
+    unset lang_library_path
+}
 unset lang_link_flags
 unset lang_test_file_found
 
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index 7ea00a25bd9..16ce9d3e023 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -2,23 +2,10 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
-global shlib_ext
-global ALWAYS_CFLAGS
-
-set shlib_ext [get_shlib_extension]
-set lang_library_path	"../libgfortran/.libs"
-set lang_link_flags	"-lgfortran -foffload=-lgfortran"
 set lang_test_file_found 0
-
-# Initialize dg.
-dg-init
-
-# Turn on OpenMP.
-lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
-
 if { $blddir != "" } {
-    set lang_source_re {^.*\.[fF](|90|95|03|08)$}
-    set lang_include_flags "-fintrinsic-modules-path=${blddir}"
+    set lang_library_path "../libgfortran/.libs"
+    set shlib_ext [get_shlib_extension]
     # Look for a static libgfortran first.
     if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
         set lang_test_file_found 1
@@ -33,6 +20,17 @@ if { $blddir != "" } {
 } else {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
 }
+if { $blddir != "" } {
+    set lang_source_re {^.*\.[fF](|90|95|03|08)$}
+    set lang_include_flags "-fintrinsic-modules-path=${blddir}"
+}
+set lang_link_flags "-lgfortran -foffload=-lgfortran"
+
+# Initialize dg.
+dg-init
+
+# Turn on OpenMP.
+lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 if { $lang_test_file_found } {
     # Gather a list of all tests.
@@ -71,8 +69,8 @@ if { $lang_test_file_found } {
 if { $blddir != "" } {
     unset lang_source_re
     unset lang_include_flags
+    unset lang_library_path
 }
-unset lang_library_path
 unset lang_link_flags
 unset lang_test_file_found
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 5d9dc5d4a3f..060aaa27419 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -11,26 +11,10 @@ proc check_effective_target_c++ { } {
     return 1
 }
 
-global shlib_ext
-
-set shlib_ext [get_shlib_extension]
-set lang_link_flags "-lstdc++"
 set lang_test_file_found 0
-set lang_library_path "../libstdc++-v3/src/.libs"
-
-# Initialize dg.
-dg-init
-torture-init
-
-# Turn on OpenACC.
-lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
-
-# Switch into C++ mode.  Otherwise, the libgomp.oacc-c-c++-common/*.c
-# files would be compiled as C files.
-set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
-set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
-
 if { $blddir != "" } {
+    set lang_library_path "../libstdc++-v3/src/.libs"
+    set shlib_ext [get_shlib_extension]
     # Look for a static libstdc++ first.
     if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
         set lang_test_file_found 1
@@ -45,6 +29,19 @@ if { $blddir != "" } {
 } else {
     puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
 }
+set lang_link_flags "-lstdc++"
+
+# Initialize dg.
+dg-init
+torture-init
+
+# Turn on OpenACC.
+lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
+
+# Switch into C++ mode.  Otherwise, the libgomp.oacc-c-c++-common/*.c
+# files would be compiled as C files.
+set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
+set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
 if { $lang_test_file_found } {
     # Gather a list of all tests.
@@ -153,7 +150,9 @@ if [info exists lang_include_flags] then {
     unset lang_source_re
     unset lang_include_flags
 }
-unset lang_library_path
+if { $blddir != "" } {
+    unset lang_library_path
+}
 unset lang_link_flags
 unset lang_test_file_found
 
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 1ac2320ec22..9af526007cf 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -4,23 +4,10 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
-global shlib_ext
-global ALWAYS_CFLAGS
-
-set shlib_ext [get_shlib_extension]
-set lang_library_path	"../libgfortran/.libs"
-set lang_link_flags	"-lgfortran -foffload=-lgfortran"
 set lang_test_file_found 0
-
-# Initialize dg.
-dg-init
-
-# Turn on OpenACC.
-lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
-
 if { $blddir != "" } {
-    set lang_source_re {^.*\.[fF](|90|95|03|08)$}
-    set lang_include_flags "-fintrinsic-modules-path=${blddir}"
+    set lang_library_path "../libgfortran/.libs"
+    set shlib_ext [get_shlib_extension]
     # Look for a static libgfortran first.
     if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
         set lang_test_file_found 1
@@ -35,6 +22,18 @@ if { $blddir != "" } {
 } else {
     puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
 }
+if { $blddir != "" } {
+    set lang_source_re {^.*\.[fF](|90|95|03|08)$}
+    set lang_include_flags "-fintrinsic-modules-path=${blddir}"
+}
+set lang_link_flags "-lgfortran -foffload=-lgfortran"
+
+# Initialize dg.
+dg-init
+
+# Turn on OpenACC.
+lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
+
 
 if { $lang_test_file_found } {
     # Gather a list of all tests.
@@ -120,8 +119,8 @@ if { $lang_test_file_found } {
 if { $blddir != "" } {
     unset lang_source_re
     unset lang_include_flags
+    unset lang_library_path
 }
-unset lang_library_path
 unset lang_link_flags
 unset lang_test_file_found
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: Get rid of 'lang_test_file_found' (was: libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)))
  2023-05-09 12:59       ` libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
@ 2023-05-09 13:05         ` Thomas Schwinge
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-09 13:05 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Rainer Orth, Tobias Burnus

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

Hi!

On 2023-05-09T14:59:53+0200, I wrote:
> On 2023-05-09T14:54:21+0200, I wrote:
>> [...] libgomp testsuite is a bit weird [...]: that every '*.exp' file
>> begins with a bunch of conditional 'unset lang_[...]' to clean up what
>> the previous '*.exp' file left behind.  I propose to simplify this as per
>> the attached "libgomp testsuite: Localize 'lang_[...]' etc." -- OK to
>> push?
>
> On top of this I'd then push the attached
> "libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first",
> see attached, which again is extracted out of my earlier work.  This is
> to enable follow-on clean-up.

... which is "libgomp testsuite: Get rid of 'lang_test_file_found'", see
attached.  I'm also attaching a 'git format-patch --ignore-all-space'
variant, for easier review.

>> given that it's in line with my
>> earlier work (just a separate step), I intend to push it soon, unless
>> there are any objections, of course.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-Get-rid-of-lang_test_file_found.patch --]
[-- Type: text/x-diff, Size: 27440 bytes --]

From 38528210d3eb3da198be6900378f9e9d1ff10b53 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Sat, 1 Nov 2014 16:25:26 +0100
Subject: [PATCH] libgomp testsuite: Get rid of 'lang_test_file_found'

Instead, 'return' early from the '*.exp' files that we're not able to test.
Also, change 'puts' into 'verbose -log'.  While re-indenting the previous
'if { $lang_test_file_found } { [...] }' code, also simplify 'ld_library_path'
setup.

	libgomp/
	* testsuite/lib/libgomp.exp (libgomp_target_compile): Don't look
	at 'lang_test_file_found'.
	* testsuite/libgomp.c++/c++.exp: Don't set and use it, and instead
	'return' early if not able to test.  Simplify 'ld_library_path' setup.
	* testsuite/libgomp.fortran/fortran.exp: Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/lib/libgomp.exp             |  31 ++-
 libgomp/testsuite/libgomp.c++/c++.exp         |  61 +++---
 libgomp/testsuite/libgomp.fortran/fortran.exp |  80 ++++----
 libgomp/testsuite/libgomp.oacc-c++/c++.exp    | 187 ++++++++----------
 .../libgomp.oacc-fortran/fortran.exp          | 166 ++++++++--------
 5 files changed, 243 insertions(+), 282 deletions(-)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index dce33d788cc..c30fa4ed24b 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -240,24 +240,23 @@ proc libgomp_target_compile { source dest type options } {
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global GCC_UNDER_TEST
-    global lang_test_file_found
+
+    global lang_source_re lang_include_flags
+    if { [info exists lang_include_flags] \
+	 && [regexp ${lang_source_re} ${source}] } {
+	lappend options "additional_flags=${lang_include_flags}"
+    }
+
     global lang_library_path
+    if { [info exists lang_library_path] } {
+	# Some targets use libgfortran.a%s in their specs, so they need
+	# a -B option for uninstalled testing.
+	lappend options "additional_flags=-B${blddir}/${lang_library_path}"
+	lappend options "ldflags=-L${blddir}/${lang_library_path}"
+    }
     global lang_link_flags
-    global lang_include_flags
-    global lang_source_re
-
-    if { [info exists lang_test_file_found] } {
-        if { $blddir != "" } {
-            # Some targets use libgfortran.a%s in their specs, so they need
-            # a -B option for uninstalled testing.
-            lappend options "additional_flags=-B${blddir}/${lang_library_path}"
-            lappend options "ldflags=-L${blddir}/${lang_library_path}"
-        }
-        lappend options "ldflags=${lang_link_flags}"
-	if { [info exists lang_include_flags] \
-	     && [regexp ${lang_source_re} ${source}] } {
-	    lappend options "additional_flags=${lang_include_flags}"
-	}
+    if { [info exists lang_link_flags] } {
+	lappend options "ldflags=${lang_link_flags}"
     }
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 797a05ca870..8307baf32fc 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -1,23 +1,18 @@
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libstdc++-v3/src/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libstdc++ first.
-    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file_found 1
-        # We may have a shared only build, so look for a shared libstdc++.
-    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libstdc++ library found, will not execute c++ tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+	verbose -log "No libstdc++ library found, will not execute c++ tests"
+	unset lang_library_path
+	return
     }
-} elseif { [info exists GXX_UNDER_TEST] } {
-    set lang_test_file_found 1
-} else {
-    puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+} elseif { ![info exists GXX_UNDER_TEST] } {
+    verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
+    return
 }
 set lang_link_flags "-lstdc++"
 
@@ -37,31 +32,28 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-if { $lang_test_file_found } {
-    # Gather a list of all tests.
-    set tests [lsort [concat \
-			  [find $srcdir/$subdir *.C] \
-			  [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
+# Gather a list of all tests.
+set tests [lsort [concat \
+		      [find $srcdir/$subdir *.C] \
+		      [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
 
-    if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
-    }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-
-    set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-    if { $blddir != ""
-	 && [file exists $flags_file] } {
-	set lang_source_re {^.*\.[cC]$}
-	set lang_include_flags [exec sh $flags_file --build-includes]
-    }
+set ld_library_path $always_ld_library_path
+if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+}
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
 
-    # Main loop.
-    dg-runtest $tests "" $DEFAULT_CFLAGS
+set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
+if { $blddir != ""
+     && [file exists $flags_file] } {
+    set lang_source_re {^.*\.[cC]$}
+    set lang_include_flags [exec sh $flags_file --build-includes]
 }
 
+# Main loop.
+dg-runtest $tests "" $DEFAULT_CFLAGS
+
 # See above.
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
 
@@ -73,7 +65,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index 16ce9d3e023..d98739c8c99 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -2,23 +2,18 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libgfortran/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libgfortran first.
-    if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file_found 1
-	# We may have a shared only build, so look for a shared libgfortran.
-    } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libgfortran library found, will not execute fortran tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+        verbose -log "No libgfortran library found, will not execute fortran tests"
+	unset lang_library_path
+	return
     }
-} elseif [info exists GFORTRAN_UNDER_TEST] {
-    set lang_test_file_found 1
-} else {
-    puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+} elseif { ![info exists GFORTRAN_UNDER_TEST] } {
+    verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+    return
 }
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
@@ -32,39 +27,37 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
-if { $lang_test_file_found } {
-    # Gather a list of all tests.
-    set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
+# Gather a list of all tests.
+set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
-    if { $blddir != "" } {
-	set quadmath_library_path "../libquadmath/.libs"
-	if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
-	     || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
-	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
-	    # Allow for spec subsitution.
-	    lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
-	    append lang_link_flags " -lquadmath"
-	} else {
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-	}
-	unset quadmath_library_path
-    } else {
-        set ld_library_path "$always_ld_library_path"
-        if { [check_no_compiler_messages has_libquadmath executable {
-                 int main() {return 0;}
-              } "-lgfortran -lquadmath"] } then {
-            append lang_link_flags " -lquadmath"
-        }
-    }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
+set ld_library_path $always_ld_library_path
+if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
 
-    # For Fortran we're doing torture testing, as Fortran has far more tests
-    # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
-    # typically not the case for C/C++.
-    gfortran-dg-runtest $tests "" ""
+    set quadmath_library_path "../libquadmath/.libs"
+    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
+	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
+	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
+	# Allow for spec subsitution.
+	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
+	append ld_library_path ":${blddir}/${quadmath_library_path}"
+	append lang_link_flags " -lquadmath"
+    }
+    unset quadmath_library_path
+} else {
+    if { [check_no_compiler_messages has_libquadmath executable {
+             int main() {return 0;}
+          } "-lgfortran -lquadmath"] } then {
+	append lang_link_flags " -lquadmath"
+    }
 }
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+# For Fortran we're doing torture testing, as Fortran has far more tests
+# with arrays etc. that testing just -O0 or -O2 is insufficient, that is
+# typically not the case for C/C++.
+gfortran-dg-runtest $tests "" ""
 
 if { $blddir != "" } {
     unset lang_source_re
@@ -72,7 +65,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 060aaa27419..5e4f7049349 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -11,23 +11,18 @@ proc check_effective_target_c++ { } {
     return 1
 }
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libstdc++-v3/src/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libstdc++ first.
-    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file_found 1
-        # We may have a shared only build, so look for a shared libstdc++.
-    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libstdc++ library found, will not execute c++ tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+        verbose -log "No libstdc++ library found, will not execute c++ tests"
+	unset lang_library_path
+	return
     }
-} elseif { [info exists GXX_UNDER_TEST] } {
-    set lang_test_file_found 1
-} else {
-    puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+} elseif { ![info exists GXX_UNDER_TEST] } {
+    verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
+    return
 }
 set lang_link_flags "-lstdc++"
 
@@ -43,105 +38,98 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-if { $lang_test_file_found } {
-    # Gather a list of all tests.
-    set tests [lsort [concat \
-			  [find $srcdir/$subdir *.C] \
-			  [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
+# Gather a list of all tests.
+set tests [lsort [concat \
+		      [find $srcdir/$subdir *.C] \
+		      [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
 
-    if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
-    }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-
-    set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-    if { $blddir != ""
-	 && [file exists $flags_file] } {
-	set lang_source_re {^.*\.[cC]$}
-	set lang_include_flags [exec sh $flags_file --build-includes]
-    }
+set ld_library_path $always_ld_library_path
+if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+}
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
+if { $blddir != ""
+     && [file exists $flags_file] } {
+    set lang_source_re {^.*\.[cC]$}
+    set lang_include_flags [exec sh $flags_file --build-includes]
+}
 
-    # Test with all available offload targets, and with offloading disabled.
-    foreach offload_target [concat [split $offload_targets ","] "disable"] {
-	global openacc_device_type
-	set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
-	set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
+# Test with all available offload targets, and with offloading disabled.
+foreach offload_target [concat [split $offload_targets ","] "disable"] {
+    global openacc_device_type
+    set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
+    set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
 
-	switch $openacc_device_type {
-	    "" {
-		unsupported "$subdir $offload_target offloading"
+    switch $openacc_device_type {
+	"" {
+	    unsupported "$subdir $offload_target offloading"
+	    continue
+	}
+	host {
+	    set acc_mem_shared 1
+	}
+	nvidia {
+	    if { ![check_effective_target_openacc_nvidia_accel_present] } {
+		# Don't bother; execution testing is going to FAIL.
+		untested "$subdir $offload_target offloading: supported, but hardware not accessible"
 		continue
 	    }
-	    host {
-		set acc_mem_shared 1
-	    }
-	    nvidia {
-		if { ![check_effective_target_openacc_nvidia_accel_present] } {
-		    # Don't bother; execution testing is going to FAIL.
-		    untested "$subdir $offload_target offloading: supported, but hardware not accessible"
-		    continue
-		}
 
-		# Copy ptx file (TEMPORARY)
-		remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
+	    # Copy ptx file (TEMPORARY)
+	    remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
 
-		# Where timer.h lives
-		lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
+	    # Where timer.h lives
+	    lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
 
-		set acc_mem_shared 0
-	    }
-	    radeon {
-		if { ![check_effective_target_openacc_radeon_accel_present] } {
-		    # Don't bother; execution testing is going to FAIL.
-		    untested "$subdir $offload_target offloading: supported, but hardware not accessible"
-		    continue
-		}
-
-		set acc_mem_shared 0
-	    }
-	    default {
-		error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)"
-	    }
+	    set acc_mem_shared 0
 	}
-	set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
-
-	# To avoid compilation overhead, and to keep simple '-foffload=[...]'
-	# handling in test cases, by default only build for the offload target
-	# that we're actually going to test.
-	set tagopt "$tagopt -foffload=$offload_target"
-	# Force usage of the corresponding OpenACC device type.
-	setenv ACC_DEVICE_TYPE $openacc_device_type
-
-	# To get better test coverage for device-specific code that is only
-	# ever used in offloading configurations, we'd like more thorough
-	# testing for test cases that deal with offloading, which most of all
-	# OpenACC test cases are.  We enable torture testing, but limit it to
-	# -O0 and -O2 only, to avoid testing times exploding too much, under
-	# the assumption that between -O0 and -O[something] there is the
-	# biggest difference in the overall structure of the generated code.
-	switch -glob $offload_target {
-	    disable {
-		set-torture-options [list \
-					 { -O2 } ]
-	    }
-	    default {
-		set-torture-options [list \
-					 { -O0 } \
-					 { -O2 } ]
+	radeon {
+	    if { ![check_effective_target_openacc_radeon_accel_present] } {
+		# Don't bother; execution testing is going to FAIL.
+		untested "$subdir $offload_target offloading: supported, but hardware not accessible"
+		continue
 	    }
-	}
 
-	gcc-dg-runtest $tests "$tagopt" ""
+	    set acc_mem_shared 0
+	}
+	default {
+	    error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)"
+	}
     }
-    unset offload_target
-} else {
-    # Call this once, which placates the subsequent torture-finish.
-    set-torture-options [list \
-			     { INVALID } ]
+    set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
+
+    # To avoid compilation overhead, and to keep simple '-foffload=[...]'
+    # handling in test cases, by default only build for the offload target
+    # that we're actually going to test.
+    set tagopt "$tagopt -foffload=$offload_target"
+    # Force usage of the corresponding OpenACC device type.
+    setenv ACC_DEVICE_TYPE $openacc_device_type
+
+    # To get better test coverage for device-specific code that is only
+    # ever used in offloading configurations, we'd like more thorough
+    # testing for test cases that deal with offloading, which most of all
+    # OpenACC test cases are.  We enable torture testing, but limit it to
+    # -O0 and -O2 only, to avoid testing times exploding too much, under
+    # the assumption that between -O0 and -O[something] there is the
+    # biggest difference in the overall structure of the generated code.
+    switch -glob $offload_target {
+	disable {
+	    set-torture-options [list \
+				     { -O2 } ]
+	}
+	default {
+	    set-torture-options [list \
+				     { -O0 } \
+				     { -O2 } ]
+	}
+    }
+
+    gcc-dg-runtest $tests "$tagopt" ""
 }
+unset offload_target
 
 # See above.
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
@@ -154,7 +142,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 torture-finish
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 9af526007cf..a590558a195 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -4,23 +4,18 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libgfortran/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libgfortran first.
-    if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file_found 1
-	# We may have a shared only build, so look for a shared libgfortran.
-    } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libgfortran library found, will not execute fortran tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+        verbose -log "No libgfortran library found, will not execute fortran tests"
+	unset lang_library_path
+	return
     }
-} elseif [info exists GFORTRAN_UNDER_TEST] {
-    set lang_test_file_found 1
-} else {
-    puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+} elseif { ![info exists GFORTRAN_UNDER_TEST] } {
+    verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+    return
 }
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
@@ -35,86 +30,84 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 
 
-if { $lang_test_file_found } {
-    # Gather a list of all tests.
-    set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
-
-    if { $blddir != "" } {
-	set quadmath_library_path "../libquadmath/.libs"
-	if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
-	     || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
-	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
-	    # Allow for spec subsitution.
-	    lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
-	    append lang_link_flags " -lquadmath"
-	} else {
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-	}
-	unset quadmath_library_path
-    } else {
-        set ld_library_path "$always_ld_library_path"
-        if { [check_no_compiler_messages has_libquadmath executable {
-                 int main() {return 0;}
-              } "-lgfortran -lquadmath"] } then {
-            append lang_link_flags " -lquadmath"
-        }
+# Gather a list of all tests.
+set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
+
+set ld_library_path $always_ld_library_path
+if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+
+    set quadmath_library_path "../libquadmath/.libs"
+    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
+	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
+	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
+	# Allow for spec subsitution.
+	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
+	append ld_library_path ":${blddir}/${quadmath_library_path}"
+	append lang_link_flags " -lquadmath"
     }
-    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-    set_ld_library_path_env_vars
-
-    # Test with all available offload targets, and with offloading disabled.
-    foreach offload_target [concat [split $offload_targets ","] "disable"] {
-	global openacc_device_type
-	set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
-	set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
-
-	switch $openacc_device_type {
-	    "" {
-		unsupported "$subdir $offload_target offloading"
+    unset quadmath_library_path
+} else {
+    if { [check_no_compiler_messages has_libquadmath executable {
+             int main() {return 0;}
+          } "-lgfortran -lquadmath"] } then {
+	append lang_link_flags " -lquadmath"
+    }
+}
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+# Test with all available offload targets, and with offloading disabled.
+foreach offload_target [concat [split $offload_targets ","] "disable"] {
+    global openacc_device_type
+    set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
+    set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
+
+    switch $openacc_device_type {
+	"" {
+	    unsupported "$subdir $offload_target offloading"
+	    continue
+	}
+	host {
+	    set acc_mem_shared 1
+	}
+	nvidia {
+	    if { ![check_effective_target_openacc_nvidia_accel_present] } {
+		# Don't bother; execution testing is going to FAIL.
+		untested "$subdir $offload_target offloading: supported, but hardware not accessible"
 		continue
 	    }
-	    host {
-		set acc_mem_shared 1
-	    }
-	    nvidia {
-		if { ![check_effective_target_openacc_nvidia_accel_present] } {
-		    # Don't bother; execution testing is going to FAIL.
-		    untested "$subdir $offload_target offloading: supported, but hardware not accessible"
-		    continue
-		}
-
-		set acc_mem_shared 0
-	    }
-	    radeon {
-		if { ![check_effective_target_openacc_radeon_accel_present] } {
-		    # Don't bother; execution testing is going to FAIL.
-		    untested "$subdir $offload_target offloading: supported, but hardware not accessible"
-		    continue
-		}
-
-		set acc_mem_shared 0
-	    }
-	    default {
-		error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)"
+
+	    set acc_mem_shared 0
+	}
+	radeon {
+	    if { ![check_effective_target_openacc_radeon_accel_present] } {
+		# Don't bother; execution testing is going to FAIL.
+		untested "$subdir $offload_target offloading: supported, but hardware not accessible"
+		continue
 	    }
+
+	    set acc_mem_shared 0
+	}
+	default {
+	    error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)"
 	}
-	set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
-
-	# To avoid compilation overhead, and to keep simple '-foffload=[...]'
-	# handling in test cases, by default only build for the offload target
-	# that we're actually going to test.
-	set tagopt "$tagopt -foffload=$offload_target"
-	# Force usage of the corresponding OpenACC device type.
-	setenv ACC_DEVICE_TYPE $openacc_device_type
-
-	# For Fortran we're doing torture testing, as Fortran has far more tests
-	# with arrays etc. that testing just -O0 or -O2 is insufficient, that is
-	# typically not the case for C/C++.
-	gfortran-dg-runtest $tests "$tagopt" ""
     }
-    unset offload_target
+    set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
+
+    # To avoid compilation overhead, and to keep simple '-foffload=[...]'
+    # handling in test cases, by default only build for the offload target
+    # that we're actually going to test.
+    set tagopt "$tagopt -foffload=$offload_target"
+    # Force usage of the corresponding OpenACC device type.
+    setenv ACC_DEVICE_TYPE $openacc_device_type
+
+    # For Fortran we're doing torture testing, as Fortran has far more tests
+    # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
+    # typically not the case for C/C++.
+    gfortran-dg-runtest $tests "$tagopt" ""
 }
+unset offload_target
 
 if { $blddir != "" } {
     unset lang_source_re
@@ -122,7 +115,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 dg-finish
-- 
2.34.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-libgomp-testsuite-Get-rid-of-lang_test_file_found_--ignore-all-space.patch --]
[-- Type: text/x-diff, Size: 14598 bytes --]

From 38528210d3eb3da198be6900378f9e9d1ff10b53 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Sat, 1 Nov 2014 16:25:26 +0100
Subject: [PATCH] libgomp testsuite: Get rid of 'lang_test_file_found'

Instead, 'return' early from the '*.exp' files that we're not able to test.
Also, change 'puts' into 'verbose -log'.  While re-indenting the previous
'if { $lang_test_file_found } { [...] }' code, also simplify 'ld_library_path'
setup.

	libgomp/
	* testsuite/lib/libgomp.exp (libgomp_target_compile): Don't look
	at 'lang_test_file_found'.
	* testsuite/libgomp.c++/c++.exp: Don't set and use it, and instead
	'return' early if not able to test.  Simplify 'ld_library_path' setup.
	* testsuite/libgomp.fortran/fortran.exp: Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/lib/libgomp.exp             | 21 ++++++-----
 libgomp/testsuite/libgomp.c++/c++.exp         | 29 ++++++---------
 libgomp/testsuite/libgomp.fortran/fortran.exp | 32 +++++++----------
 libgomp/testsuite/libgomp.oacc-c++/c++.exp    | 35 ++++++-------------
 .../libgomp.oacc-fortran/fortran.exp          | 32 +++++++----------
 5 files changed, 55 insertions(+), 94 deletions(-)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index dce33d788cc..c30fa4ed24b 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -240,24 +240,23 @@ proc libgomp_target_compile { source dest type options } {
     global gluefile wrap_flags
     global ALWAYS_CFLAGS
     global GCC_UNDER_TEST
-    global lang_test_file_found
-    global lang_library_path
-    global lang_link_flags
-    global lang_include_flags
-    global lang_source_re
 
-    if { [info exists lang_test_file_found] } {
-        if { $blddir != "" } {
+    global lang_source_re lang_include_flags
+    if { [info exists lang_include_flags] \
+	 && [regexp ${lang_source_re} ${source}] } {
+	lappend options "additional_flags=${lang_include_flags}"
+    }
+
+    global lang_library_path
+    if { [info exists lang_library_path] } {
 	# Some targets use libgfortran.a%s in their specs, so they need
 	# a -B option for uninstalled testing.
 	lappend options "additional_flags=-B${blddir}/${lang_library_path}"
 	lappend options "ldflags=-L${blddir}/${lang_library_path}"
     }
+    global lang_link_flags
+    if { [info exists lang_link_flags] } {
 	lappend options "ldflags=${lang_link_flags}"
-	if { [info exists lang_include_flags] \
-	     && [regexp ${lang_source_re} ${source}] } {
-	    lappend options "additional_flags=${lang_include_flags}"
-	}
     }
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 797a05ca870..8307baf32fc 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -1,23 +1,18 @@
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libstdc++-v3/src/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libstdc++ first.
-    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file_found 1
-        # We may have a shared only build, so look for a shared libstdc++.
-    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libstdc++ library found, will not execute c++ tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+	verbose -log "No libstdc++ library found, will not execute c++ tests"
+	unset lang_library_path
+	return
     }
-} elseif { [info exists GXX_UNDER_TEST] } {
-    set lang_test_file_found 1
-} else {
-    puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+} elseif { ![info exists GXX_UNDER_TEST] } {
+    verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
+    return
 }
 set lang_link_flags "-lstdc++"
 
@@ -37,16 +32,14 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-if { $lang_test_file_found } {
 # Gather a list of all tests.
 set tests [lsort [concat \
 		      [find $srcdir/$subdir *.C] \
 		      [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
 
+set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
+    append ld_library_path ":${blddir}/${lang_library_path}"
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
@@ -60,7 +53,6 @@ if { $lang_test_file_found } {
 
 # Main loop.
 dg-runtest $tests "" $DEFAULT_CFLAGS
-}
 
 # See above.
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
@@ -73,7 +65,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index 16ce9d3e023..d98739c8c99 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -2,23 +2,18 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libgfortran/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libgfortran first.
-    if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file_found 1
-	# We may have a shared only build, so look for a shared libgfortran.
-    } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libgfortran library found, will not execute fortran tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+        verbose -log "No libgfortran library found, will not execute fortran tests"
+	unset lang_library_path
+	return
     }
-} elseif [info exists GFORTRAN_UNDER_TEST] {
-    set lang_test_file_found 1
-} else {
-    puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+} elseif { ![info exists GFORTRAN_UNDER_TEST] } {
+    verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+    return
 }
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
@@ -32,25 +27,24 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
-if { $lang_test_file_found } {
 # Gather a list of all tests.
 set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
+set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+
     set quadmath_library_path "../libquadmath/.libs"
     if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
 	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
 	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
 	# Allow for spec subsitution.
 	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
+	append ld_library_path ":${blddir}/${quadmath_library_path}"
 	append lang_link_flags " -lquadmath"
-	} else {
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
     }
     unset quadmath_library_path
 } else {
-        set ld_library_path "$always_ld_library_path"
     if { [check_no_compiler_messages has_libquadmath executable {
              int main() {return 0;}
           } "-lgfortran -lquadmath"] } then {
@@ -64,7 +58,6 @@ if { $lang_test_file_found } {
 # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
 # typically not the case for C/C++.
 gfortran-dg-runtest $tests "" ""
-}
 
 if { $blddir != "" } {
     unset lang_source_re
@@ -72,7 +65,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 060aaa27419..5e4f7049349 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -11,23 +11,18 @@ proc check_effective_target_c++ { } {
     return 1
 }
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libstdc++-v3/src/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libstdc++ first.
-    if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
-        set lang_test_file_found 1
-        # We may have a shared only build, so look for a shared libstdc++.
-    } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libstdc++ library found, will not execute c++ tests"
-    }
-} elseif { [info exists GXX_UNDER_TEST] } {
-    set lang_test_file_found 1
-} else {
-    puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+        verbose -log "No libstdc++ library found, will not execute c++ tests"
+	unset lang_library_path
+	return
+    }
+} elseif { ![info exists GXX_UNDER_TEST] } {
+    verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
+    return
 }
 set lang_link_flags "-lstdc++"
 
@@ -43,16 +38,14 @@ lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
 
-if { $lang_test_file_found } {
 # Gather a list of all tests.
 set tests [lsort [concat \
 		      [find $srcdir/$subdir *.C] \
 		      [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
 
+set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-        set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
-    } else {
-        set ld_library_path "$always_ld_library_path"
+    append ld_library_path ":${blddir}/${lang_library_path}"
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
@@ -137,11 +130,6 @@ if { $lang_test_file_found } {
     gcc-dg-runtest $tests "$tagopt" ""
 }
 unset offload_target
-} else {
-    # Call this once, which placates the subsequent torture-finish.
-    set-torture-options [list \
-			     { INVALID } ]
-}
 
 # See above.
 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
@@ -154,7 +142,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 torture-finish
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 9af526007cf..a590558a195 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -4,23 +4,18 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
-set lang_test_file_found 0
 if { $blddir != "" } {
     set lang_library_path "../libgfortran/.libs"
     set shlib_ext [get_shlib_extension]
-    # Look for a static libgfortran first.
-    if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
-        set lang_test_file_found 1
-	# We may have a shared only build, so look for a shared libgfortran.
-    } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
-        set lang_test_file_found 1
-    } else {
-        puts "No libgfortran library found, will not execute fortran tests"
+    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"]
+	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+        verbose -log "No libgfortran library found, will not execute fortran tests"
+	unset lang_library_path
+	return
     }
-} elseif [info exists GFORTRAN_UNDER_TEST] {
-    set lang_test_file_found 1
-} else {
-    puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+} elseif { ![info exists GFORTRAN_UNDER_TEST] } {
+    verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
+    return
 }
 if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
@@ -35,25 +30,24 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 
 
-if { $lang_test_file_found } {
 # Gather a list of all tests.
 set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
+set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
+    append ld_library_path ":${blddir}/${lang_library_path}"
+
     set quadmath_library_path "../libquadmath/.libs"
     if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
 	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
 	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
 	# Allow for spec subsitution.
 	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
+	append ld_library_path ":${blddir}/${quadmath_library_path}"
 	append lang_link_flags " -lquadmath"
-	} else {
-	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
     }
     unset quadmath_library_path
 } else {
-        set ld_library_path "$always_ld_library_path"
     if { [check_no_compiler_messages has_libquadmath executable {
              int main() {return 0;}
           } "-lgfortran -lquadmath"] } then {
@@ -114,7 +108,6 @@ if { $lang_test_file_found } {
     gfortran-dg-runtest $tests "$tagopt" ""
 }
 unset offload_target
-}
 
 if { $blddir != "" } {
     unset lang_source_re
@@ -122,7 +115,6 @@ if { $blddir != "" } {
     unset lang_library_path
 }
 unset lang_link_flags
-unset lang_test_file_found
 
 # All done.
 dg-finish
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: Generalize 'lang_library_path' into a list of 'lang_library_paths' (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)
  2014-11-04 18:32   ` Mike Stump
  2023-05-09 12:36     ` libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
  2023-05-09 12:54     ` libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
@ 2023-05-12  7:26     ` Thomas Schwinge
  2023-05-12  8:27     ` libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] " Thomas Schwinge
  3 siblings, 0 replies; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-12  7:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Tobias Burnus, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

Hi!

On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
> On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>>> [...]
>>>
>>> Am I on the right track with the following?
>>
>> Nobody commented, which also means nobody disagreed
>
> :-)
>
>> OK to commit all that to trunk?
>
> Ok, thanks.

Rebased, adjusted, retested another 2014 clean-up patch; pushed to
master branch commit b794dc779382bb9e645ccc10b4447d4e411f6000
"libgomp testsuite: Generalize 'lang_library_path' into a list of 'lang_library_paths'"
("..., and use that for libquadmath, too"), see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-Generalize-lang_library_path-into-.patch --]
[-- Type: text/x-diff, Size: 11361 bytes --]

From b794dc779382bb9e645ccc10b4447d4e411f6000 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Sun, 2 Nov 2014 17:49:31 +0100
Subject: [PATCH] libgomp testsuite: Generalize 'lang_library_path' into a list
 of 'lang_library_paths'

..., and use that for libquadmath, too.

	libgomp/
	* testsuite/lib/libgomp.exp (libgomp_target_compile): Generalize
	'lang_library_path' into a list of 'lang_library_paths'.
	* testsuite/libgomp.c++/c++.exp: Adjust.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.fortran/fortran.exp: Adjust.  Use that for
	libquadmath, too.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/lib/libgomp.exp             | 14 ++++----
 libgomp/testsuite/libgomp.c++/c++.exp         | 14 ++++----
 libgomp/testsuite/libgomp.fortran/fortran.exp | 33 +++++++++--------
 libgomp/testsuite/libgomp.oacc-c++/c++.exp    | 14 ++++----
 .../libgomp.oacc-fortran/fortran.exp          | 35 +++++++++++--------
 5 files changed, 63 insertions(+), 47 deletions(-)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 2295fbbbd417..9fea31d80672 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -241,12 +241,14 @@ proc libgomp_target_compile { source dest type options } {
 	lappend options "additional_flags=${lang_include_flags}"
     }
 
-    global lang_library_path
-    if { [info exists lang_library_path] } {
-	# Some targets use libgfortran.a%s in their specs, so they need
-	# a -B option for uninstalled testing.
-	lappend options "additional_flags=-B${blddir}/${lang_library_path}"
-	lappend options "ldflags=-L${blddir}/${lang_library_path}"
+    global lang_library_paths
+    if { [info exists lang_library_paths] } {
+	foreach lang_library_path $lang_library_paths {
+	    # targets that use lib[...].a%s in their specs need a -B option
+	    # for uninstalled testing.
+	    lappend options "additional_flags=-B${blddir}/${lang_library_path}"
+	    lappend options "ldflags=-L${blddir}/${lang_library_path}"
+	}
     }
     global lang_link_flags
     if { [info exists lang_link_flags] } {
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 8307baf32fcf..1a1c3ee22252 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -2,14 +2,15 @@ load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
 if { $blddir != "" } {
-    set lang_library_path "../libstdc++-v3/src/.libs"
+    set libstdc++_library_path "../libstdc++-v3/src/.libs"
     set shlib_ext [get_shlib_extension]
-    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"]
-	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+    if { ![file exists "${blddir}/${libstdc++_library_path}/libstdc++.a"]
+	 && ![file exists "${blddir}/${libstdc++_library_path}/libstdc++.${shlib_ext}"] } {
 	verbose -log "No libstdc++ library found, will not execute c++ tests"
-	unset lang_library_path
+	unset libstdc++_library_path
 	return
     }
+    lappend lang_library_paths ${libstdc++_library_path}
 } elseif { ![info exists GXX_UNDER_TEST] } {
     verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
@@ -39,7 +40,7 @@ set tests [lsort [concat \
 
 set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-    append ld_library_path ":${blddir}/${lang_library_path}"
+    append ld_library_path ":${blddir}/${libstdc++_library_path}"
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
@@ -62,7 +63,8 @@ if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
 if { $blddir != "" } {
-    unset lang_library_path
+    unset libstdc++_library_path
+    unset lang_library_paths
 }
 unset lang_link_flags
 
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index d98739c8c99d..9295bbae65dd 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -3,14 +3,23 @@ load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
 if { $blddir != "" } {
-    set lang_library_path "../libgfortran/.libs"
+    set libgfortran_library_path "../libgfortran/.libs"
     set shlib_ext [get_shlib_extension]
-    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"]
-	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+    if { ![file exists "${blddir}/${libgfortran_library_path}/libgfortran.a"]
+	 && ![file exists "${blddir}/${libgfortran_library_path}/libgfortran.${shlib_ext}"] } {
         verbose -log "No libgfortran library found, will not execute fortran tests"
-	unset lang_library_path
+	unset libgfortran_library_path
 	return
     }
+    lappend lang_library_paths $libgfortran_library_path
+
+    set libquadmath_library_path "../libquadmath/.libs"
+    if { [file exists "${blddir}/${libquadmath_library_path}/libquadmath.a"]
+	 || [file exists "${blddir}/${libquadmath_library_path}/libquadmath.${shlib_ext}"] } {
+	lappend lang_library_paths $libquadmath_library_path
+    } else {
+	set libquadmath_library_path ""
+    }
 } elseif { ![info exists GFORTRAN_UNDER_TEST] } {
     verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
     return
@@ -32,18 +41,12 @@ set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
 set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-    append ld_library_path ":${blddir}/${lang_library_path}"
+    append ld_library_path ":${blddir}/${libgfortran_library_path}"
 
-    set quadmath_library_path "../libquadmath/.libs"
-    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
-	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
-	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
-	# Allow for spec subsitution.
-	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	append ld_library_path ":${blddir}/${quadmath_library_path}"
+    if { $libquadmath_library_path != "" } {
+	append ld_library_path ":${blddir}/${libquadmath_library_path}"
 	append lang_link_flags " -lquadmath"
     }
-    unset quadmath_library_path
 } else {
     if { [check_no_compiler_messages has_libquadmath executable {
              int main() {return 0;}
@@ -62,7 +65,9 @@ gfortran-dg-runtest $tests "" ""
 if { $blddir != "" } {
     unset lang_source_re
     unset lang_include_flags
-    unset lang_library_path
+    unset libgfortran_library_path
+    unset libquadmath_library_path
+    unset lang_library_paths
 }
 unset lang_link_flags
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 5e4f70493490..63d1d7650a20 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -12,14 +12,15 @@ proc check_effective_target_c++ { } {
 }
 
 if { $blddir != "" } {
-    set lang_library_path "../libstdc++-v3/src/.libs"
+    set libstdc++_library_path "../libstdc++-v3/src/.libs"
     set shlib_ext [get_shlib_extension]
-    if { ![file exists "${blddir}/${lang_library_path}/libstdc++.a"]
-	 && ![file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] } {
+    if { ![file exists "${blddir}/${libstdc++_library_path}/libstdc++.a"]
+	 && ![file exists "${blddir}/${libstdc++_library_path}/libstdc++.${shlib_ext}"] } {
         verbose -log "No libstdc++ library found, will not execute c++ tests"
-	unset lang_library_path
+	unset libstdc++_library_path
 	return
     }
+    lappend lang_library_paths ${libstdc++_library_path}
 } elseif { ![info exists GXX_UNDER_TEST] } {
     verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
@@ -45,7 +46,7 @@ set tests [lsort [concat \
 
 set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-    append ld_library_path ":${blddir}/${lang_library_path}"
+    append ld_library_path ":${blddir}/${libstdc++_library_path}"
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
@@ -139,7 +140,8 @@ if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
 if { $blddir != "" } {
-    unset lang_library_path
+    unset libstdc++_library_path
+    unset lang_library_paths
 }
 unset lang_link_flags
 
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index a590558a1950..af0a4f7ff311 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -5,14 +5,23 @@ load_gcc_lib gcc-dg.exp
 load_gcc_lib gfortran-dg.exp
 
 if { $blddir != "" } {
-    set lang_library_path "../libgfortran/.libs"
+    set libgfortran_library_path "../libgfortran/.libs"
     set shlib_ext [get_shlib_extension]
-    if { ![file exists "${blddir}/${lang_library_path}/libgfortran.a"]
-	 && ![file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] } {
+    if { ![file exists "${blddir}/${libgfortran_library_path}/libgfortran.a"]
+	 && ![file exists "${blddir}/${libgfortran_library_path}/libgfortran.${shlib_ext}"] } {
         verbose -log "No libgfortran library found, will not execute fortran tests"
-	unset lang_library_path
+	unset libgfortran_library_path
 	return
     }
+    lappend lang_library_paths $libgfortran_library_path
+
+    set libquadmath_library_path "../libquadmath/.libs"
+    if { [file exists "${blddir}/${libquadmath_library_path}/libquadmath.a"]
+	 || [file exists "${blddir}/${libquadmath_library_path}/libquadmath.${shlib_ext}"] } {
+	lappend lang_library_paths $libquadmath_library_path
+    } else {
+	set libquadmath_library_path ""
+    }
 } elseif { ![info exists GFORTRAN_UNDER_TEST] } {
     verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
     return
@@ -35,18 +44,12 @@ set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
 
 set ld_library_path $always_ld_library_path
 if { $blddir != "" } {
-    append ld_library_path ":${blddir}/${lang_library_path}"
-
-    set quadmath_library_path "../libquadmath/.libs"
-    if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
-	 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
-	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
-	# Allow for spec subsitution.
-	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
-	append ld_library_path ":${blddir}/${quadmath_library_path}"
+    append ld_library_path ":${blddir}/${libgfortran_library_path}"
+
+    if { $libquadmath_library_path != "" } {
+	append ld_library_path ":${blddir}/${libquadmath_library_path}"
 	append lang_link_flags " -lquadmath"
     }
-    unset quadmath_library_path
 } else {
     if { [check_no_compiler_messages has_libquadmath executable {
              int main() {return 0;}
@@ -112,7 +115,9 @@ unset offload_target
 if { $blddir != "" } {
     unset lang_source_re
     unset lang_include_flags
-    unset lang_library_path
+    unset libgfortran_library_path
+    unset libquadmath_library_path
+    unset lang_library_paths
 }
 unset lang_link_flags
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)
  2014-11-04 18:32   ` Mike Stump
                       ` (2 preceding siblings ...)
  2023-05-12  7:26     ` libgomp testsuite: Generalize 'lang_library_path' into a list of 'lang_library_paths' (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
@ 2023-05-12  8:27     ` Thomas Schwinge
  2023-05-12  8:33       ` libgomp testsuite: As appropriate, use the 'gcc', 'g++', 'gfortran' driver [PR91884] (was: libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
  3 siblings, 1 reply; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-12  8:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Tobias Burnus, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]

Hi!

The cleanup is done, now turn ourselves to the changes proper re PR91884
"libgomp testsuite: (not) using a specific driver for C++, Fortran":

On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
> On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>>> No matter whether it's C, C++, or Fortran source code, the libgomp
>>> testsuite always uses (for build-tree testing) gcc/xgcc, or (for
>>> installed testing) GCC_UNDER_TEST.  It doesn't make use of
>>> GXX_UNDER_TEST, GFORTRAN_UNDER_TEST.  To support the latter two
>>> languages' needs, some -l[...] flags are then added via lang_link_flags.
>>> For example, for Fortran this is -lgfortran.  This is, however, not what
>>> would happen if using the gfortran driver to build (which is what a user
>>> would be doing -- which we should replicate as much as possible at least
>>> for installed testing): the gfortran driver also adds -lquadmath, if
>>> applicable.
>>>
>>> Now, I wonder why to re-invent all that in the libgomp testsuite, if the
>>> respective driver already has that knowledge, via spec files, for
>>> example?  (Also, the regular GCC compiler tests, gcc/testsuite/, are
>>> doing the right thing.)  Why is libgomp testsuite implemented this way --
>>> just a legacy of the past, or is there a need for that (that I'm not
>>> seeing)?
>>>
>>> [...]
>>>
>>> Am I on the right track with the following?
>>
>> Nobody commented, which also means nobody disagreed
>
> :-)
>
>> OK to commit all that to trunk?
>
> Ok, thanks.

> Watch for any review points from the libgomp people, they might trickle a few in.  I don’t mean to cut short any review points from them.

After Tobias in his 2019 "PR testsuite/91884 Add -lquadmath if available"
again picked up my idea and parts of my 2014 patches (... but in the end
settled for a "simpler" solution to the problem at hand), my original
proposal also got an ACK from Rainer,
<https://inbox.sourceware.org/ydd36g2jc7a.fsf@CeBiTec.Uni-Bielefeld.DE>.

> Also, please watch for breakage.

Always.  :-)


First, another "no change in behavior" new patch, loosely based
on/extracted out of my earlier work.  I'm posting it separately, but
given that it's in line with my earlier work (just a separate step), I
intend to push it soon, unless there are any objections, of course.
"libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884]"
("..., which is still 'GCC_UNDER_TEST' for all of them"), see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-Have-each-.exp-file-specify-the-co.patch --]
[-- Type: text/x-diff, Size: 6613 bytes --]

From 1b2c8132495435dd4455a1c79e5abbd88073c754 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 10 May 2023 14:43:21 +0200
Subject: [PATCH] libgomp testsuite: Have each '*.exp' file specify the
 compiler to use [PR91884]

..., which is still 'GCC_UNDER_TEST' for all of them; no change in behavior.

	PR testsuite/91884
	libgomp/
	* testsuite/lib/libgomp.exp (libgomp_target_compile): Don't
	specify compiler.
	* testsuite/libgomp.c++/c++.exp (ALWAYS_CFLAGS): Specify compiler.
	* testsuite/libgomp.c/c.exp (ALWAYS_CFLAGS): Likewise.
	* testsuite/libgomp.fortran/fortran.exp (ALWAYS_CFLAGS): Likewise.
	* testsuite/libgomp.graphite/graphite.exp (ALWAYS_CFLAGS):
	Likewise.
	* testsuite/libgomp.oacc-c++/c++.exp (ALWAYS_CFLAGS): Likewise.
	* testsuite/libgomp.oacc-c/c.exp (ALWAYS_CFLAGS): Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp (ALWAYS_CFLAGS):
	Likewise.
---
 libgomp/testsuite/lib/libgomp.exp                  |  5 -----
 libgomp/testsuite/libgomp.c++/c++.exp              | 10 +++++-----
 libgomp/testsuite/libgomp.c/c.exp                  |  2 ++
 libgomp/testsuite/libgomp.fortran/fortran.exp      |  1 +
 libgomp/testsuite/libgomp.graphite/graphite.exp    |  1 +
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         | 10 +++++-----
 libgomp/testsuite/libgomp.oacc-c/c.exp             |  2 ++
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp |  1 +
 8 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 9fea31d8067..48c43e4a136 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -46,10 +46,6 @@ load_file libgomp-test-support.exp
 
 set dg-do-what-default run
 
-#
-# GCC_UNDER_TEST is the compiler under test.
-#
-
 set libgomp_compile_options ""
 
 #
@@ -262,7 +258,6 @@ proc libgomp_target_compile { source dest type options } {
 
     lappend options "additional_flags=[libio_include_flags]"
     lappend options "timeout=[timeout_value]"
-    lappend options "compiler=$GCC_UNDER_TEST"
 
     set options [concat $libgomp_compile_options $options]
 
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 1a1c3ee2225..4110ada7c46 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -16,6 +16,11 @@ if { $blddir != "" } {
     return
 }
 set lang_link_flags "-lstdc++"
+# Switch into C++ mode.  Otherwise, the 'libgomp.c-c++-common/*.c'
+# files would be compiled as C files.
+set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
+set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
 
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
@@ -28,11 +33,6 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
-# Switch into C++ mode.  Otherwise, the libgomp.c-c++-common/*.c
-# files would be compiled as C files.
-set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
-set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
-
 # Gather a list of all tests.
 set tests [lsort [concat \
 		      [find $srcdir/$subdir *.C] \
diff --git a/libgomp/testsuite/libgomp.c/c.exp b/libgomp/testsuite/libgomp.c/c.exp
index 0ee28ed723e..aae282478db 100644
--- a/libgomp/testsuite/libgomp.c/c.exp
+++ b/libgomp/testsuite/libgomp.c/c.exp
@@ -1,6 +1,8 @@
 load_lib libgomp-dg.exp
 load_gcc_lib gcc-dg.exp
 
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
+
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
     set DEFAULT_CFLAGS "-O2"
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index 9295bbae65d..9aeebd3af7c 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -29,6 +29,7 @@ if { $blddir != "" } {
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 }
 set lang_link_flags "-lgfortran -foffload=-lgfortran"
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
 
 # Initialize dg.
 dg-init
diff --git a/libgomp/testsuite/libgomp.graphite/graphite.exp b/libgomp/testsuite/libgomp.graphite/graphite.exp
index ff53a31272c..bc3a82d8804 100644
--- a/libgomp/testsuite/libgomp.graphite/graphite.exp
+++ b/libgomp/testsuite/libgomp.graphite/graphite.exp
@@ -25,6 +25,7 @@ if ![check_effective_target_fgraphite] {
   return
 }
 
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
 # Flags for force-parallel-*.c testcases.
 set PARALLEL_CFLAGS "-ansi -pedantic-errors -O2 \
 -ftree-parallelize-loops=4 -floop-parallelize-all \
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 63d1d7650a2..70fb9da0ef4 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -26,6 +26,11 @@ if { $blddir != "" } {
     return
 }
 set lang_link_flags "-lstdc++"
+# Switch into C++ mode.  Otherwise, the 'libgomp.oacc-c-c++-common/*.c'
+# files would be compiled as C files.
+set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
+set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
 
 # Initialize dg.
 dg-init
@@ -34,11 +39,6 @@ torture-init
 # Turn on OpenACC.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 
-# Switch into C++ mode.  Otherwise, the libgomp.oacc-c-c++-common/*.c
-# files would be compiled as C files.
-set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
-set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
-
 # Gather a list of all tests.
 set tests [lsort [concat \
 		      [find $srcdir/$subdir *.C] \
diff --git a/libgomp/testsuite/libgomp.oacc-c/c.exp b/libgomp/testsuite/libgomp.oacc-c/c.exp
index ca61a82937a..8ca0c81687c 100644
--- a/libgomp/testsuite/libgomp.oacc-c/c.exp
+++ b/libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -15,6 +15,8 @@ proc check_effective_target_c++ { } {
 dg-init
 torture-init
 
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
+
 # Turn on OpenACC.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
 
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index af0a4f7ff31..56dd9485339 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -31,6 +31,7 @@ if { $blddir != "" } {
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 }
 set lang_link_flags "-lgfortran -foffload=-lgfortran"
+lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
 
 # Initialize dg.
 dg-init
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* libgomp testsuite: As appropriate, use the 'gcc', 'g++', 'gfortran' driver [PR91884] (was: libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))
  2023-05-12  8:27     ` libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] " Thomas Schwinge
@ 2023-05-12  8:33       ` Thomas Schwinge
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Schwinge @ 2023-05-12  8:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Mike Stump, Jakub Jelinek, Tobias Burnus, Rainer Orth

[-- Attachment #1: Type: text/plain, Size: 3641 bytes --]

Hi!

On 2023-05-12T10:27:29+0200, I wrote:
> The cleanup is done, now turn ourselves to the changes proper re PR91884
> "libgomp testsuite: (not) using a specific driver for C++, Fortran":
>
> On 2014-11-04T10:31:37-0800, Mike Stump <mikestump@comcast.net> wrote:
>> On Nov 4, 2014, at 4:13 AM, Thomas Schwinge <thomas@codesourcery.com> wrote:
>>> On Wed, 15 Oct 2014 17:46:48 +0200, I wrote:
>>>> No matter whether it's C, C++, or Fortran source code, the libgomp
>>>> testsuite always uses (for build-tree testing) gcc/xgcc, or (for
>>>> installed testing) GCC_UNDER_TEST.  It doesn't make use of
>>>> GXX_UNDER_TEST, GFORTRAN_UNDER_TEST.  To support the latter two
>>>> languages' needs, some -l[...] flags are then added via lang_link_flags.
>>>> For example, for Fortran this is -lgfortran.  This is, however, not what
>>>> would happen if using the gfortran driver to build (which is what a user
>>>> would be doing -- which we should replicate as much as possible at least
>>>> for installed testing): the gfortran driver also adds -lquadmath, if
>>>> applicable.
>>>>
>>>> Now, I wonder why to re-invent all that in the libgomp testsuite, if the
>>>> respective driver already has that knowledge, via spec files, for
>>>> example?  (Also, the regular GCC compiler tests, gcc/testsuite/, are
>>>> doing the right thing.)  Why is libgomp testsuite implemented this way --
>>>> just a legacy of the past, or is there a need for that (that I'm not
>>>> seeing)?
>>>>
>>>> [...]
>>>>
>>>> Am I on the right track with the following?
>>>
>>> Nobody commented, which also means nobody disagreed
>>
>> :-)
>>
>>> OK to commit all that to trunk?
>>
>> Ok, thanks.
>
>> Watch for any review points from the libgomp people, they might trickle a few in.  I don’t mean to cut short any review points from them.
>
> After Tobias in his 2019 "PR testsuite/91884 Add -lquadmath if available"
> again picked up my idea and parts of my 2014 patches (... but in the end
> settled for a "simpler" solution to the problem at hand), my original
> proposal also got an ACK from Rainer,
> <https://inbox.sourceware.org/ydd36g2jc7a.fsf@CeBiTec.Uni-Bielefeld.DE>.
>
>> Also, please watch for breakage.
>
> Always.  :-)
>
>
> First, another "no change in behavior" new patch, loosely based
> on/extracted out of my earlier work.  I'm posting it separately, but
> given that it's in line with my earlier work (just a separate step), I
> intend to push it soon, unless there are any objections, of course.
> "libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884]"
> ("..., which is still 'GCC_UNDER_TEST' for all of them"), see attached.

..., and then finally
"libgomp testsuite: As appropriate, use the 'gcc', 'g++', 'gfortran' driver [PR91884]",
see attached.

    ..., that is, 'GCC_UNDER_TEST', 'GXX_UNDER_TEST', 'GFORTRAN_UNDER_TEST' instead
    of 'GCC_UNDER_TEST' for all of them.  No need anymore for 'gcc -lstdc++ -x c++'
    for C++ code, or 'gcc -lgfortran' plus conditional '-lquadmath' for Fortran
    code.  (Getting rid of explicit '-foffload=-lgfortran' is for another day.)


By the way, all changes (individually) tested in a number of different
configurations: '--enable-languages=[...]', native vs. cross, build-tree
vs. installed testing, etc.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libgomp-testsuite-As-appropriate-use-the-gcc-g-gfort.patch --]
[-- Type: text/x-diff, Size: 13090 bytes --]

From 5324d8fb140c1ab790ea4756983bff203c549ce3 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 10 May 2023 15:01:55 +0200
Subject: [PATCH] libgomp testsuite: As appropriate, use the 'gcc', 'g++',
 'gfortran' driver [PR91884]

..., that is, 'GCC_UNDER_TEST', 'GXX_UNDER_TEST', 'GFORTRAN_UNDER_TEST' instead
of 'GCC_UNDER_TEST' for all of them.  No need anymore for 'gcc -lstdc++ -x c++'
for C++ code, or 'gcc -lgfortran' plus conditional '-lquadmath' for Fortran
code.  (Getting rid of explicit '-foffload=-lgfortran' is for another day.)

	PR testsuite/91884
	libgomp/
	* configure.ac: 'AC_SUBST(CXX)'.
	* configure: Regenerate.
	* Makefile.in: Likewise.
	* testsuite/Makefile.in: Likewise.
	* testsuite/libgomp-site-extra.exp.in (GXX_UNDER_TEST)
	(GFORTRAN_UNDER_TEST): Set.
	* testsuite/lib/libgomp.exp (libgomp_init): Adjust.
	* testsuite/libgomp.c++/c++.exp: Use 'GXX_UNDER_TEST'.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.fortran/fortran.exp: Use
	'GFORTRAN_UNDER_TEST'.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/Makefile.in                           |  1 +
 libgomp/configure                             | 18 ++++++++--
 libgomp/configure.ac                          | 13 ++++++-
 libgomp/testsuite/Makefile.in                 |  1 +
 libgomp/testsuite/lib/libgomp.exp             | 35 ++++++++++++++++++-
 libgomp/testsuite/libgomp-site-extra.exp.in   |  2 ++
 libgomp/testsuite/libgomp.c++/c++.exp         | 22 +-----------
 libgomp/testsuite/libgomp.fortran/fortran.exp | 11 ++----
 libgomp/testsuite/libgomp.oacc-c++/c++.exp    | 22 +-----------
 .../libgomp.oacc-fortran/fortran.exp          | 11 ++----
 10 files changed, 71 insertions(+), 65 deletions(-)

diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 2c81ccacc1d..95585353b4e 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -368,6 +368,7 @@ CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CPU_COUNT = @CPU_COUNT@
+CXX = @CXX@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
diff --git a/libgomp/configure b/libgomp/configure
index fd0e337b578..9c91173015f 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -678,6 +678,7 @@ libtool_VERSION
 ac_ct_FC
 FCFLAGS
 FC
+CXX
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
@@ -11418,7 +11419,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11421 "configure"
+#line 11422 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11524,7 +11525,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11527 "configure"
+#line 11528 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11814,7 +11815,18 @@ fi
 test -f libgfortran.spec || touch libgfortran.spec
 FCFLAGS="$FCFLAGS -L."
 
-# We need gfortran to compile parts of the library
+# We optionally test libgomp C++ support, and for that want to use the proper
+# C++ driver, 'g++' (or 'xg++' for build-tree testing).  Given that build of
+# target libstdc++-v3 depends on target libgomp (see '../Makefile.def'), we
+# cannot make build of target libgomp depend on target libstdc++-v3: circular
+# dependency.  We thus cannot instantiate 'AC_PROG_CXX' here: we'd get
+# '-funconfigured-libstdc++-v3' (see '../configure.ac').  Therefore, just
+# capture 'CXX', and we'll fix this up at 'make check' time (see
+# 'testsuite/lib/libgomp.exp:libgomp_init').
+
+
+# We need 'gfortran' to compile parts of the library, and test libgomp Fortran
+# support.
 # We can't use AC_PROG_FC because it expects a fully working gfortran.
 #AC_PROG_FC(gfortran)
 case `echo $GFORTRAN` in
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index a9b1f3973f7..4d2518d7cb9 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -156,7 +156,18 @@ AM_MAINTAINER_MODE
 test -f libgfortran.spec || touch libgfortran.spec
 FCFLAGS="$FCFLAGS -L."
 
-# We need gfortran to compile parts of the library
+# We optionally test libgomp C++ support, and for that want to use the proper
+# C++ driver, 'g++' (or 'xg++' for build-tree testing).  Given that build of
+# target libstdc++-v3 depends on target libgomp (see '../Makefile.def'), we
+# cannot make build of target libgomp depend on target libstdc++-v3: circular
+# dependency.  We thus cannot instantiate 'AC_PROG_CXX' here: we'd get
+# '-funconfigured-libstdc++-v3' (see '../configure.ac').  Therefore, just
+# capture 'CXX', and we'll fix this up at 'make check' time (see
+# 'testsuite/lib/libgomp.exp:libgomp_init').
+AC_SUBST(CXX)
+
+# We need 'gfortran' to compile parts of the library, and test libgomp Fortran
+# support.
 # We can't use AC_PROG_FC because it expects a fully working gfortran.
 #AC_PROG_FC(gfortran)
 case `echo $GFORTRAN` in
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 7a88f0fe5c6..4e8b21e8b38 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -147,6 +147,7 @@ CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CPU_COUNT = @CPU_COUNT@
+CXX = @CXX@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 48c43e4a136..30d67e4f280 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -66,7 +66,7 @@ proc libgomp_init { args } {
     global ALWAYS_CFLAGS
     global CFLAGS
     global TOOL_EXECUTABLE TOOL_OPTIONS
-    global GCC_UNDER_TEST
+    global GCC_UNDER_TEST GXX_UNDER_TEST GFORTRAN_UNDER_TEST
     global TESTING_IN_BUILD_TREE
     global target_triplet
     global always_ld_library_path
@@ -85,12 +85,45 @@ proc libgomp_init { args } {
       setenv LANG C.ASCII
     }
 
+    if { $blddir != "" } {
+	# Fix up '-funconfigured-libstdc++-v3' in 'GXX_UNDER_TEST' (see
+	# '../../configure.ac').
+	set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
+	if { [file exists $flags_file] } {
+	    set flags [exec sh $flags_file --build-includes]
+	    verbose -log "GXX_UNDER_TEST = $GXX_UNDER_TEST"
+	    set GXX_UNDER_TEST [string map [list \
+	      " -funconfigured-libstdc++-v3 " " $flags " \
+					   ] $GXX_UNDER_TEST]
+	    verbose -log "GXX_UNDER_TEST = $GXX_UNDER_TEST"
+	}
+    }
     if ![info exists GCC_UNDER_TEST] then {
 	if [info exists TOOL_EXECUTABLE] {
 	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
 	} else {
 	    set GCC_UNDER_TEST "[find_gcc]"
 	}
+	# Only if we're guessing 'GCC_UNDER_TEST', we're also going to guess
+	# 'GXX_UNDER_TEST', 'GFORTRAN_UNDER_TEST'.
+	if ![info exists GXX_UNDER_TEST] then {
+	    if [info exists TOOL_EXECUTABLE] {
+		set GXX_UNDER_TEST $TOOL_EXECUTABLE
+	    } else {
+		set GXX_UNDER_TEST "[find_g++]"
+	    }
+	} else {
+	    error "GXX_UNDER_TEST set but not GCC_UNDER_TEST"
+	}
+	if ![info exists GFORTRAN_UNDER_TEST] then {
+	    if [info exists TOOL_EXECUTABLE] {
+		set GFORTRAN_UNDER_TEST $TOOL_EXECUTABLE
+	    } else {
+		set GFORTRAN_UNDER_TEST "[find_gfortran]"
+	    }
+	} else {
+	    error "GFORTRAN_UNDER_TEST set but not GCC_UNDER_TEST"
+	}
     }
 
     if ![info exists tmpdir] {
diff --git a/libgomp/testsuite/libgomp-site-extra.exp.in b/libgomp/testsuite/libgomp-site-extra.exp.in
index c0d26660bad..15407ab1749 100644
--- a/libgomp/testsuite/libgomp-site-extra.exp.in
+++ b/libgomp/testsuite/libgomp-site-extra.exp.in
@@ -1 +1,3 @@
 set GCC_UNDER_TEST {@CC@}
+set GXX_UNDER_TEST {@CXX@}
+set GFORTRAN_UNDER_TEST {@FC@}
diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp
index 4110ada7c46..8b4563b1d0d 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -15,12 +15,7 @@ if { $blddir != "" } {
     verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
 }
-set lang_link_flags "-lstdc++"
-# Switch into C++ mode.  Otherwise, the 'libgomp.c-c++-common/*.c'
-# files would be compiled as C files.
-set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
-set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
-lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
+lappend ALWAYS_CFLAGS "compiler=$GXX_UNDER_TEST"
 
 # If a testcase doesn't have special options, use these.
 if ![info exists DEFAULT_CFLAGS] then {
@@ -45,28 +40,13 @@ if { $blddir != "" } {
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
 
-set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-if { $blddir != ""
-     && [file exists $flags_file] } {
-    set lang_source_re {^.*\.[cC]$}
-    set lang_include_flags [exec sh $flags_file --build-includes]
-}
-
 # Main loop.
 dg-runtest $tests "" $DEFAULT_CFLAGS
 
-# See above.
-set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
-
-if [info exists lang_include_flags] then {
-    unset lang_source_re
-    unset lang_include_flags
-}
 if { $blddir != "" } {
     unset libstdc++_library_path
     unset lang_library_paths
 }
-unset lang_link_flags
 
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index 9aeebd3af7c..e69656bce23 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -28,8 +28,8 @@ if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 }
-set lang_link_flags "-lgfortran -foffload=-lgfortran"
-lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
+set lang_link_flags "-foffload=-lgfortran"
+lappend ALWAYS_CFLAGS "compiler=$GFORTRAN_UNDER_TEST"
 
 # Initialize dg.
 dg-init
@@ -46,13 +46,6 @@ if { $blddir != "" } {
 
     if { $libquadmath_library_path != "" } {
 	append ld_library_path ":${blddir}/${libquadmath_library_path}"
-	append lang_link_flags " -lquadmath"
-    }
-} else {
-    if { [check_no_compiler_messages has_libquadmath executable {
-             int main() {return 0;}
-          } "-lgfortran -lquadmath"] } then {
-	append lang_link_flags " -lquadmath"
     }
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 70fb9da0ef4..79df401c99a 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -25,12 +25,7 @@ if { $blddir != "" } {
     verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
     return
 }
-set lang_link_flags "-lstdc++"
-# Switch into C++ mode.  Otherwise, the 'libgomp.oacc-c-c++-common/*.c'
-# files would be compiled as C files.
-set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
-set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
-lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
+lappend ALWAYS_CFLAGS "compiler=$GXX_UNDER_TEST"
 
 # Initialize dg.
 dg-init
@@ -51,13 +46,6 @@ if { $blddir != "" } {
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
 set_ld_library_path_env_vars
 
-set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
-if { $blddir != ""
-     && [file exists $flags_file] } {
-    set lang_source_re {^.*\.[cC]$}
-    set lang_include_flags [exec sh $flags_file --build-includes]
-}
-
 # Test with all available offload targets, and with offloading disabled.
 foreach offload_target [concat [split $offload_targets ","] "disable"] {
     global openacc_device_type
@@ -132,18 +120,10 @@ foreach offload_target [concat [split $offload_targets ","] "disable"] {
 }
 unset offload_target
 
-# See above.
-set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
-
-if [info exists lang_include_flags] then {
-    unset lang_source_re
-    unset lang_include_flags
-}
 if { $blddir != "" } {
     unset libstdc++_library_path
     unset lang_library_paths
 }
-unset lang_link_flags
 
 # All done.
 torture-finish
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index 56dd9485339..2e8aa2285fb 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -30,8 +30,8 @@ if { $blddir != "" } {
     set lang_source_re {^.*\.[fF](|90|95|03|08)$}
     set lang_include_flags "-fintrinsic-modules-path=${blddir}"
 }
-set lang_link_flags "-lgfortran -foffload=-lgfortran"
-lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST"
+set lang_link_flags "-foffload=-lgfortran"
+lappend ALWAYS_CFLAGS "compiler=$GFORTRAN_UNDER_TEST"
 
 # Initialize dg.
 dg-init
@@ -49,13 +49,6 @@ if { $blddir != "" } {
 
     if { $libquadmath_library_path != "" } {
 	append ld_library_path ":${blddir}/${libquadmath_library_path}"
-	append lang_link_flags " -lquadmath"
-    }
-} else {
-    if { [check_no_compiler_messages has_libquadmath executable {
-             int main() {return 0;}
-          } "-lgfortran -lquadmath"] } then {
-	append lang_link_flags " -lquadmath"
     }
 }
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-05-12  8:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-15 15:52 libgomp testsuite: (not) using a specific driver for C++, Fortran? Thomas Schwinge
2014-11-04 12:14 ` Thomas Schwinge
2014-11-04 18:32   ` Mike Stump
2023-05-09 12:36     ` libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
2023-05-09 12:39       ` libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
2023-05-09 12:41         ` libgomp testsuite: Use 'lang_test_file_found' instead of 'lang_test_file' (was: libgomp testsuite: Only use 'blddir' if set (was: libgomp C++ testsuite: Don't compute 'blddir' twice (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))) Thomas Schwinge
2023-05-09 12:54     ` libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
2023-05-09 12:59       ` libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge
2023-05-09 13:05         ` libgomp testsuite: Get rid of 'lang_test_file_found' (was: libgomp C++, Fortran testsuites: Resolve 'lang_test_file_found' first (was: libgomp testsuite: Localize 'lang_[...]' etc. (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?))) Thomas Schwinge
2023-05-12  7:26     ` libgomp testsuite: Generalize 'lang_library_path' into a list of 'lang_library_paths' (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?) Thomas Schwinge
2023-05-12  8:27     ` libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] " Thomas Schwinge
2023-05-12  8:33       ` libgomp testsuite: As appropriate, use the 'gcc', 'g++', 'gfortran' driver [PR91884] (was: libgomp testsuite: Have each '*.exp' file specify the compiler to use [PR91884] (was: libgomp testsuite: (not) using a specific driver for C++, Fortran?)) Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).