构建 gcc-2.95.3 以在 64 位 Ubuntu 9.10 上使用
更新:我从 http://ftp 获得了 Debian 3.0r2 的副本。 ntct.edu.tw/Linux/ISO/Debian/3.0r2/ 其中包含 gcc 2.95.4,这是完美的。将其安装在 VirtualBox 中,现在一切都正常了。 :)
原文:
我正在尝试构建 gcc 2.95.3 的副本以在我的机器上使用,但我遇到了一段非常困难的时期。
我买了一本我一直在看的书,是 2002 年的。它要求我编译许多示例,看看 C 编译器会生成什么汇编。本书使用gcc 2.95.3。我的系统上的 gcc 是 4.x,更不用说 64 位了,所以生成的程序集看起来几乎与书中的示例完全不同。
我已经尝试了几乎所有方法来使 gcc 2.95.3 在我的机器上运行。我什至使用 VirtualBox 安装了较旧的 32 位 Linux 发行版,但我一生都无法编译它。
目前,在我的机器上,这就是我正在做的事情:
./configure --host=i386-amd-linux-gnu
make
在它滚动几分钟后,它出现了这样的情况:
make[2]: Entering directory `/home/twilson/Downloads/gcc-2.95.3/gcc/ch'
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include parse.c
parse.c: In function ‘require’:
parse.c:326: warning: format not a string literal and no format arguments
parse.c: In function ‘expect’:
parse.c:352: warning: format not a string literal and no format arguments
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include actions.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include except.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include grant.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include lang.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include tree.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include lex.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include decl.c
decl.c: In function ‘start_struct’:
decl.c:4451: error: argument ‘code’ doesn’t match prototype
ch-tree.h:736: error: prototype declaration
make[2]: *** [decl.o] Error 1
make[2]: Leaving directory `/home/twilson/Downloads/gcc-2.95.3/gcc/ch'
make[1]: *** [cc1chill] Error 2
make[1]: Leaving directory `/home/twilson/Downloads/gcc-2.95.3/gcc'
make: *** [all-gcc] Error 2
似乎无论我做什么,它总是会因一个或另一个错误而出错。这是我一直以来最接近的结果(我认为,因为这是不间断运行的最长编译)。
我不是配置或制作方面的专家,也不是旧软件方面的专家。多年来我只做与网络相关的事情,而且我很晚才进入这个较低级别的游戏。
最近有没有人尝试这样做并成功或知道为什么会发生这种情况?
谢谢, 汤姆
UPDATE: I got a copy of Debian 3.0r2 from http://ftp.ntct.edu.tw/Linux/ISO/Debian/3.0r2/
This contains gcc 2.95.4 which is perfect. Installed it in VirtualBox and everything is now right with the world. :)
ORIGINAL:
I'm trying to build a copy of gcc 2.95.3 for use on my machine, and I am having a really difficult time.
I purchased a book that I've been going through and it is from 2002. It wants me to compile many of the examples to see what assembly the C compiler comes up with. The book uses gcc 2.95.3. The gcc on my system is 4.x not to mention 64-bit, so the assembly is generates looks almost NOTHING like that of the examples in the book.
I've tried just about everything to make gcc 2.95.3 work on my machine. I've even installed older 32-bit Linux distros using VirtualBox, but cannot for the life of me get it to compile.
Currently, on my machine here's what I'm doing:
./configure --host=i386-amd-linux-gnu
make
And after it rolls around for a few minutes, it comes up with this:
make[2]: Entering directory `/home/twilson/Downloads/gcc-2.95.3/gcc/ch'
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include parse.c
parse.c: In function ‘require’:
parse.c:326: warning: format not a string literal and no format arguments
parse.c: In function ‘expect’:
parse.c:352: warning: format not a string literal and no format arguments
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include actions.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include except.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include grant.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include lang.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include tree.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include lex.c
gcc -c -DIN_GCC -g -O2 -I. -I.. -I. -I./.. -I./../config -I./../../include decl.c
decl.c: In function ‘start_struct’:
decl.c:4451: error: argument ‘code’ doesn’t match prototype
ch-tree.h:736: error: prototype declaration
make[2]: *** [decl.o] Error 1
make[2]: Leaving directory `/home/twilson/Downloads/gcc-2.95.3/gcc/ch'
make[1]: *** [cc1chill] Error 2
make[1]: Leaving directory `/home/twilson/Downloads/gcc-2.95.3/gcc'
make: *** [all-gcc] Error 2
It seems that no matter what I do it always errors out with one error or another. This is as close as I've been (I assume, since this is the longest the compilation ever ran without stopping).
I am not an expert with configure or make, or with older software. I was only doing web-related stuff for many years and I'm coming into this lower-level game late.
Has anyone tried to do this recently and succeeded or know why this is happening?
Thanks,
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用正确的标志,gcc 将为 32 位系统生成汇编程序。根据代码的复杂性和您阅读汇编程序的经验水平,2.95 和 4.x 的输出可能没有太大差异。如果它可以让您不必修补旧版本的编译器,也许值得考虑。
例如,以下内容将为 i386 CPU 生成汇编代码(在 .s 文件中):
如果这不能满足您的需要,请查看此页面,其中列出了在 64 位上构建 gcc 2.95 所需的步骤位主机。 http://www.trevorpounds.com/blog/?p=111
With the right flags, gcc will emit assembler for a 32-bit system. Depending on the complexity of the code and your level of experience in reading assembler, there may not be much difference between the output from 2.95 and 4.x. Maybe it's worth considering if it saves you from having to patch together an old version of the compiler.
For example, the following will produce assembler code (in a .s file) for i386 CPUs:
If that doesn't do it for you then take a look at this page that lays out the steps you need to build gcc 2.95 on a 64-bit host. http://www.trevorpounds.com/blog/?p=111
嗯,构建这样一个旧版本将是地狱,更不用说,非常困难。我看到几个选项:
使用较旧的 GCC 来尝试构建更旧的 GCC。 (像 3.4.5 这样的东西会有更多的工作运气。
使用 Ubuntu 软件包对于旧版本的 Ubuntu,请使用 Dapper 的 GCC 2.95。安装,只需将其解压到某处(应该非常简单,只需确保以相同的方式安装所有依赖项即可。如果这不起作用,请尝试使用旧 Linux 安装的虚拟机。
Well, building such an old version will be hell, not to mention, very hard. I see several options:
Use an older GCC to try and build the even older GCC. (Something like 3.4.5 would have more luck of working.
Use the Ubuntu package for an older version of Ubuntu, say Dapper's GCC 2.95. If it doesn't install, just unpack it somewhere (should be quite straightforward, just be sure to install all dependencies in the same fashion. If this doesn't work, try a VM with an old linux install.