This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49149] New: Dependency autogeneration with `-M` rendered useless by requiring .mod files
- From: "zbeekman at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 May 2011 20:06:34 +0000
- Subject: [Bug fortran/49149] New: Dependency autogeneration with `-M` rendered useless by requiring .mod files
- Auto-submitted: auto-generated
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.