Discussion:
Creating a cross compiler from ARM to x86
Jason Smith
2014-07-05 17:59:00 UTC
Permalink
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? Any help would be
greatly appreciated.

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 gleamed from several web pages 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 (***@imx6q-wandboard-2gb-0) (gcc version
4.6.3 (Debian 4.6.3-14) ) #1 SMP Sun Apr 20 09:56:48 UTC 2014

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 (***@brownie) (gcc version 4.6.3
(Ubuntu/Linaro 4.6.3-1ubuntu5) ) #98-Ubuntu SMP Wed Jun 11 20:27:07 UTC 2014
--
Jason Smith
Marc Glisse
2014-07-05 19:17:44 UTC
Permalink
Post by Jason Smith
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
/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:194: Error: thumb conditional instruction should be
in IT block -- `movcc r4,#0'
The problem appears to be during the build of GMP.
Post by Jason Smith
2. gmp-6.0.0a
Could you try a snapshot of what will be in 6.0.1? I believe we have
already fixed some related bug.
https://gmplib.org/download/snapshot/

(or use an older version of GMP, maybe 5.1.3)

If the problem persists, please try building the GMP snapshot
independently and report the problem to gmp-bugs AT gmplib.org.

Actually, now I think about it, I am not sure why gcc is building gmp for
the target, I thought it would only build it for the host.
--
Marc Glisse
Jason Smith
2014-07-05 20:09:31 UTC
Permalink
The latest snapshot of GMP seems to have worked. Now I have hit a
problem with MPFR:
configure: error: libmpfr not found or uses a different ABI
(including static vs shared).

I found this in the FAQ for MPFR,
http://www.mpfr.org/faq.html#no_libgmp, but I'm not sure how GCC handles
this. When I put the MPFR code into gcc with the command "mv
$HOME/mpfr-3.1.2 $HOME/gcc-4.6.3/mpfr" how does GCC detect the library.
Do I need to specify it in my LD_LIBRARY_PATH of edit C_FLAGS with -I -L
and -l flags?

Jason Smith
Post by Marc Glisse
Post by Jason Smith
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
/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:194: Error: thumb conditional instruction should be
in IT block -- `movcc r4,#0'
The problem appears to be during the build of GMP.
Post by Jason Smith
2. gmp-6.0.0a
Could you try a snapshot of what will be in 6.0.1? I believe we have
already fixed some related bug.
https://gmplib.org/download/snapshot/
(or use an older version of GMP, maybe 5.1.3)
If the problem persists, please try building the GMP snapshot
independently and report the problem to gmp-bugs AT gmplib.org.
Actually, now I think about it, I am not sure why gcc is building gmp
for the target, I thought it would only build it for the host.
Marc Glisse
2014-07-05 20:20:33 UTC
Permalink
Post by Jason Smith
The latest snapshot of GMP seems to have worked. Now I have hit a
configure: error: libmpfr not found or uses a different ABI
(including static vs shared).
I found this in the FAQ for MPFR,
http://www.mpfr.org/faq.html#no_libgmp, but I'm not sure how GCC handles
this. When I put the MPFR code into gcc with the command "mv
$HOME/mpfr-3.1.2 $HOME/gcc-4.6.3/mpfr" how does GCC detect the library.
Do I need to specify it in my LD_LIBRARY_PATH of edit C_FLAGS with -I -L
and -l flags?
As explained by the FAQ you are linking to, you need to look at the
config.log file in mpfr to know why things failed. Normally, gcc passes
the right options so you don't have to do anything special after that
'mv'.
--
Marc Glisse
Stefan Ruppert
2014-07-08 09:07:30 UTC
Permalink
Post by Jason Smith
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.
Hi Jason,

do you have measured power consumption of an x86 based-system and
compared it to the power consumption of your BeagleBone?

I have measured the power consumption using Fritzbox 7390 and Fritz Dect
200, thus its the consumption of the complete system.

We have a ARM-based quad-core Utilite Pro (http://utilite-computer.com/)
(Freescale i.MX6 quad-core Cortex-A9 @1GHz running ubunutu 12.04) system
consuming around 5 Watt in idle mode and around 8 Watt average when 3
cores are active. Our quad-core Xeon x86 64-bit (Xeon(R) CPU E3-1245 v3
@ 3.40GHz, limited to 2.9GHz running debian 7.5) system uses 20 Watt in
idle and around 40 Watt average when 3 cores are active.

An build of our MyARM software needs 5 minutes on the xeon-system
(building totally in RAM ;-) and 19 minutes on the ARM-based system.

Now roughly calculating power consumption:

Xeon-based: 40W * ( 5/60)h = ~3.3Wh
ARM-based: 8W * (19/60)h = ~2.5Wh

Now measuring build time and power consumption when only a single core
is used:

Xeon-based: 11.5 minutes build time and around 34 Watt average
ARM-based 40.5 minutes build time and around 7 Watt average

Resulting in the following power consumption:

Xeon-based: 34W * (11,5/60)h = ~6.5Wh
ARM-based: 7W * (40,5/60)h = ~4.7Wh

With 4 cores active:

Xeon-based: 44W * (4,25/60)h = ~3,11Wh
ARM-based: 9W * (17/60)h = ~2,55Wh

Thus using more cores reduces overall power consumption and our
ARM-based system uses around 30% less power. But our Xeon-Server is a
VM-Server serving up-to 18 different VMs with different operating systems...

Regards,
Stefan

--
MyARM measuring response time, performance and more ...

Loading...