g77 版本 3.2 使用选项 -finit-local-zero 创建大型目标文件
我正在使用遗留+学术+数字的fortran-77代码,需要g77 3.2.x才能成功编译和运行...我在Red Hat Linux 9上使用该编译器用于i386
其中一个fortran-77 files 定义了一个子例程,其中包含大量实数、整数和双精度数组作为局部变量...如果我使用以下方式编译它:
$ g77 -c thefile.F -o thefile.o
它会生成一个大小约为 10kB 的目标文件...但以下内容:
$ g77 -finit-local-zero -c thefile.F -o thefile.o
生成一个大小为 14MB 的目标文件
我尝试strip
'ing 目标文件,但
代码中的几十个这样的文件的大小并没有改变太多,并且可执行二进制文件的大小最终
为 200MB 知道发生了什么吗?更重要的是我该怎么做才能恢复到更合理的对象/二进制大小?
PS:当我将 200MB 二进制文件压缩到 tar.gz 中时,tarball 低于 1 MB ...意味着 200MB 可能是充满 0 或其他东西(我可以在十六进制编辑器中打开它,但我现在感觉太懒了)
PS:下面给出了编译器详细信息(使用 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% 由零组成!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自在线文档:
http://gcc.gnu.org/ onlinedocs/gfortran/Code-Gen-Options.html
答:是的。听起来你已经回答了你自己的问题:)
From the on-line documentation:
http://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html
A: Yup. Sounds like you've answered your own question :)