我正在使用一个遗留+学术+数值fortran-77代码,它需要g77 3.2.x才能成功编译和运行.我正在使用RedHatLinux9上的编译器来实现i386
其中一个fortran-77文件定义了一个子例程,其中包含大量的实、整数和双精度数组作为局部变量.如果我使用以下方法编译它:
$ g77 -c thefile.F -o thefile.o它产生一个大约10 of大小的对象文件..。但以下各点:
$ g77 -finit-local-zero -c thefile.F -o thefile.o生成大小为14 of的对象文件。
我尝试过对对象文件进行strip处理,但是大小变化不大
代码中的几十个这样的文件和可执行的二进制文件最终都是200 up的大小。
知道怎么回事吗?更重要的是,,我能做些什么才能回到更清晰的对象/二进制大小呢?
当我将200 MB的二进制压缩成tar.gz时,tarball在1MB以下.这意味着200 of可能充满了0或其他东西(我可以用十六进制编辑器打开它,但我现在觉得太懒了)。
P.S.:编译器的详细信息如下(使用-v标志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编辑:较新的g77/gfortran版本没有这个问题(对象文件大小与-finit-local-0几乎相同),但我不能使用它们(用最新的编译器版本使代码产生正确的结果本身就是一个项目).我需要-finit本地零标志(没有它的代码挂起)。
编辑2:我采取了一个十六进制转储和确定足够的99%的文件组成的零!
发布于 2012-01-20 23:13:24
从在线文档中:
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). 问:你知道发生了什么事吗?我能做些什么才能回到更清晰的对象/二进制大小呢?
意味着200 or可能装满了0或者什么的?
A:是的。听起来你已经回答了你自己的问题:)
https://stackoverflow.com/questions/8948990
复制相似问题