我正在尝试使用
在OS X 10.9上交叉编译i386-elf-gcc./configure --enable-languages=c,c++,fortran,go,java,objc,obj-c++ \
--enable-stage1-languages=c++ \
--prefix=/usr/local/i386-efi-gcc --target=i386-elf
和
make -j 16
最后我遇到了这样一个错误:
checking for suffix of object files... configure: error: in `/src/gcc-4.9.1/i386-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
Makefile:10818: recipe for target 'configure-target-libgcc' failed
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory '/src/gcc-4.9.1'
Makefile:874: recipe for target 'all' failed
make: *** [all] Error 2
我检查了/src/gcc-4.9.1/i386-elf/libgcc/config.log
:
configure:3580: checking for suffix of object files
configure:3602: /src/gcc-4.9.1/host-x86_64-apple-darwin13.3.0/gcc/xgcc -B/src/gcc-4.9.1/host-x86_64-apple-darwin13.3.0/gcc/ -B/usr/local/i386-efi-gcc/i386-elf/bin/ -B/usr/local/i386-efi-gcc/i386-elf/lib/ -isystem /usr/local/i386-efi-gcc/i386-elf/include -isystem /usr/local/i386-efi-gcc/i386-elf/sys-include -c -g -O2 conftest.c >&5
/src/gcc-4.9.1/host-x86_64-apple-darwin13.3.0/gcc/as: line 106: exec: -o: invalid option
exec: usage: exec [-cl] [-a name] file [redirection ...]
configure:3606: $? = 1
我意识到/src/gcc-4.9.1/host-x86_64-apple-darwin13.3.0/gcc/as
可能有问题。以下是我在开头看到的内容:
# Invoke as, ld or nm from the build tree.
ORIGINAL_AS_FOR_TARGET=""
ORIGINAL_LD_FOR_TARGET=""
ORIGINAL_LD_BFD_FOR_TARGET="/.bfd"
ORIGINAL_LD_GOLD_FOR_TARGET="/.gold"
ORIGINAL_PLUGIN_LD_FOR_TARGET=""
ORIGINAL_NM_FOR_TARGET=""
显然,ORIGINAL_AS_FOR_TARGET
不应为空。由于as
脚本是由gcc-4.9.1/gcc/configure
生成的,因此我检查了gcc-4.9.1/host-x86_64-apple-darwin13.3.0/gcc/config.log
并找到了:
configure:21319: checking for i386-elf-as
configure:21352: result: no
configure:21368: checking what assembler to use
configure:21409: result:
configure:21483: checking for i386-elf-ld
configure:21516: result: no
configure:21549: checking whether we are using gold
configure:21558: result: no
configure:21569: checking what linker to use
configure:21603: result:
configure:21631: checking for i386-elf-nm
configure:21664: result: no
configure:21672: checking what nm to use
configure:21680: result:
configure:21711: checking for i386-elf-objdump
configure:21744: result: no
configure:21752: checking what objdump to use
configure:21759: result: not found
configure:21781: checking for readelf
configure:21799: found /usr/local/bin/readelf
configure:21811: result: /usr/local/bin/readelf
configure:21822: checking what readelf to use
configure:21832: result: /usr/local/bin/readelf
我想也许这里的事情出了问题。
为什么会出现错误?如何成功交叉编译gcc?
答案 0 :(得分:1)
编译gcc的一个主要先决条件是首先为同一个目标编译相应的binutils包。你可以在这里获得最新的binutils:
http://ftp.gnu.org/gnu/binutils/
首先使用相同的目标前缀编译并安装binutils包(并确保它将为您提供i386-elf-as,i386-elf-ld等)。然后使用gcc构建从一个干净的平板开始(=删除构建失败的目录并再次提取文件)。运行./configure时,只需确保binutils二进制文件位于PATH中。
希望这会让你前进。