public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/114922] New: fsyntax-only need the modules
@ 2024-05-02 12:47 axel.ehrich@tu-clausthal.de
  2024-05-02 16:43 ` [Bug fortran/114922] " anlauf at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: axel.ehrich@tu-clausthal.de @ 2024-05-02 12:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114922

            Bug ID: 114922
           Summary: fsyntax-only need the modules
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: axel.ehrich@tu-clausthal.de
  Target Milestone: ---

Created attachment 58087
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58087&action=edit
Short Example for this problem

I encounter the following problem with gfortran: When I try to compile a file
(such as the one attached) with the options -c -fsyntax-only,
that is

"gfortran -c -fsyntax-only syntax-only_test.f90"

I receive the following error message:
------------------------------------------------------
syntax-only_test.f90:2:5:

    2 | use module
      |     1
Fatal Error: Cannot open module file 'module.mod' for reading at (1): No such
file or directory
compilation terminated.
-----------------------------------------------

One purpose of the option "-fsyntax-only" is to create the module files (.mod),
however, without doing the compilation that would require module files. The
observed behaviour appears like a bug in gfortran.

I used 
https://aoterodelaroza.github.io/devnotes/modern-fortran-makefiles/
to look how i can solve the problem with the depends of mod files.

Best regards,
Axel

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

* [Bug fortran/114922] fsyntax-only need the modules
  2024-05-02 12:47 [Bug fortran/114922] New: fsyntax-only need the modules axel.ehrich@tu-clausthal.de
@ 2024-05-02 16:43 ` anlauf at gcc dot gnu.org
  2024-05-02 17:38 ` kargls at comcast dot net
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-02 16:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114922

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from anlauf at gcc dot gnu.org ---
The documentation says:

-fsyntax-only

    Check the code for syntax errors, but do not actually compile it. This will
generate module files for each module present in the code, but no other output
file.


So if you do not provide the needed modules, you should get exactly the same
errors as when compiling without -fsyntax-only.

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

* [Bug fortran/114922] fsyntax-only need the modules
  2024-05-02 12:47 [Bug fortran/114922] New: fsyntax-only need the modules axel.ehrich@tu-clausthal.de
  2024-05-02 16:43 ` [Bug fortran/114922] " anlauf at gcc dot gnu.org
@ 2024-05-02 17:38 ` kargls at comcast dot net
  2024-05-03 10:50 ` axel.ehrich@tu-clausthal.de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargls at comcast dot net @ 2024-05-02 17:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114922

kargls at comcast dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargls at comcast dot net

--- Comment #2 from kargls at comcast dot net ---
While Harald gave one reason, consider the simply program

   use foo, only bar
   x = bar(1.)
   end

gfortran needs information about 'bar'.  Is it an array,
function, or subroutine?

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

* [Bug fortran/114922] fsyntax-only need the modules
  2024-05-02 12:47 [Bug fortran/114922] New: fsyntax-only need the modules axel.ehrich@tu-clausthal.de
  2024-05-02 16:43 ` [Bug fortran/114922] " anlauf at gcc dot gnu.org
  2024-05-02 17:38 ` kargls at comcast dot net
@ 2024-05-03 10:50 ` axel.ehrich@tu-clausthal.de
  2024-05-03 13:38 ` mikael at gcc dot gnu.org
  2024-05-06  5:58 ` axel.ehrich@tu-clausthal.de
  4 siblings, 0 replies; 6+ messages in thread
From: axel.ehrich@tu-clausthal.de @ 2024-05-03 10:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114922

--- Comment #3 from Axel Ehrich <axel.ehrich@tu-clausthal.de> ---
The question is related to the actual purpose of the option -fsyntax only:

In my understanding, the intention of the option -fsyntax-only is to construct
the module files needed to compile the code. A  build process would involve two
steps: Step 1: construct all module files with gfortran -fsyntax only. Step 2:
construct the object files without this option, while relying on the presence
of all module files. (I have found this recipe on the internet and consider it
valuable.)

Alternatively, the purpose of -fsyntax-only could be to save compile time by a
doing quick first check before entering the time consuming parts of the
compilation.  If this syntax check goes so far that it requires the module
files already, the goal mentioned above cannot be reached.

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

* [Bug fortran/114922] fsyntax-only need the modules
  2024-05-02 12:47 [Bug fortran/114922] New: fsyntax-only need the modules axel.ehrich@tu-clausthal.de
                   ` (2 preceding siblings ...)
  2024-05-03 10:50 ` axel.ehrich@tu-clausthal.de
@ 2024-05-03 13:38 ` mikael at gcc dot gnu.org
  2024-05-06  5:58 ` axel.ehrich@tu-clausthal.de
  4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu.org @ 2024-05-03 13:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114922

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Axel Ehrich from comment #3)

> In my understanding, the intention of the option -fsyntax-only is to
> construct the module files needed to compile the code. A  build process
> would involve two steps: Step 1: construct all module files with gfortran
> -fsyntax only. Step 2: construct the object files without this option, while
> relying on the presence of all module files. (I have found this recipe on
> the internet and consider it valuable.)
> 
The normal process is to compile directly the files (without -fsyntax-only) in
the right order, in a single step.  Some people prefer to do it in two steps,
depending on their needs.

> Alternatively, the purpose of -fsyntax-only could be to save compile time by
> a doing quick first check before entering the time consuming parts of the
> compilation. 
Yes, that's the main purpose.

> If this syntax check goes so far that it requires the module
> files already, the goal mentioned above cannot be reached.

Yes, it can.  The files have to be compiled in the right order.

Keep in mind that the compiler processes one file at a time and doesn't have
a global knowledge of all the files together.

Consider this example:
  module m2
    use m1
  end module m2

What symbols should be made available in the module file for m2?
Don't you think that the knowledge of the content of m1 is needed?

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

* [Bug fortran/114922] fsyntax-only need the modules
  2024-05-02 12:47 [Bug fortran/114922] New: fsyntax-only need the modules axel.ehrich@tu-clausthal.de
                   ` (3 preceding siblings ...)
  2024-05-03 13:38 ` mikael at gcc dot gnu.org
@ 2024-05-06  5:58 ` axel.ehrich@tu-clausthal.de
  4 siblings, 0 replies; 6+ messages in thread
From: axel.ehrich@tu-clausthal.de @ 2024-05-06  5:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114922

--- Comment #5 from Axel Ehrich <axel.ehrich@tu-clausthal.de> ---
Thank you for the explanation. This resolves the issue.

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

end of thread, other threads:[~2024-05-06  5:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-02 12:47 [Bug fortran/114922] New: fsyntax-only need the modules axel.ehrich@tu-clausthal.de
2024-05-02 16:43 ` [Bug fortran/114922] " anlauf at gcc dot gnu.org
2024-05-02 17:38 ` kargls at comcast dot net
2024-05-03 10:50 ` axel.ehrich@tu-clausthal.de
2024-05-03 13:38 ` mikael at gcc dot gnu.org
2024-05-06  5:58 ` axel.ehrich@tu-clausthal.de

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