如何在 Debian chroot 中构建 gcc?

如何在 Debian chroot 中构建 gcc?

我曾经debootstrap设置过一个最小的 Debian 系统(x86):

debootstrap wheezy /var/chroot http://ftp.debian.org/debian/

然后我进入 chroot 并安装了一些软件包:

apt-get install build-essential m4 flex bison libgmp-dev libmpfr-dev

我正在尝试构建 gcc 4.1.3 (不要问为什么)。我配置如下:

./configure --prefix=/usr/local --program-suffix=-4.1.3 --enable-languages=c,c++

它运行了几分钟,然后失败并出现以下错误:

In file included from /usr/include/stdio.h:28,
                 from ../.././gcc/tsystem.h:90,
                 from ../.././gcc/crtstuff.c:68:
/usr/include/features.h:323:26: error: bits/predefs.h: No such file or directory
/usr/include/features.h:356:25: error: sys/cdefs.h: No such file or directory
/usr/include/features.h:388:23: error: gnu/stubs.h: No such file or directory
In file included from ../.././gcc/tsystem.h:90,
                 from ../.././gcc/crtstuff.c:68:
/usr/include/stdio.h:36:25: error: bits/types.h: No such file or directory
In file included from ../.././gcc/tsystem.h:90,
                 from ../.././gcc/crtstuff.c:68:

然而,我构建一个使用stdio.h.所以我可以编译东西,但显然不能编译 gcc。

为了能够构建 gcc,必须对 chroot 进行哪些额外的安装/配置?

答案1

设置后我能够完成构建:

export LIBRARY_PATH=/usr/lib/i386-linux-gnu
export C_INCLUDE_PATH=/usr/include/i386-linux-gnu
export CPLUS_INCLUDE_PATH=/usr/include/i386-linux-gnu

编辑:我现在意识到问题的根源。系统自带的 gcc 知道在/usr/include/i386-linux-gnu.但是,我构建的 gcc 不会在这些目录中搜索。因此构建在 stage2 失败。

看来 gcc 没有任何配置选项可以让你设置头文件和库搜索路径,所以我猜测 gcc-4.1 太旧了(在 Debian 多架构方案出现之前),新版本都知道已经在搜索/usr/include/<target>等等。

相关内容