public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Make test_compiler_info in Fortran tests test the Fortran compiler
@ 2020-10-26 16:28 Gary Benson
  2020-10-26 16:28 ` [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++" Gary Benson
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Gary Benson @ 2020-10-26 16:28 UTC (permalink / raw)
  To: gdb-patches

Hi all,

Most (all?) of GDB's Fortran tests operate differently depending on
which compiler is used, but the functions to determine which compiler
is in use check the C compiler, not the Fortran compiler.  Running
"make check" with non-matched C and Fortran compilers results in the
failure of most or all of GDB's tests built from Fortran sources.
This series fixes.

Checked on Fedora 32 x86_64, with GNU Fortran as the Fortran compiler,
and with GCC and Clang as the C compiler.  Is this ok to commit?

Cheers,
Gary

--
Gary Benson - he / him / his
Principal Software Engineer, Red Hat


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

* [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++"
  2020-10-26 16:28 Make test_compiler_info in Fortran tests test the Fortran compiler Gary Benson
@ 2020-10-26 16:28 ` Gary Benson
  2020-10-30 19:00   ` Tom Tromey
  2020-10-26 16:28 ` [PATCH 2/3] Recognise GNU Fortran as GCC Gary Benson
  2020-10-26 16:28 ` [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler Gary Benson
  2 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2020-10-26 16:28 UTC (permalink / raw)
  To: gdb-patches

get_compiler_info accepts an optional argument to allow tests to
specify that the C++ compiler should be used.  This commit extends
get_compiler_info to use the respective Fortran compiler if "f77"
or "f90" are specified.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_compile): Add additional_flags=-cpp
	when getting compiler info for Fortran sources.
---
 gdb/testsuite/ChangeLog   | 5 +++++
 gdb/testsuite/lib/gdb.exp | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 999fd63..b6cf7fc 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3923,6 +3923,12 @@ proc gdb_compile {source dest type options} {
 	set new_options [universal_compile_options]
     }
 
+    if {[lsearch -exact $options getting_compiler_info] != -1
+	&& ([lsearch -exact $options f77] != -1
+	    || [lsearch -exact $options f90] != -1)} {
+	lappend new_options "additional_flags=-cpp"
+    }
+
     # Some C/C++ testcases unconditionally pass -Wno-foo as additional
     # options to disable some warning.  That is OK with GCC, because
     # by design, GCC accepts any -Wno-foo option, even if it doesn't
-- 
1.8.3.1


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

* [PATCH 2/3] Recognise GNU Fortran as GCC
  2020-10-26 16:28 Make test_compiler_info in Fortran tests test the Fortran compiler Gary Benson
  2020-10-26 16:28 ` [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++" Gary Benson
@ 2020-10-26 16:28 ` Gary Benson
  2020-10-30 19:00   ` Tom Tromey
  2020-10-26 16:28 ` [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler Gary Benson
  2 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2020-10-26 16:28 UTC (permalink / raw)
  To: gdb-patches

GNU Fortran's preprocessor defines __GFORTRAN__ where GCC defines
__GNUC__.  This commit causes the testsuite's get_compiler_info
method to identify GNU Fortran as though it were C-language GCC.

gdb/testsuite/ChangeLog:

	* lib/compiler.c: Recognise gfortran as GCC.
---
 gdb/testsuite/ChangeLog      | 4 ++++
 gdb/testsuite/lib/compiler.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/compiler.c b/gdb/testsuite/lib/compiler.c
index b149f57..b947b66 100644
--- a/gdb/testsuite/lib/compiler.c
+++ b/gdb/testsuite/lib/compiler.c
@@ -34,7 +34,7 @@
 
 set compiler_info "unknown"
 
-#if defined (__GNUC__)
+#if defined (__GNUC__) || defined (__GFORTRAN__)
 #if defined (__GNUC_PATCHLEVEL__)
 /* Only GCC versions >= 3.0 define the __GNUC_PATCHLEVEL__ macro.  */
 set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__} -]
-- 
1.8.3.1


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

* [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler
  2020-10-26 16:28 Make test_compiler_info in Fortran tests test the Fortran compiler Gary Benson
  2020-10-26 16:28 ` [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++" Gary Benson
  2020-10-26 16:28 ` [PATCH 2/3] Recognise GNU Fortran as GCC Gary Benson
@ 2020-10-26 16:28 ` Gary Benson
  2020-10-30 19:02   ` Tom Tromey
  2 siblings, 1 reply; 9+ messages in thread
From: Gary Benson @ 2020-10-26 16:28 UTC (permalink / raw)
  To: gdb-patches

This commit adds a call to get_compiler_info within lib/fortran.exp
with "f90" as the language argument.  This causes calls to
test_compiler_info in all tests that include lib/fortran.exp to
refer to the Fortran compiler rather than the C compiler.

gdb/testsuite/ChangeLog:

	* lib/fortran.exp: Call get_compiler_info on inclusion to make
	calls to test_compiler_info check the Fortran compiler.
---
 gdb/testsuite/ChangeLog       | 5 +++++
 gdb/testsuite/lib/fortran.exp | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 97e442b..ca018bf 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -15,6 +15,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# Ensure calls to test_compiler_info will use the Fortran compiler.
+get_compiler_info f90
+
 # Auxiliary function to set the language to fortran.
 # The result is 1 (true) for success, 0 (false) for failure.
 
-- 
1.8.3.1


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

* Re: [PATCH 2/3] Recognise GNU Fortran as GCC
  2020-10-26 16:28 ` [PATCH 2/3] Recognise GNU Fortran as GCC Gary Benson
@ 2020-10-30 19:00   ` Tom Tromey
  2020-11-02 14:38     ` Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2020-10-30 19:00 UTC (permalink / raw)
  To: Gary Benson via Gdb-patches

Gary> -#if defined (__GNUC__)
Gary> +#if defined (__GNUC__) || defined (__GFORTRAN__)
Gary>  #if defined (__GNUC_PATCHLEVEL__)
Gary>  /* Only GCC versions >= 3.0 define the __GNUC_PATCHLEVEL__ macro.  */
Gary>  set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__} -]

