在BeagleBone Black上构建gcc失败了

Jas*_*ith 12 gcc cross-compiling beagleboneblack

问题

我正在尝试在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
Run Code Online (Sandbox Code Playgroud)

我知道拇指与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"
Run Code Online (Sandbox Code Playgroud)

然后我继续配置,构建和安装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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

我然后配置,没有任何错误,并尝试构建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
Run Code Online (Sandbox Code Playgroud)

这会产生以下错误:

/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
Run Code Online (Sandbox Code Playgroud)

BeagleBone Black

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
Run Code Online (Sandbox Code Playgroud)

"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)
Run Code Online (Sandbox Code Playgroud)

桌面

这是我试图让代码最终运行的计算机.

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
Run Code Online (Sandbox Code Playgroud)

"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
Run Code Online (Sandbox Code Playgroud)

Arn*_*out 0

我建议使用现有的工具链生成框架之一:buildrootcrosstool-NG ,而不是尝试手动构建交叉编译器。您需要使用 apt-get 在您的 BBB 上安装一些依赖项,但除此之外,这只是配置问题;制作。