This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libgomp][testsuite] PR testsuite/91884 Add -lquadmath if available


I have also an alternative version:

* For in-build-dir test runs, do as with previous patch, i.e. add "-lquadmath" to the "xgcc" call if the directory is available.

* For installed-compiler test runs, the new patch uses GFORTRAN_UNDER_TEST / GXX_UNDER_TEST (It would also use them with in-build-dir runs, but nothing sets them. I have kept the -lgfortran / -lstdg++ flags, though they could be left out iff {GXX,GFORTRAN}_UNDER_TEST is set. Presumably, some linker will complain if they appear twice.)

Additionally, that patch does some cleanup:
* Only set always_ld_library_path to a blddir path if it exists
* Replace lang_test_file by (existing) lang_test_file_found in lib/*exp

That patch is based on a subset of patches posted by Thomas, extended to the new files; cf. PR or:

https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01374.html
https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00157.html


What do you think? Which variant do you prefer? If the other one, should some cleanup of this patch be used nonetheless?

Tobias

PS: Tested with an in-build-tree test run and an installed-compiler test run on x86_64_gnu-linux

	2019-...  Tobias Burnus  <tobias@codesourcery.com>
		  Thomas Schwinge  <thomas@codesourcery.com>

	libgomp/
	* testsuite/lib/libgomp.exp (libgomp_init): Add blddir to
	always_ld_library_path only if it exists.
	(libgomp_target_compile): Use lang_test_file_found instead of
	lang_test_file and don't set compiler=.
	* testsuite/libgomp.c/c.exp: Do not set lang_test_file;
	unset lang_test_file_found for initialization.
	* testsuite/libgomp.hsa.c/c.exp: Likewise.
	* testsuite/libgomp.oacc-c/c.exp: Likewise.
	* testsuite/libgomp.graphite/graphite.exp: Likewise.
	* testsuite/libgomp.c++/c++.exp: Likewise; use GXX_UNDER_TEST
	if available.
	* testsuite/libgomp.oacc-c++/c++.exp: Likewise.
	* testsuite/libgomp.fortran/fortran.exp: Likewise but using
	GFORTRAN_UNDER_TEST.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 14d9b5f1305..86c97239579 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -63,7 +63,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
@@ -115,7 +114,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 "."
 
     # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
     # Intel MIC offloading testing.
@@ -166,6 +165,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"
@@ -241,13 +242,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.
@@ -268,7 +269,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 f4884e2ffa7..cab9e4eac2e 100644
--- a/libgomp/testsuite/libgomp.c++/c++.exp
+++ b/libgomp/testsuite/libgomp.c++/c++.exp
@@ -5,8 +5,10 @@ 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 [info exists lang_test_file_found] then {
+    unset lang_test_file_found
+}
 if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
@@ -27,30 +29,28 @@ 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"] {
-        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"
 }
 
 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 [concat \
 			  [find $srcdir/$subdir *.C] \
@@ -65,7 +65,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 ""
diff --git a/libgomp/testsuite/libgomp.c/c.exp b/libgomp/testsuite/libgomp.c/c.exp
index 31bdd5795dc..f4e662a15c3 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
@@ -20,6 +20,8 @@ if ![info exists DEFAULT_CFLAGS] then {
 # Initialize dg.
 dg-init
 
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
diff --git a/libgomp/testsuite/libgomp.fortran/fortran.exp b/libgomp/testsuite/libgomp.fortran/fortran.exp
index d848ed4d47f..2fb3eeb9ba9 100644
--- a/libgomp/testsuite/libgomp.fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.fortran/fortran.exp
@@ -11,7 +11,9 @@ set lang_link_flags	"-lgfortran -foffload=-lgfortran"
 if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
-set lang_test_file_found 0
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
+}
 set quadmath_library_path "../libquadmath/.libs"
 
 
@@ -26,24 +28,25 @@ 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"
 }
 
 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}]]
 
@@ -54,6 +57,7 @@ if { $lang_test_file_found } {
 	    # 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}"
 	}
diff --git a/libgomp/testsuite/libgomp.graphite/graphite.exp b/libgomp/testsuite/libgomp.graphite/graphite.exp
index 9d9de02abbe..32f5cca9e12 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
@@ -45,6 +45,8 @@ set PARALLEL_CFLAGS "-ansi -pedantic-errors -O2 \
 # Initialize `dg'.
 dg-init
 
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
diff --git a/libgomp/testsuite/libgomp.hsa.c/c.exp b/libgomp/testsuite/libgomp.hsa.c/c.exp
index 4614192320a..4a2e2eabd4e 100644
--- a/libgomp/testsuite/libgomp.hsa.c/c.exp
+++ b/libgomp/testsuite/libgomp.hsa.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
@@ -15,6 +15,8 @@ load_gcc_lib gcc-dg.exp
 # Initialize dg.
 dg-init
 
+lappend libgomp_compile_options "compiler=$GCC_UNDER_TEST"
+
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index dcefa792ca4..a2cd39ce8c9 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -15,8 +15,10 @@ 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 [info exists lang_test_file_found] then {
+    unset lang_test_file_found
+}
 if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
@@ -33,30 +35,28 @@ 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"] {
-        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"
 }
 
 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 [concat \
 			  [find $srcdir/$subdir *.C] \
@@ -71,7 +71,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 ""
diff --git a/libgomp/testsuite/libgomp.oacc-c/c.exp b/libgomp/testsuite/libgomp.oacc-c/c.exp
index 55cd40f1e99..2a907e1ccd0 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
@@ -26,6 +26,8 @@ proc check_effective_target_c++ { } {
 dg-init
 torture-init
 
+lappend libgomp_compile_options "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 af25a22a522..0d9705f80cd 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -13,7 +13,9 @@ set lang_link_flags	"-lgfortran -foffload=-lgfortran"
 if [info exists lang_include_flags] then {
     unset lang_include_flags
 }
-set lang_test_file_found 0
+if [info exists lang_test_file_found] then {
+    unset lang_test_file_found
+}
 set quadmath_library_path "../libquadmath/.libs"
 
 
@@ -28,24 +30,25 @@ 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"
 }
 
 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}]]
 
@@ -56,6 +59,7 @@ if { $lang_test_file_found } {
 	    # 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}"
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]