无法在mac os X上为MIPS交叉编译器构建binutils

时间:2015-01-22 16:22:34

标签: mips osx-yosemite binutils

我正在尝试在Mac OS X Yosemite上构建MIPS交叉编译器。

我在下面的网站上提到并一步一步地进行了操作。

http://www.theairportwiki.com/index.php/Building_a_cross_compile_of_GCC_for_MIPS_on_OS_X

[配置和构建'binutils'] 的步骤中,

当我键入'$ sudo make all 2>& 1 |时终端上的tee make.log'

我收到来自终端的错误消息,如下所示。

M-PEC:binutils-build M-PEC$ sudo make all 2>&1 | tee make.log
tee: make.log: Permission denied
make[3]: Nothing to be done for `all'.
rm -f stamp-h1
/bin/sh ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
test -f config.h || (rm -f stamp-h1 && /Applications/Xcode.app/Contents/Developer/usr/bin/make stamp-h1)
Making info in doc
make[3]: Nothing to be done for `info'.
Making info in po
make[3]: Nothing to be done for `info'.
make[3]: Nothing to be done for `info-am'.
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in doc
make[4]: Nothing to be done for `all'.
Making all in po
make[4]: Nothing to be done for `all'.
/bin/sh ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.24/bfd -I. -I../../binutils-2.24/bfd -I../../binutils-2.24/bfd/../include  -DHAVE_bfd_elf32_bigmips_vec -DHAVE_bfd_elf32_littlemips_vec -DHAVE_bfd_elf64_bigmips_vec -DHAVE_bfd_elf64_littlemips_vec -DHAVE_bfd_elf64_little_generic_vec -DHAVE_bfd_elf64_big_generic_vec -DHAVE_bfd_elf32_little_generic_vec -DHAVE_bfd_elf32_big_generic_vec -I./../intl -DBINDIR='"/opt/cross/gcc-mips/bin"'  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT elfxx-mips.lo -MD -MP -MF .deps/elfxx-mips.Tpo -c -o elfxx-mips.lo ../../binutils-2.24/bfd/elfxx-mips.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.24/bfd -I. -I../../binutils-2.24/bfd -I../../binutils-2.24/bfd/../include -DHAVE_bfd_elf32_bigmips_vec -DHAVE_bfd_elf32_littlemips_vec -DHAVE_bfd_elf64_bigmips_vec -DHAVE_bfd_elf64_littlemips_vec -DHAVE_bfd_elf64_little_generic_vec -DHAVE_bfd_elf64_big_generic_vec -DHAVE_bfd_elf32_little_generic_vec -DHAVE_bfd_elf32_big_generic_vec -I./../intl -DBINDIR=\"/opt/cross/gcc-mips/bin\" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT elfxx-mips.lo -MD -MP -MF .deps/elfxx-mips.Tpo -c ../../binutils-2.24/bfd/elfxx-mips.c -o elfxx-mips.o
../../binutils-2.24/bfd/elfxx-mips.c:2132:1: error: unused function 'got_ofst_reloc_p' [-Werror,-Wunused-function]
got_ofst_reloc_p (unsigned int r_type)
^
../../binutils-2.24/bfd/elfxx-mips.c:2138:1: error: unused function 'got_hi16_reloc_p' [-Werror,-Wunused-function]
got_hi16_reloc_p (unsigned int r_type)
^
2 errors generated.
make[4]: *** [elfxx-mips.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-bfd] Error 2
make: *** [all] Error 2

如果有人可以解决此问题,请帮助我。

2 个答案:

答案 0 :(得分:0)

Yosemite默认使用CLANG / LLVM,而不是gcc。不确定这种组合是否比GCC更挑剔,但它似乎抱怨一些无害的东西。总的来说,我觉得比必要的更挑剔。

因为makefile中包含选项-Werror,所以这会导致编译失败。我从ld / Makefile,binutils / Makefile,gas / Makefile和bfd / Makefile中删除了-Werror,因为还有其他警告被提升为错误。

我最喜欢抱怨:来自readelf.c的fputc(“”+ n,...);这是不好的形式,当然,但技术上是正确的。然而这个警告/错误:

../../../ binutils-2013.11 / binutils / readelf.c:9322:20:错误:将“int”添加到       string不会附加到字符串[-Werror,-Wstring-plus-int]

不是很有用。

答案 1 :(得分:0)

您需要为CLANG添加更多编译器选项:export CFLAGS="-Wno-error=deprecated-declarations -Wno-error=unused-function -Wno-error=unused-const-variable"

你也可以像http://wiki.osdev.org/User:Max/Building_a_GCC_4.9_cross_compiler_on_OS_X_Mavericks中那样提供编译器选项--disable-werror../binutils-2.24/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-werror

即使您成功获取目标文件,由于ar,您在链接时也会出错。请参阅此帖:Building a cross compile of binutils on OS X Yosemite