g77 version 3.2 creates large object file with the option -finit-local-zero

348 views Asked by At

I'm working with a legacy + academic + numerical fortran-77 code that requires g77 3.2.x in order to compile and run successfully ... I'm using that compiler on Red Hat Linux 9 for i386

One of those fortran-77 files defines a subroutine with lots of real, integer, and double precision arrays as local variables ... if I compile it using:

$ g77 -c thefile.F -o thefile.o

it produces an object file of size around 10kB ... but the following:

$ g77 -finit-local-zero -c thefile.F -o thefile.o

produces an object file of size 14MB

I tried strip'ing the object file but the size doesn't change much

a couple dozen such files in the code and the executable binary ends up being 200MB in size

Any idea about what's going on? more importantly what can I do to get back to saner object/binary sizes?

P.S.: when I compressed the 200MB binary into tar.gz, the tarball was under 1 MB ... means probably the 200MB is full of 0's or something (I could open it in a hex-editor but i'm feeling too lazy right now)

P.S.: the compiler details are given below (using the -v flag of g77)

$ g77 -v -finit-local-zero -c thefile.F -o thefile.o
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/tradcpp0 -lang-fortran -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=2 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ thefile.F /tmp/ccXXvzMA.f
GNU traditional CPP version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/f771 /tmp/ccXXvzMA.f -quiet -dumpbase thefile.F -version -finit-local-zero -o /tmp/cck0Blw1.s
GNU F77 version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) (i386-redhat-linux)
    compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
 as -V -Qy -o thefile.o /tmp/cck0Blw1.s
GNU assembler version 2.13.90.0.18 (i386-redhat-linux) using BFD version 2.13.90.0.18 20030206

EDIT: newer g77/gfortran versions don't have that problem (object file size stays almost the same with -finit-local-zero) but I can't use them (making the code produce correct results with latest compiler versions would be a project in itself) ... and I need the -finit-local-zero flag (code hangs without it)

EDIT 2: I took a hex dump and sure enough 99% of the file consists of zeros!

1

There are 1 answers

1
paulsm4 On BEST ANSWER

From the on-line documentation:

http://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html

-finit-local-zero
-finit-integer=n
-finit-real=<zero|inf|-inf|nan|snan>
-finit-logical=<true|false>
-finit-character=n
    The -finit-local-zero option instructs the compiler to initialize local INTEGER,
    REAL, and COMPLEX variables to zero, LOGICAL variables to false, and CHARACTER 
    variables to a string of null bytes. Finer-grained initialization options are
    provided by the -finit-integer=n, -finit-real=<zero|inf|-inf|nan|snan> (which 
    also initializes the real and imaginary parts of local COMPLEX variables), 
    -finit-logical=<true|false>, and -finit-character=n (where n is an ASCII 
    character value) options. These options do not initialize

    * allocatable arrays
    * components of derived type variables
    * variables that appear in an EQUIVALENCE statement. 

    (These limitations may be removed in future releases). 

Q: Any idea about what's going on? and what can I do to get back to saner object/binary sizes?

Means probably the 200MB is full of 0's or something?

A: Yup. Sounds like you've answered your own question :)