linux - g77 版本 3.2 使用选项 -finit-local-zero 创建大目标文件

标签 linux fortran legacy numeric g77

我正在使用需要 g77 3.2.x 才能成功编译和运行的遗留 + 学术 + 数字 fortran-77 代码......我在 Red Hat Linux 9 上使用 i386 的编译器

其中一个 fortran-77 文件定义了一个子例程,其中包含许多实数、整数和 double 组作为局部变量……如果我使用以下方式编译它:

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

它生成一个大小约为 10kB 的目标文件......但是如下:

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

生成一个大小为 14MB 的目标文件

我尝试strip'ing 目标文件,但大小变化不大

代码中有几十个这样的文件,可执行二进制文件的大小最终达到 200MB

知道发生了什么事吗?更重要的是,我该怎么做才能恢复到更合理的对象/二进制大小?

P.S.:当我将 200MB 的二进制文件压缩成 tar.gz 时,tarball 不到 1MB ...意味着 200MB 可能充满了 0 之类的东西(我可以在十六进制编辑器中打开它,但我感觉现在太懒了)

P.S.: 下面给出了编译器的详细信息(使用 g77 的 -v 标志)

$ 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-zero 相同)但我不能使用它们(使代码在最新的编译器版本中产生正确的结果本身就是一个项目)...我需要 -finit-local-zero 标志(没有它代码会挂起)

编辑 2:我进行了十六进制转储,果然 99% 的文件由零组成!

最佳答案

来自在线文档:

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?

答:是的。听起来你已经回答了你自己的问题:)

关于linux - g77 版本 3.2 使用选项 -finit-local-zero 创建大目标文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8948990/

相关文章:

linux - 在 bash 脚本中获取包含下划线的文件

ios - 在 arm7s 上运行 arm7 内置的 iOS SDK

linux - 强制 sh shell 使用外部函数而不是内置函数

python - 在 VS Code 中为 python 脚本运行终端?

fortran - Fortran FORMAT 是在编译时还是执行时完成的?

fortran - 为什么递归 IO 操作会出现 Fortran 运行时错误?

multithreading - 共享内存计算机上的多线程 FFTW 3.1.2

macos - OS X Yosemite 更新后 IntelliJ 无法启动

ios - 我的应用程序应该支持什么版本的 iOS?

linux - spring-security-core 2.0.3 spring-aop 2.0.8 导致 NoSuchMethodError