The body of this #if uses __GNUC__ to populate "compiler_info"... but if
it isn't defined, won't this yield something incorrect?

Tom

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

* Re: [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++"
  2020-10-26 16:28 ` [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++" Gary Benson
@ 2020-10-30 19:00   ` Tom Tromey
  0 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2020-10-30 19:00 UTC (permalink / raw)
  To: Gary Benson via Gdb-patches

Gary> gdb/testsuite/ChangeLog:

Gary> 	* lib/gdb.exp (gdb_compile): Add additional_flags=-cpp
Gary> 	when getting compiler info for Fortran sources.

This looks good to me.  Thank you.

Tom

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

* Re: [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler
  2020-10-26 16:28 ` [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler Gary Benson
@ 2020-10-30 19:02   ` Tom Tromey
  2020-11-02 14:42     ` Gary Benson
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2020-10-30 19:02 UTC (permalink / raw)
  To: Gary Benson via Gdb-patches

>>>>> "Gary" == Gary Benson via Gdb-patches <gdb-patches@sourceware.org> writes:

Gary> This commit adds a call to get_compiler_info within lib/fortran.exp
Gary> with "f90" as the language argument.  This causes calls to
Gary> test_compiler_info in all tests that include lib/fortran.exp to
Gary> refer to the Fortran compiler rather than the C compiler.

This seems strange to me.  If simply loading fortran.exp changes
test_compiler_info, then it seems like a runtest that includes multiple
tests could have different results depending on the order:

runtest fortran-test.exp cxx-test.exp
-vs-
runtest cxx-test.exp fortran-test.exp

Tom

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

* Re: [PATCH 2/3] Recognise GNU Fortran as GCC
  2020-10-30 19:00   ` Tom Tromey
@ 2020-11-02 14:38     ` Gary Benson
  0 siblings, 0 replies; 9+ messages in thread
From: Gary Benson @ 2020-11-02 14:38 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Gary Benson via Gdb-patches

Tom Tromey wrote:
> Gary> -#if defined (__GNUC__)
> Gary> +#if defined (__GNUC__) || defined (__GFORTRAN__)
> Gary>  #if defined (__GNUC_PATCHLEVEL__)
> Gary>  /* Only GCC versions >= 3.0 define the __GNUC_PATCHLEVEL__ macro.  */
> Gary>  set compiler_info [join {gcc __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__} -]
> 
> The body of this #if uses __GNUC__ to populate "compiler_info"...
> but if it isn't defined, won't this yield something incorrect?

It turns out GNU Fortran *does* define __GNUC__, I must've
confused myself while I was working on this.  So I guess I
can drop this patch from the series--good catch!

Cheers,
Gary

-- 
Gary Benson - he / him / his
Principal Software Engineer, Red Hat


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

* Re: [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler
  2020-10-30 19:02   ` Tom Tromey
@ 2020-11-02 14:42     ` Gary Benson
  0 siblings, 0 replies; 9+ messages in thread
From: Gary Benson @ 2020-11-02 14:42 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Gary Benson via Gdb-patches

Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Gary> This commit adds a call to get_compiler_info within lib/fortran.exp
> Gary> with "f90" as the language argument.  This causes calls to
> Gary> test_compiler_info in all tests that include lib/fortran.exp to
> Gary> refer to the Fortran compiler rather than the C compiler.
> 
> This seems strange to me.  If simply loading fortran.exp changes
> test_compiler_info, then it seems like a runtest that includes multiple
> tests could have different results depending on the order:
> 
> runtest fortran-test.exp cxx-test.exp
> -vs-
> runtest cxx-test.exp fortran-test.exp

Isn't get_compiler_info run once per .exp file?
It seems to be if you run it via "make check",
grep get_compiler_info gdb.log returns hundreds
of results .

Cheers,
Gary

-- 
Gary Benson - he / him / his
Principal Software Engineer, Red Hat


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

end of thread, other threads:[~2020-11-02 14:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 16:28 Make test_compiler_info in Fortran tests test the Fortran compiler Gary Benson
2020-10-26 16:28 ` [PATCH 1/3] Make get_compiler_info accept "f77" and "f90" as well as "c++" Gary Benson
2020-10-30 19:00   ` Tom Tromey
2020-10-26 16:28 ` [PATCH 2/3] Recognise GNU Fortran as GCC Gary Benson
2020-10-30 19:00   ` Tom Tromey
2020-11-02 14:38     ` Gary Benson
2020-10-26 16:28 ` [PATCH 3/3] Ensure calls to test_compiler_info will use the Fortran compiler Gary Benson
2020-10-30 19:02   ` Tom Tromey
2020-11-02 14:42     ` Gary Benson

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