[binutils-gdb] gdb/testsuite: only add -J option when compiling with gfortran

Andrew Burgess aburgess@sourceware.org
Wed Jun 2 09:22:55 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2d4211150abba189c4fcd2f7cf0290161474631

commit f2d4211150abba189c4fcd2f7cf0290161474631
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Wed Jun 2 09:50:29 2021 +0100

    gdb/testsuite: only add -J option when compiling with gfortran
    
    We currently make use of the -J option to gfortran in order that
    compiled modules should be placed in the correct output directory.
    Obviously different compilers, e.g. flang, will have different options
    to achieve the same result.
    
    This commit makes it so we only add the -J flag when using a gcc
    based (i.e. gfortran) compiler.
    
    I had a look through the flang help page and tried a few likely
    looking options, but couldn't find anything that seemed to do the same
    thing, so, for now, I'm only adding an extra option when compiling
    with gfortran.
    
    This does mean that any compiler other than gfortran might run into
    problems if running the testsuite in parallel due to modules of the
    same name all being written to the same directory, and so possibly
    overwriting each other.
    
    gdb/testsuite/ChangeLog:
    
            * lib/gdb.exp (gdb_compile): Only add the -J option when using a
            gcc based Fortran compiler, for example, flang does not support
            this option.

Diff:
---
 gdb/testsuite/ChangeLog   | 6 ++++++
 gdb/testsuite/lib/gdb.exp | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3b7169638e7..f34812d5580 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2021-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* lib/gdb.exp (gdb_compile): Only add the -J option when using a
+	gcc based Fortran compiler, for example, flang does not support
+	this option.
+
 2021-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* lib/fortran.exp (fortran_int8): Escape '*' in pattern.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 36a5fd4feb7..f6686e19162 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4098,7 +4098,9 @@ proc gdb_compile {source dest type options} {
 	    || [lsearch -exact $options f90] != -1 } {
 	# Fortran compile.
 	set mod_path [standard_output_file ""]
-	lappend new_options "additional_flags=-J${mod_path}"
+	if [test_compiler_info "gcc-*"] {
+	    lappend new_options "additional_flags=-J${mod_path}"
+	}
     }
 
     set shlib_found 0


More information about the Gdb-cvs mailing list