我正在尝试构建gcc-5.3和binutils-2.26。我这样做了:
mkdir gcc; cd gcc
wget http://path/to/gcc-5.3.0.tar.bz2
wget http://path/to/binutils-2.26.tar.bz2
tar xf gcc-5.3.0.tar.bz2
tar xf binutils-2.26.tar.bz2
cd gcc-5.3.0
contrib/download_prerequisites
for file in ../binutils-2.26/*; do ln -s "${file}"; done
cd ..
mkdir build
mkdir dist
cd build
../gcc-5.3.0/configure --prefix=/home/teamcity/gcc/dist --disable-multilib --with-system-zlib --enable-languages=c,c++,fortran --program-suffix=-mine
make
这似乎可以构建第一阶段的可执行文件; prev-gas
,prev-gcc
,prev-ld
都包含可信的可执行文件。但下一阶段失败了:
Configuring stage 2 in ./intl
configure: loading cache ./config.cache
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for x86_64-unknown-linux-gnu-gcc... /home/teamcity/gcc/build/./prev-gcc/xgcc -B/home/teamcity/gcc/build/./prev-gcc/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/lib/ -isystem /home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/include -isystem /home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/sys-include -L/home/teamcity/gcc/build/./ld
checking for C compiler default output file name...
configure: error: in `/home/teamcity/gcc/build/intl':
configure: error: C compiler cannot create executables
See `config.log' for more details.
config.log的相关位似乎是这样的:
configure:2978: checking for C compiler default output file name
configure:3000: /home/teamcity/gcc/build/./prev-gcc/xgcc -B/home/teamcity/gcc/build/./prev-gcc/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unkn
own-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/lib/ -isystem /home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/include -isystem /home/teamcity/gcc/dist/x86_64-unknown-l
inux-gnu/sys-include -L/home/teamcity/gcc/build/./ld -g -O2 -gtoggle -static-libstdc++ -static-libgcc conftest.c >&5
/home/teamcity/gcc/build/./prev-gcc/as: 106: exec: /home/teamcity/gcc/build/./gas/as-new: not found
这看起来像prev-gcc一样,期望找到gas/as-new
,实际上它是prev-gas/as-new
。
是否有一些解决方法? ln -s prev-gas gas
只是安全吗?我希望以后会引起问题。是不是可以一起构建这两个版本的gcc和binutils?
答案 0 :(得分:0)
这是我在Ubuntu 14.04 Azure VM上自行尝试后编辑的答案。
以下方法对我有用:
/root/objdir/../gcc-5.3.0/configure --prefix=/opt/gcc-5.3.0
--enable-languages=c,c++ --disable-multilib --with-ld=/opt/gcc-5.3.0/bin/ld --with-as=/opt/gcc-5.3.0/bin/as
在构建目录中配置gcc-5.3.0,假设gcc-5.3.0和构建目录objdir
是相同的
水平。make
构建目录中make install
后跟objdir
。验证新构建的ld
使用的gcc
是否是新binutils中的/opt/gcc-5.3.0/bin/gcc -print-prog-name=ld
:
/opt/gcc-5.3.0/bin/ld
在这个例子中输出应该是:
ld
另一项测试:在我的案例/usr/bin/ld
中重命名系统ld
;新建的gcc应该仍然有效。
当然,这适用于as
和-print-prog-name=...
。
将AS和LD环境变量设置为指向binutils包中新构建的二进制文件不起作用:--with-ld
仍然显示默认工具,删除/重命名默认工具导致gcc失败。
因此,实现此目的的最佳方法是首先构建binutils,然后使用--with-as
和configure
选项<div class="container">
<div class="col-md-10">
<div class="inner-addon right-addon">
<i class="glyphicon glyphicon-search"></i>
<input type="text" class="form-control" placeholder="Search" />
</div>
</div>
</div>
。如果您还想确保使用新构建的binutils来构建GCC,您可能希望在系统提供的工具之前将它们放在PATH中,或者您甚至可以重命名系统提供的工具以使它们远离图片。
感谢您查看另一个邮件列表以验证构建GCC和binutils一起工作除非从源代码控制中提取,否则我认为在使用下载的tarball时该选项不适用。总的来说,这是一项有趣的练习。