[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2024-01-02 Thread acoplan at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #24 from Alex Coplan  ---
Thanks a lot for the fix!

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-29 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED
   Target Milestone|--- |14.0

--- Comment #23 from anlauf at gcc dot gnu.org ---
The issue should be fixed in gcc-14, and the changed behavior of -save-temps
documented.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-28 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #22 from GCC Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:2cb93e6686e4af5725d8c919cf19f535a7f3aa33

commit r14-6857-g2cb93e6686e4af5725d8c919cf19f535a7f3aa33
Author: Rimvydas Jasinskas 
Date:   Sat Dec 23 18:59:09 2023 +

Fortran: Add Developer Options mini-section to documentation

Separate out -fdump-* options to the new section.  Sort by option name.

While there, document -save-temps intermediates.

gcc/fortran/ChangeLog:

PR fortran/81615
* invoke.texi: Add Developer Options section.  Move '-fdump-*'
to it.  Add small examples about changed '-save-temps' behavior.

Signed-off-by: Rimvydas Jasinskas 

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #21 from GCC Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:ba615557a4c698d27042a5fe058ea6e721a03b12

commit r14-6758-gba615557a4c698d27042a5fe058ea6e721a03b12
Author: Rimvydas Jasinskas 
Date:   Wed Dec 20 03:39:33 2023 +

Fortran: Use non conflicting file extensions for intermediates [PR81615]

gcc/ChangeLog:

* doc/invoke.texi: Document the new file extensions

gcc/fortran/ChangeLog:

PR fortran/81615
* lang-specs.h (F951_CPP_OPTIONS): Do not hardcode ".f90" extension
(F951_CPP_EXTENSION): Use .fi/.fii for fixed/free form sources
* options.cc (form_from_filename): Handle the new extensions

Signed-off-by: Rimvydas Jasinskas 

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-19 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #20 from anlauf at gcc dot gnu.org ---
(In reply to Jerry DeLisle from comment #19)
> (In reply to anlauf from comment #18)
> > (In reply to Alex Coplan from comment #17)
> > > Just a ping: it would be nice if this could be fixed, I'm currently trying
> > > to debug/reduce a miscompiled benchmark which has *.f90 source files but
> > > -save-temps isn't useful due to this issue.
> > 
> > The patch in comment#16 seems to work and looks good to me, but it appears
> > to never have been submitted for review.
> > 
> > One could also add a mini-section in invoke.texi by borrowing from
> > gcc/doc/invoke.texi (-> Developer Options) and add a minimal example
> > for -save-temps in the context of gfortran use.
> 
> It seems simple. Shall we post the patch to make sure we dont get any
> broader objections? If none, then we commit.

I'd say let's first give Rimvydas a chance to complete the patch with
a commit message, and to submit to the ML.  He's the author, and he has
submitted patches which he properly signed-off.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-19 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

Jerry DeLisle  changed:

   What|Removed |Added

 CC||jvdelisle at gcc dot gnu.org

--- Comment #19 from Jerry DeLisle  ---
(In reply to anlauf from comment #18)
> (In reply to Alex Coplan from comment #17)
> > Just a ping: it would be nice if this could be fixed, I'm currently trying
> > to debug/reduce a miscompiled benchmark which has *.f90 source files but
> > -save-temps isn't useful due to this issue.
> 
> The patch in comment#16 seems to work and looks good to me, but it appears
> to never have been submitted for review.
> 
> One could also add a mini-section in invoke.texi by borrowing from
> gcc/doc/invoke.texi (-> Developer Options) and add a minimal example
> for -save-temps in the context of gfortran use.

It seems simple. Shall we post the patch to make sure we dont get any broader
objections? If none, then we commit.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-19 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org

--- Comment #18 from anlauf at gcc dot gnu.org ---
(In reply to Alex Coplan from comment #17)
> Just a ping: it would be nice if this could be fixed, I'm currently trying
> to debug/reduce a miscompiled benchmark which has *.f90 source files but
> -save-temps isn't useful due to this issue.

The patch in comment#16 seems to work and looks good to me, but it appears
to never have been submitted for review.

One could also add a mini-section in invoke.texi by borrowing from
gcc/doc/invoke.texi (-> Developer Options) and add a minimal example
for -save-temps in the context of gfortran use.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2023-12-19 Thread acoplan at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

Alex Coplan  changed:

   What|Removed |Added

 CC||acoplan at gcc dot gnu.org

--- Comment #17 from Alex Coplan  ---
Just a ping: it would be nice if this could be fixed, I'm currently trying to
debug/reduce a miscompiled benchmark which has *.f90 source files but
-save-temps isn't useful due to this issue.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-11 Thread rimvydas.jas at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

Rimvydas (RJ)  changed:

   What|Removed |Added

 CC||rimvydas.jas at gmail dot com

--- Comment #16 from Rimvydas (RJ)  ---
Created attachment 54063
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54063=edit
rename intermediate extensions to .fi or .fii

Emitting intermediate files using plain foo.f90 form is a very annoying issue
when trying to modernize archaic codebases to be used in current projects and
it really helps when intermediate files could be saved without disturbing used
native build system habitat.  Consider the following:
$ cat bar.F
       SUBROUTINEABINIT PART 2( ARGU
     x                          MENT)
       E N D S   U   B   R   O   U   T   I   N  E
$ gfortran --save-temps -c bar.F
$ gfortran -c bar.s
$ gfortran -c bar.f90
bar.F:1:8:

    1 |        SUBROUTINEABINIT PART 2( ARGU
      |        1
Error: Unclassifiable statement at (1)

This shows that intermediate Fortran source produced cannot be used again
because of fixed/free form differences while assembly file is fine.  There are
N+K build system variants that do crazy and wonderful things like
filtering/substituting flags, redirecting STDERR/STDOUT for cleaner warning
messages, silently moving sources and objects with strange rules, hiding
compilation lines in python scripts, substituting symbol names in assembly
files and even substituting names in source code on the fly to solve symbol
conflicts between contrib codebases using sed(1) or heavy cpp(1).  So sometimes
it is simply easier to modify the compiler and recompile (after all it does not
take long for gcc).
Attached is a simple diff variant that uses F77/F90+ to emit .fi/.fii
intermediate source files accordingly (inspired by what ObjC/ObjC++ do with
intermediates .mi/.mii files).  Such small change really helped to
double/triple crosscheck very complicated project with mixed F77/F90 using
sometimes crazy cpp(1) macros for the "hooks".  Using .fii extension for all
sources of .F90/.F95/.F03/.F08/.Fyz seems like a logical solution.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-09 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #15 from Steve Kargl  ---
On Sat, Dec 10, 2022 at 01:47:44AM +, barrowes at alum dot mit.edu wrote:
> 
> Thanks for engaging, and thanks for the suggestion. I might be able to do this
> over the winter. Could you give me a hint as to where to look. Which files.
> 

I suspect that you should start by understand gcc/fortran/lang-specs.h.
That's where most of the the filename suffixes are defined.  In particular,
this chuck of code

/* Identical to gcc.cc (cpp_options), but omitting %(cpp_unique_options)
   and -fpch-preprocess on -save-temps.  */
#define CPP_ONLY_OPTIONS"%1 %{m*} %{f*} %{g*:%{!g0:%{g*} \
 %{!fno-working-directory:-fworking-directory}}} \
 %{std*} %{W**} %{w} \
 %{O*} %{undef}"

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-09 Thread barrowes at alum dot mit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #14 from Ben Barrowes  ---
Thanks for engaging, and thanks for the suggestion. I might be able to do this
over the winter. Could you give me a hint as to where to look. Which files.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-09 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Severity|normal  |enhancement
   Priority|P3  |P5

--- Comment #13 from kargl at gcc dot gnu.org ---
(In reply to Ben Barrowes from comment #12)

> Can gfortran be modified to have the option to do this as well?

Sure, gfortran can be modified.  The nontrivial part is that there are very few
active contributors to gfortran.  I suspect your patch would be much
appreciated.


Until then, you can modify your Makefile with very minor changes to stuff
intermediate files into subdirectories.

% ls
Makefilea1.f90  b1.f90  c1.f90  d1.f90
% cat Makefile 
FC = gfortran11
PP = preprocessed/
FF = -c -cpp -save-temps -dumpdir ${PP}
IN = f90
NAMES = a1 b1 c1 d1

all:
mkdir -p ${PP}
.for i in ${NAMES}
${FC} ${FF} $i.${IN}
.endfor

clean:
@rm -rf ${PP} *.o

% make
mkdir -p preprocessed/
gfortran11 -c -cpp -save-temps -dumpdir preprocessed/ a1.f90
gfortran11 -c -cpp -save-temps -dumpdir preprocessed/ b1.f90
gfortran11 -c -cpp -save-temps -dumpdir preprocessed/ c1.f90
gfortran11 -c -cpp -save-temps -dumpdir preprocessed/ d1.f90
% ls
Makefilea1.ob1.oc1.od1.o
a1.f90  b1.f90  c1.f90  d1.f90  preprocessed/
% ls preprocessed/
a1.f90  a1.sb1.f90  b1.sc1.f90  c1.sd1.f90  d1.s

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-09 Thread barrowes at alum dot mit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #12 from Ben Barrowes  ---
I use these intermediate files during the software analysis process, but then
delete them later. They are useful for me to have.

When I am given a makefile, it is often 1000's loc. I am not sure I want to go
in and modify it such as you suggest below and tell the customer it is for
their own good. I'd rather be able to set a couple of switches to the
preprocessor and get what I want.

gfortran already allows to create a *.d file in each directory for each file.
Is that poor software design as well? And when gfortran files are preprocessed
all into a *.f90 file, except when they are not (see Thomas's email below), is
that poor software design?

ifort allows for the creation of these intermediate preprocessed files,
creating *.i and *.i90 files.

IBM XL allows this as well using the -d switch:
https://www.ibm.com/docs/en/xl-fortran-aix/16.1.0?topic=preprocessor-passing-fortran-files-through-c
And the intermediate filename becomes Ffilename.f*

Can gfortran be modified to have the option to do this as well?

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #11 from Steve Kargl  ---
On Fri, Dec 09, 2022 at 01:50:56AM +, barrowes at alum dot mit.edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615
> 
> --- Comment #10 from Ben Barrowes  ---
> The reason the stdout redirection doesn't work for me is because
> I want to save these preprocessed files during a "make" session.
> When I make, thousands of fotran files are preprocessed and compiled.
> How do I save the stdout from each one into its own directory?
> 

% cat > a1.f90
subroutine foo
end subroutine foo
% cp a1.f90 b1.f90
% cp a1.f90 c1.f90
% cp a1.f90 d1.f90
% cat Makefile
FC = gfortran11
FF = -cpp -E
IN = f90
OUT = txt

NAMES = a1 b1 c1 d1

all:
.for i in ${NAMES}
${FC} ${FF} $i.${IN} > $i.${OUT}
.endfor
% make 
gfortran11 -cpp -E a1.f90 > a1.txt
gfortran11 -cpp -E b1.f90 > b1.txt
gfortran11 -cpp -E c1.f90 > c1.txt
gfortran11 -cpp -E d1.f90 > d1.txt
% ls
Makefilea1.txt  b1.txt  c1.txt  d1.txt
a1.f90  b1.f90  c1.f90  d1.f90

The preprocessed files appear in the same directory with its source
source file.  It's trivial matter to have preprocess stuffed into
its own directory.

PS: Having to preprocess thousands of Fortran files into individual
directories seems to be poor software design.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread barrowes at alum dot mit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #10 from Ben Barrowes  ---
The reason the stdout redirection doesn't work for me is because I want to save
these preprocessed files during a "make" session. When I make, thousands of
fotran files are preprocessed and compiled. How do I save the stdout from each
one into its own directory?

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #9 from kargl at gcc dot gnu.org ---
(In reply to Ben Barrowes from comment #8)
> Maybe *.fpp ?

We already have too many extensions for Fortran.
How about simply redirecting stdout

gfortran -cpp -E file.f90 > preprocessed.f90

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread barrowes at alum dot mit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #8 from Ben Barrowes  ---
Maybe *.fpp ?

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #7 from Jakub Jelinek  ---
*.i would be definitely wrong, that is for preprocessed C (*.ii is for
preprocessed C++, *.mi for preprocessed ObjC, etc.).

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread barrowes at alum dot mit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #6 from Ben Barrowes  ---
There are many cases where people do not use a capital "F", but still have
preprocessor directives in the code. In these cases, no proprocessed file is
written out right now, AFAIK.

So perhaps as you suggest we could add a new suffix to the old filename. Then
test1.f would become test.f.i and test1.f90 would also become test1.f.i, etc.
Having this one rule would be a concise solution and have a guaranteed output
in all cases.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek  ---
If you use test.F90 extension, -save-temps will produce test.f90 with
preprocessed source, that is how it should behave.
Now, for *.F or *.F08 etc. extensions it still creates *.f90, I'd say it should
create
*.f, *.f08 etc. instead.  And finally for the -cpp case where the source
contains an extension that is meant for files that don't need preprocessing,
either we could use a temporary filename, or say append suffix to the filename
instead of removing its suffix and appending a new extension.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2022-12-08 Thread barrowes at alum dot mit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #4 from Ben Barrowes  ---
It has been a while.

Is there any way to save the temporary preprocessed files in gfortran?

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2017-07-31 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

Thomas Koenig  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #3 from Thomas Koenig  ---
I agree that the current handling of *.f90 and *.f with
-cpp and -save-temps is undocumented and partially broken.

Consider creating a *.f90 file from a *.f file:

$ cat foo.f
  programme main
  end
$ gfortran -cpp -save-temps foo.f
$ cat foo.f90
# 1 "foo.f"
# 1 ""
# 1 ""
# 1 "foo.f"
  programme main
  end
$ gfortran foo.f90 
foo.f90:1:13:

 # 1 "foo.f"
 1
Fehler: Ungültige Form der PROGRAM-Anweisung bei (1)

Here, we generate a fixed-form program source with an
extension that is usually an indicator of fixed form.

One possibility would be to disable -save-temps together
with -cpp when the source file is *.f or *.f90 (or *.f03).

Creating *.f90 from *.F90 is also dangerous on Windows systems.

I think creating *.i and *.i90 files, respectively, would be
a better option. ifort does so, so there is at least some
precedent.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2017-07-31 Thread barrowes at alum dot mit.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

--- Comment #2 from Ben Barrowes  ---
Then how does one get a preprocessed/savetemp file from an existing *.f90 file?

In the case of C, preprocessed and temp files have different extensions and are
thus easily identified after compiling. For gfortran,
preprocessing/saveingtemps of *.f files produces *.f90 files which is
confusing, and preprocessing/savetemps of *.f90 files produces no output.

Gfortran needs to produce preprocessed/savetemps that have unique and easily
identifiable extensions. If not *.i and *.i90, then something else like *.t and
*.t90 or similar.

[Bug fortran/81615] save-temps and gfortran produces *.f90 files instead of *.i or *i90 files

2017-07-31 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81615

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2017-07-31
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres  ---
> I was under the impression that I would get a test0.i file since the only
> documentation of using -save-temps I can find comes from the gcc docs:
> https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#index-save-temps

Which says

 Store the usual “temporary” intermediate files permanently.

> which mentions *.i files in their example.

because the compiled file is a C file. The *.i (*.ii) files are C (C++ files),
thus cannot (shall not) be produced by gfortran.

As noticed in comment 0, -save-temps generates a preprocessed *.f90 if it does
not already exists. Note that INCLUDE statements are ignored.

IMO this PR should be closed as INVALID or WONTFIX.