16.4.2013 15:13, Sebastian Huber wrote:
> On Mon, Apr 15, 2013 at 4:05 PM, NeonJohn <jgd@xxxxxxxxxxxxx> wrote:
>
>> I have successfully compiled 4.8 for my native system, Ubuntu Linux.
>> Now I'm trying to build a cross compiler to generate ARM code for the
>> Beagle Bone. Having a few problems.
>
> For a cross-compiler you normally specify a --target. So maybe the
> command should look like this:
>
> path/to/gcc/source/configure --target=arm-angstrom-linux-gnueabi \
> --prefix=/opt/arm-linux-gnueabi-4.8 --disable-fortran --disable-java \
> --disable-lto --disable-objc -enable-neon
Quite wise could be to spy how the native GCC for 'Angstrom-Cloud9-'
or something was configured, for instance :
/home/koen/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/work-shared/gcc-4.5-r49+svnr184907/gcc-4_5-branch/configure
--build=x86_64-linux --host=arm-angstrom-linux-gnueabi
--target=arm-angstrom-linux-gnueabi --prefix=/usr --exec_prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec
--datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com
--localstatedir=/var --libdir=/usr/lib --includedir=/usr/include
--oldincludedir=/usr/include --infodir=/usr/share/info
--mandir=/usr/share/man --disable-silent-rules
--disable-dependency-tracking
--with-libtool-sysroot=/home/koen/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone
--with-gnu-ld --enable-shared --enable-languages=c,c++
--enable-threads=posix --disable-multilib --enable-c99
--enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch
--program-prefix=arm-angstrom-linux-gnueabi- --enable-target-optspace
--enable-lto --enable-libssp --disable-bootstrap --disable-libgomp
--disable-libmudflap --with-linker-hash-style=gnu --with-ppl=no
--with-cloog=no --enable-cheaders=c_global
--with-local-prefix=/home/koen/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/usr
--with-gxx-include-dir=/usr/include/c++/ --enable-nls --enable-__cxa_atexit
in the gcc-4.5 on the SD-Card image I downloaded. There are quite
a lot options one should consider in order to get an equivalent to the
native GCC...
> To build the Binutils you may use this:
>
> path/to/binutils/source/configure --target=arm-angstrom-linux-gnueabi \
> --disable-werror --prefix=/opt/arm-linux-gnueabi-4.8
Yes, the $prefix and $target MUST be the same in both binutils and GCC
configures!
(Or one knows what one is doing when using different values...)
> Make sure that the new Binutils are in your path before you build GCC.
Yes, the $prefix/bin MUST be in PATH...
What was totally forgotten here and also usually is the target C library :-(
In a native GCC build not having any stuff in '/usr/include' and '/usr/lib'
would totally disable any builds! Similarly not having the target C library
in its place before starting the cross GCC build will disable the GCC
build!
When one looks at the root directory on the SD-card filesystem :
[root@HP-Pavilion Angstrom-Cloud9-]# pwd
/media/Angstrom-Cloud9-
[root@HP-Pavilion Angstrom-Cloud9-]# ls
bin dev home lost+found mnt proc sbin tmp var
boot etc lib media opt run sys usr
then the natural question is : "Where are the target C library components?"
Any Linux user should know the answer : "In 'lib', 'usr/include' and
'usr/lib'
of course!"
Then there comes the question : "Where to put this stuff on the cross host?"
Any cross GCC builder should know the answer : "Into the chosen $sysroot
of course!"
So one needs to decide where to put the copied 'lib', 'usr/include' and
'usr/lib'
directories from the target system, what could be the suitable $sysroot
? My
own standard is the '/opt/host-$target', in this case that could be the :
/opt/host-arm-angstrom-linux-gnueabi
where to copy these directories from the SD-card filesystem.
In order to the binutils and GCC to find the target C library, one must
add the
option '--with-sysroot=$sysroot' to the configure commands of both!
As the binutils configure command one so would use for instance :
path/to/binutils/source/configure --target=arm-angstrom-linux-gnueabi \
--disable-werror --prefix=/opt/arm-linux-gnueabi-4.8 \
--with-sysroot=/opt/host-arm-angstrom-linux-gnueabi
How to configure the cross GCC is left mainly as a homework but at least
using the options :
--enable-shared --enable-languages=c,c++ --enable-threads=posix
--disable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu
--enable-libstdcxx-pch --enable-target-optspace --enable-lto --enable-libssp
--disable-bootstrap --disable-libgomp --disable-libmudflap
--with-linker-hash-style=gnu --with-ppl=no --with-cloog=no
--enable-cheaders=c_global --enable-nls --enable-__cxa_atexit
could be investigated, why they were used with the native GCC and whether
to use the same in the cross GCC too...