fwhole-program issue
Tobias Burnus
burnus@net-b.de
Wed Jul 4 05:55:00 GMT 2012
Hi,
Manfred Schwarb wrote:
> I'm somewhat puzzled: for me the dead simple program
> # cat wholeprogram1.f
> subroutine wholeprogram1
> print*,"wholeprogram1"
> end
> # cat wholeprogram2.f
> program wholeprogram2
> call wholeprogram1
> end
> does not compile with -fwhole-program
That's not surprising:
gfortran -fwhole-program -c wholeprogram1.f
can optimize "wholeprogram1" away as it is not called in that file.
Recall that -fwhole-program work per translation/compilation unit (TU,
i.e. per file), which is also indicated in the manual:
"-fwhole-program
Assume that the current compilation unit represents the
whole program being compiled. [...]"
Thus, -fwhole-program should either only be used if one has only a
single file (or for the file which contains only the main program). Or
together with link-time optimization (LTO), enabled by "-flto".
Thus, you should add "-flto".
Tobias
More information about the Fortran
mailing list