public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49149] New: Dependency autogeneration with `-M` rendered useless by requiring .mod files
@ 2011-05-24 20:09 zbeekman at gmail dot com
  2011-05-24 22:02 ` [Bug fortran/49149] " kargl at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: zbeekman at gmail dot com @ 2011-05-24 20:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49149

           Summary: Dependency autogeneration with `-M` rendered useless
                    by requiring .mod files
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zbeekman@gmail.com


Here is some fortran code:

MODULE utils
  USE types, ONLY: WP
  IMPLICIT NONE

CONTAINS
  ELEMENTAL FUNCTION initPI() RESULT(PI)
    REAL(WP) :: PI
    PI = ATAN(1.0_WP)*4.0_WP
  END FUNCTION initpi
END MODULE utils

When I run the following command with gfortran 4.6 I get the following error.

$ gfortran -MG -cpp modutils.f90
modutils.f90:2.21:

  USE types, ONLY: WP
                     1
Fatal Error: Can't open module file 'types.mod' for reading at (1): No such
file or directory

This entirely defeats the purpose of having a preprocessor spit out makefile
rules. If I want my dependencies resolved automatically, I should be able to
spit out .d files which are later included in my makefile *in an arbitrary
order.* GENERATION OF MAKEFILE RULES FOR AUTOMATIC DEPENDENCY RESOLUTION MUST
BE ABLE TO BE DONE IN ANY ORDER BY PARSING THE SOURCE. There should not be a
requirement to have .mod files present. These files are part of a separate
source file and contribute zero knowledge to the dependencies of the current
file. The need not be present for preprocessing, or dependency resolution. (But
yes, they are needed for syntax checking.)  With the `-M` feature added to
gfortran one should be able to follow the procedure outlined on the GNUmake
website for automatic dependency generation to build codes with a small set of
pattern rules. See this page for more info.
http://theory.uwinnipeg.ca/localfiles/infofiles/make/make_43.html

If the procedure outlined on that page is attempted, the include statement in
the makefile will cause the makefile to about because the include statement
tries to build the files in arbitrary order (likely ascii collating sequence by
file name). The makefile code listed bellow should work but doesn't because of
the eroneously required .mod files:

FC=ifort
GFC = gfortran

%.o: %.f90 %.d
    $(FC) $(FCFLAGS) $(FPPFLAGS) -c $< -o $@


%.d: %.f90
    $(SHELL) -ec "$(GFC) -M -cpp $(FPPFLAGS) $< | sed '1 s/^/$@ /' > $@"

sources:=$(wildcard *.f90)
depends:=$(patsubst %.f90,%.d,$(wildcard *.f90))

include $(depends)

Dependency resolution is the bane of Fortran developers, and a huge headache.
Being able to implement Makefiles like the one listed above instead of
teadiously writing line after line of dependency resolutions by hand will be a
boon for the Fortran community as a whole. Please make it a priority to look
into this in the near future.

Many thanks, and keep up the great work.


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

end of thread, other threads:[~2015-03-03 21:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-24 20:09 [Bug fortran/49149] New: Dependency autogeneration with `-M` rendered useless by requiring .mod files zbeekman at gmail dot com
2011-05-24 22:02 ` [Bug fortran/49149] " kargl at gcc dot gnu.org
2011-07-24 19:06 ` dfranke at gcc dot gnu.org
2011-08-31 20:06 ` zbeekman at gmail dot com
2011-08-31 20:24 ` zbeekman at gmail dot com
2011-08-31 21:06 ` kargl at gcc dot gnu.org
2011-08-31 22:18 ` zbeekman at gmail dot com
2011-08-31 22:28 ` sgk at troutmask dot apl.washington.edu
2011-08-31 22:46 ` zbeekman at gmail dot com
2011-08-31 23:05 ` zbeekman at gmail dot com
2011-08-31 23:21 ` sgk at troutmask dot apl.washington.edu
2011-09-01  1:14 ` zbeekman at gmail dot com
2011-09-01  1:28 ` zbeekman at gmail dot com
2011-09-03 14:47 ` zbeekman at gmail dot com
2011-11-07 22:52 ` fxcoudert at gcc dot gnu.org
2015-03-03 21:09 ` zbeekman at gmail dot com
2015-03-03 21:20 ` zbeekman at gmail dot com

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