如何构建旧版本的 gcc?

如何构建旧版本的 gcc?

我使用的是 Ubuntu 14.04.2 32 位平台,并且安装了 gcc 4.8.4。我想构建旧版本的 gcc (2.95.3) 来编译旧版本的 linux 内核。我试着遵循这个gcc-2.95.3和这个gcc-2.95.3-64(虽然后者指导如何在 64 位主机中构建 32 位 gcc,它似乎很有帮助,但不起作用)指南,但我未能构建它。有没有办法在我当前的发行版中编译它?

编辑:这是我使用的错误消息./configure --prefix=/usr/local/gcc --sysconfdir=/etcmake bootstrap如果我不使用引导程序标记我在达到以下错误之前遇到更多错误。以下错误信息来自gcc-2.95.1

Making info file `cpp.info' from `./cpp.texi'.
./cpp.texi:2041: Unknown command `sam'.
./cpp.texi:2041: Misplaced {.
./cpp.texi:2041: Misplaced }.
./cpp.texi:2041: Unmatched }.
./cpp.texi:361: Node `Include Operation''s Next field not pointed back to.
./cpp.texi:421: This node (`Once-Only') is the one with the bad `Prev'.
./cpp.texi:815: Next reference to nonexistent node `Nonstandard Predefined'.
./cpp.texi:802: `Standar Predefiined' has an Up field of `Predefined', but `Predefined' has no menu item for `Standar Predefiined'.
./cpp.texi:998: Prev reference to nonexistent node `Standard Predefined'.
./cpp.texi:802: `Nonstanard Preddefined' has an Up field of `Predefined', but `Predefined' has no menu item for `Nonstanard Preddefined'.
./cpp.texi:1366: Next reference to nonexistent node `Macro Parentheses'.
./cpp.texi:1398: Node `Macro Prenthesees''s Next field not pointed back to.
./cpp.texi:1475: This node (`SwallowSemicoloon') is the one with the bad `Prev'.
./cpp.texi:1398: Node `Macro Prenthesees's Prev field not pointed back to.
./cpp.texi:1366: This node (`Misnesting') has the bad Next.
./cpp.texi:1342: `Macro Prenthesees' has an Up field of `Macro Pitfalls', but `Macro Pitfalls' has no menu item for `Macro Prenthesees'.
./cpp.texi:1475: Node `SwallowSemicoloon''s Next field not pointed back to.
./cpp.texi:1538: This node (`Side Effects') is the one with the bad `Prev'.
./cpp.texi:1342: `SwallowSemicoloon' has an Up field of `Macro Pitfalls', but `Macro Pitfalls' has no menu item for `SwallowSemicoloon'.
./cpp.texi:1342: `Argumen Prescann' has an Up field of `Macro Pitfalls', but `Macro Pitfalls' has no menu item for `Argumen Prescann'.
./cpp.texi:1812: Next reference to nonexistent node `Newline in Argss'.
./cpp.texi:1850: Node `Newlines in Args's Prev field not pointed back to.
./cpp.texi:1812: This node (`Cascaded Macros') has the bad Next.
./cpp.texi:1911: Node `Conditinal Usess' missing Up field.
./cpp.texi:1944: Next reference to nonexistent node `Deleted ode'.
./cpp.texi:1944: Prev reference to nonexistent node `Conditioal Usess'.
./cpp.texi:1959: Next reference to nonexistent node `#else Diective.'.
./cpp.texi:2018: Node `#else Directive' missing Up field.
./cpp.texi:2039: Node `#elif Directive' missing Up field.
./cpp.texi:2086: Node `Deleted Code' missing Up field.
./cpp.texi:2107: Node `Conditionals-Macros' missing Up field.
./cpp.texi:2208: Next reference to nonexistent node `#error Directive'.
./cpp.texi:2208: Prev reference to nonexistent node `Conditioals-Maccros'.
./cpp.texi:2338: Node `#error irectivee' missing Up field.
./cpp.texi:71: `Other Drectivess' has an Up field of `Top', but `Top' has no menu item for `Other Drectivess'.
./cpp.texi:2435: Cross reference to nonexistent node `Standard Predefined'.
./cpp.texi:2360: Cross reference to nonexistent node `Nonstandard Predefined'.
./cpp.texi:1956: Menu reference to nonexistent node `#elif Diective.'.
./cpp.texi:1955: Menu reference to nonexistent node `#else Diective.'.
./cpp.texi:1908: Menu reference to nonexistent node `#error Directive'.
./cpp.texi:1906: Menu reference to nonexistent node `Conditioals-Maccros'.
./cpp.texi:1905: Menu reference to nonexistent node `Deleted ode'.
./cpp.texi:1903: Menu reference to nonexistent node `Conditioal Usess'.
./cpp.texi:1360: Menu reference to nonexistent node `Argument Prescan'.
./cpp.texi:1355: Menu reference to nonexistent node `Swallow Semicolon'.
./cpp.texi:1353: Menu reference to nonexistent node `Macro Parentheses'.
./cpp.texi:1148: Cross reference to nonexistent node `Swallow Semicolon'.
./cpp.texi:812: Menu reference to nonexistent node `Nonstandard Predefined'.
./cpp.texi:811: Menu reference to nonexistent node `Standard Predefined'.
./cpp.texi:128: Menu reference to nonexistent node `Other Directives'.
./cpp.texi:815: warning: unreferenced node `Standar Predefiined'.
./cpp.texi:998: warning: unreferenced node `Nonstanard Preddefined'.
./cpp.texi:1398: warning: unreferenced node `Macro Prenthesees'.
./cpp.texi:1911: warning: unreferenced node `Conditinal Usess'.
./cpp.texi:2018: warning: unreferenced node `#else Directive'.
./cpp.texi:2039: warning: unreferenced node `#elif Directive'.
./cpp.texi:2086: warning: unreferenced node `Deleted Code'.
./cpp.texi:2338: warning: unreferenced node `#error irectivee'.
makeinfo: Removing output file `cpp.info' due to errors; use --force to preserve.
make[2]: *** [cpp.info] Error 2

答案1

您将很难在现代系统上构建如此旧版本的 gcc...您复制的错误来自texinfo,它不再与 gcc 2.95 中包含的文档兼容。

您可以尝试直接安装二进制文件http://snapshot.debian.org/package/gcc-2.95/2.95.4.ds15-27/;安装cpp-2.95gcc-2.95从那里将为您提供 C 支持,而无需触及您现有的 gcc 安装。要获得 C++ 支持,您需要g++-2.95和库;我还没有检查它们在现代系统上的安装效果如何。

答案2

我刚刚使用以下步骤在 Ubuntu 14.04 上安装了 gcc-3.4.6 和 gcc-2.95.3教程。我在这里发布这些步骤没有多大意义,因为您还需要从该页面下载一些补丁文件。

对于这两个编译,我必须添加-D_FORTIFY_SOURCE=0CFLAGSgcc 构建目录及其包含其他 Makefile 的子文件夹中的所有 Makefile 中。

我需要首先安装 gcc-3.4.6,然后用它来构建 gcc-2.95.3。为此,您需要CC=/opt/x86_64/gcc/gcc-3.4.6/bin/gcc在 gcc-2.95.3 的 Makefile 中进行设置。

此外,我还必须将以下文件从源目录复制glibc-2.10.1gcc-2.95.3/glibc-workaround/教程页面上的命令创建的目录:

  • bits/libc-lock.h
  • sys/param.h
  • _G_config.h

要修复上述问题中的错误消息:我注释掉了编译或安装的 gcc-2.95.3 Makefiles 的所有部分texinfocpp.info.

答案3

您需要从源代码编译旧版本的 gcc,并使用前缀选项为其指定不同的目标目录。

./configure --prefix=/usr/local/gcc

我认为 gcc 配置将允许您使用现有的 /etc。

./configure --prefix=/usr/local/gcc --sysconfdir=/etc

相关内容