在BeagleBone Black上构建gcc失败

12

问题

我正在尝试在BeagleBone Black上构建交叉编译器,以便从ARM编译到x86。这样做的目的是使用我手头拥有的低功耗BeagleBone Black作为构建服务器。它已经可以通过mingw-w64编译Windows,但我还需要它来编译适用于Linux x86系统的代码。

然而,当我尝试在BeagleBone Black上编译gcc时,出现以下错误:

/bin/bash ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../gcc-4.6.3/gmp -D__GMP_WITHIN_GMP    -g -O2 -c -o mpn/div_qr_1n_pi1.lo mpn/div_qr_1n_pi1.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../gcc-4.6.3/gmp -D__GMP_WITHIN_GMP -g -O2 -c mpn/div_qr_1n_pi1.c -o mpn/div_qr_1n_pi1.o
/tmp/cckCXg2a.s: Assembler messages:
/tmp/cckCXg2a.s:194: Error: thumb conditional instruction should be in IT block -- `movcc r4,#0'
/tmp/cckCXg2a.s:195: Error: thumb conditional instruction should be in IT block -- `movcs r4,#-1'
/tmp/cckCXg2a.s:452: Error: thumb conditional instruction should be in IT block -- `movcc r4,#0'
/tmp/cckCXg2a.s:453: Error: thumb conditional instruction should be in IT block -- `movcs r4,#-1'
make[4]: *** [mpn/div_qr_1n_pi1.lo] Error 1
make[4]: Leaving directory `$HOME/builds/gcc/gmp'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `$HOME/builds/gcc/gmp'
make[2]: *** [all] Error 2
make[2]: Leaving directory `$HOME/builds/gcc/gmp'
make[1]: *** [all-gmp] Error 2
make[1]: Leaving directory `$HOME/builds/gcc'
make: *** [all] Error 2

我知道拇指与ARM有关,但我对为什么它不起作用感到困惑。我做错了什么?

以下是我尝试创建交叉编译器所采取的步骤。这是我第一次尝试制作交叉编译器,因此大部分信息都来自于几个网页和手册。


采取的步骤

为了创建交叉编译器,我下载了以下软件包:

  1. binutils-2.24
  2. gmp-6.0.0a
  3. mpfr-3.1.2
  4. mpc-1.0.2
  5. gcc-4.6.3
  6. linux-3.15.3
  7. glibc-2.19

所有这些包都被解压缩到$HOME目录中。

然后,我设置了以下bash环境变量。

export PREFIX="$HOME/cross_compiler/x86_64"
export TARGET="x86_64-linux-gnu"
export PATH="$PREFIX/bin:$PATH"

之后,我开始配置、构建和安装binutils。

mkdir -p $HOME/builds/binutils
cd $HOME/builds/binutils
../../binutils-2.24/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-werror
make
make install

Binutils构建过程中没有出现任何错误,所以我开始构建gcc。首先,我将所有的附加文件移动到gcc目录中。

mv $HOME/gmp-6.0.0a $HOME/gcc-4.6.3/gmp
mv $HOME/mpfr-3.1.2 $HOME/gcc-4.6.3/mpfr
mv $HOME/mpc-1.0.2 $HOME/gcc-4.6.3/mpc

我接着进行了配置,没有任何错误,并尝试构建gcc。

mkdir -p $HOME/builds/gcc
cd $HOME/builds/gcc
../../gcc-4.6.3/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --enable-shared --with-multilib-list=m32,m64 --enable-threads=posix --enable-tls --without-headers
make

这导致了以下错误:
/bin/bash ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../gcc-4.6.3/gmp -D__GMP_WITHIN_GMP    -g -O2 -c -o mpn/div_qr_1n_pi1.lo mpn/div_qr_1n_pi1.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../gcc-4.6.3/gmp -D__GMP_WITHIN_GMP -g -O2 -c mpn/div_qr_1n_pi1.c -o mpn/div_qr_1n_pi1.o
/tmp/cckCXg2a.s: Assembler messages:
/tmp/cckCXg2a.s:194: Error: thumb conditional instruction should be in IT block -- `movcc r4,#0'
/tmp/cckCXg2a.s:195: Error: thumb conditional instruction should be in IT block -- `movcs r4,#-1'
/tmp/cckCXg2a.s:452: Error: thumb conditional instruction should be in IT block -- `movcc r4,#0'
/tmp/cckCXg2a.s:453: Error: thumb conditional instruction should be in IT block -- `movcs r4,#-1'
make[4]: *** [mpn/div_qr_1n_pi1.lo] Error 1
make[4]: Leaving directory `$HOME/builds/gcc/gmp'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `$HOME/builds/gcc/gmp'
make[2]: *** [all] Error 2
make[2]: Leaving directory `$HOME/builds/gcc/gmp'
make[1]: *** [all-gmp] Error 2
make[1]: Leaving directory `$HOME/builds/gcc'
make: *** [all] Error 2

贝狄尔骨黑板

Linux version 3.14.1-bone2 (root@imx6q-wandboard-2gb-0) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Sun Apr 20 09:56:48 UTC 2014

"gcc -v" 输出

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14)

桌面电脑

这是我最终想让代码运行的计算机。

Linux version 3.2.0-65-generic (buildd@brownie) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #98-Ubuntu SMP Wed Jun 11 20:27:07 UTC 2014

"gcc -v" 输出:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

1
看一下你的本地 ARM 编译器是如何配置的(gcc -v)。你是否使用相同的 --host 配置了交叉编译器?你能否构建一个普通的(非交叉)编译器? - n. m.
是的,上面的目标是从“gcc -v”命令的输出中得出的。对于这一点我没有表达清楚,我感到抱歉。最终我要编译的目标是“x86_64-linux-gnu”。 - Jason Smith
我猜把命令的输出放在上面可能会更容易一些。所以我会在上面添加它。 - Jason Smith
1
这看起来像是在x86机器上运行gcc -v。在ARM机器上会发生什么?另外,使用build=x86_64-linux-gnu host=arm-whatever target=x86_64-linux-gnu构建一种加拿大交叉编译器(crossback)可能更简单。 - n. m.
你是对的。终端一定出现了断管并返回到桌面。我回到家后会把它修好并发布BeagleBone Black的信息。对此我很抱歉。 - Jason Smith
显示剩余5条评论
1个回答

0

不要试图手动构建交叉编译器,我建议使用现有的工具链生成框架之一:buildrootcrosstool-NG。您需要使用apt-get在BBB上安装一些依赖项,但除此之外只需进行配置和编译即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接