12

Problem

I am trying to build a cross compiler on a BeagleBone Black to compile from ARM to x86. The intent of this is to use the low power consuming BeagleBone Black that I had on hand as a build server. It can already compile for windows through mingw-w64, but I need it to also compile the code for Linux x86 systems.

However, when I try to compile gcc on the BeagleBone Black I get the following errors:

/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

I know thumbs have something to do with ARM, but I'm mostly at a loss for why this isn't working. What did I do wrong?

Below are the steps I took in trying to create the cross-compiler. This is my first attempt at trying to make a cross-compiler, so most of this information was gleaned from several webpages and manuals.


Steps Taken

To create the cross compiler I downloaded the following packages:

  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

These were all unpacked into the directory $HOME.

From there I set the following bash environment variables.

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

I then proceeded to configure, build, and install the 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 built without any errors, so I proceeded to build gcc. First I moved all the extras into the gcc directory.

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

I then configured, without any errors, and tried to build 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

This generated the following errors:

/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

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

"gcc -v" output

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)

Desktop

This is the computer I am trying to get the code to run on in the end.

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" output:

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
Jason Smith
  • 765
  • 8
  • 23
  • 1
    Look how your native ARM compiler was configured (`gcc -v`). Have you configured your cross-compiler with the same `--host`? Can you build a normal (not cross) compiler? – n. m. could be an AI Jul 05 '14 at 20:36
  • Target: arm-linux-gnueabihf Since I'm building directly on the BeagleBone Black unit and not through a canadian cross setup, shouldn't the build set the host itself? – Jason Smith Jul 05 '14 at 20:57
  • yeah the Target above is the print out from the "gcc -v" command. I apologize about not being clear about that. The target I am compiling for in the end is "x86_64-linux-gnu" – Jason Smith Jul 05 '14 at 21:00
  • I guess it would probably be easier to put the output of the command. So I'll add it above. – Jason Smith Jul 05 '14 at 21:04
  • 1
    This looks like `gcc -v` on an x86 machine. What happens on the ARM machine? Also, it just might be simpler to build a kind of Canadian cross compiler (crossback?) with build=x86_64-linux-gnu host=arm-whatever target=x86_64-linux-gnu. – n. m. could be an AI Jul 05 '14 at 21:31
  • You are right. The terminal must have had a broken pipe and went back to the desktop. I'll fix it up and post the BeagleBone Black's when I get home. I apologize about that. – Jason Smith Jul 06 '14 at 00:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/56826/discussion-between-jason-smith-and-n-m). – Jason Smith Jul 06 '14 at 00:13
  • @n.m., OK I have posted the correct output to each section. I apologize again about that. Also, the problem seems to be fixed by using the latest snapshot of gmp. Although, I now have the "libgmp not found or uses a different ABI" from mpfr. That will have to be a separate question though. Thank you for your help though. I really do appreciate your time. – Jason Smith Jul 06 '14 at 04:15
  • I don't see any obvious errors here. Sorry :( Perhaps try really building a crossback compiler. – n. m. could be an AI Jul 06 '14 at 04:51
  • @n.m., Thanks for the input. Apparently there were no errors in what I was doing. There was however a bug in the gmp code that was fixed in the latest snapshot. So all is good now. – Jason Smith Jul 06 '14 at 04:54

1 Answers1

0

Instead of trying to manually build a cross-compiler, I would advise to use one of the existing toolchain generation frameworks: buildroot or crosstool-NG. You need to install some dependencies on your BBB using apt-get, but otherwise it's just a matter of configure; make.

Arnout
  • 2,927
  • 16
  • 24