Discussion:
abe: cross native toolchain compilation for aarch64-linux-gnu
Virendra Kumar Pathak
2015-06-03 16:26:47 UTC
Permalink
Hi Linaro Toolchain Group,

I am trying to build a cross-native toolchain for AARCH64 using ABE build
framework.
By cross native I mean that toolchain will be build on 0x86 (Red hat
Santiago 6.4), it will run on AARCH64 (Juno) and
will produce binaries to be run on AARCH64 (Juno)
(If I am not mistaked) --build=0x86, --host=AARCH64, --target=AARCH64

Steps followed:
1. I built a cross toolchain first
../abe/configure
../abe/abe.sh --target aarch64-linux-gnu --build all --release 2015.05.29
--tarbin --disable update
2. Added the above cross toolchain (bin path) in the PATH
3. To build to cross-native
../abe/configure
../abe/abe.sh --host aarch64-linux-gnu --target aarch64-linux-gnu --build
all --release 2015.06.01.native --tarbin --disable update

But after some time, I got following error and compilation hanged.

make: Leaving directory
`/home/user_name/vpathak/build_abe/builds/aarch64-linux-gnu/aarch64-linux-gnu/gcc.git~linaro-4.9-branch-stage1'
RUN: copy_gcc_libs_to_sysroot
"/home/user_name/vpathak/build_abe/builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
--sysroot=/home/user_name/vpathak/build_abe/sysroots/aarch64-linux-gnu"
/home/user_name/vpathak/abe/lib/make.sh: line 962:
./builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: cannot
execute binary file

Am I missing something ? Please help.



However with the following hack in the abe, I am able to compile
cross-native toolchain for aarch64-linux-gnu.

In the abe code base:
-------------------------------------------------------------------------------------------------------
lib/make.sh
Function copy_gcc_libs_to_sysroot()
gcc_exe="`find -name ${target}-gcc`"
- libgcc="`${gcc_exe} -print-file-name=${libgcc}`"
+ #libgcc="`${gcc_exe} -print-file-name=${libgcc}`"
+
libgcc="/home/user_name/vpathak/build_abe/builds/destdir/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.9.3/libgcc.a"

Since './builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc' is
native toolchain it will not run on 0x86. Thus libgcc will be empty.
Therefore I hard-coded libgcc path.
-------------------------------------------------------------------------------------------------------
I had to disable gdb compilation. This error I faced while compiling
cross-native compilation only.
Cross compilation is successful on the same 0x86 machine.

checking for library containing waddstr... no
configure: error: no enhanced curses library found; disable TUI
make: *** [configure-gdb] Error 1
make: Leaving directory
`/home/user_name/vpathak/build_abe/builds/aarch64-linux-gnu/aarch64-linux-gnu/binutils-gdb.git~linaro_gdb-7.8-branch-gdb'
WARNING: Make had failures!
ERROR (#159): build_all (Failed building .)

hacked patch
--- a/lib/make.sh
+++ b/lib/make.sh
@@ -31,10 +31,10 @@ build_all()
# to rebuilt the sysroot.
local builds="infrastructure binutils libc stage2 gdb"
else
- local builds="infrastructure binutils stage1 libc stage2 gdb"
+ local builds="infrastructure binutils stage1 libc stage2"
fi
if test "`echo ${target} | grep -c -- -linux-`" -eq 1; then
- local builds="${builds} gdbserver"
+ local builds="${builds}"
fi
---------------------------------------------------------------------------------------------------------------

Thanks.
--
with regards,
Virendra Kumar Pathak
Jim Wilson
2015-06-03 18:23:22 UTC
Permalink
On Wed, Jun 3, 2015 at 9:26 AM, Virendra Kumar Pathak
Post by Virendra Kumar Pathak
I am trying to build a cross-native toolchain for AARCH64 using ABE build
framework.
By cross native I mean that toolchain will be build on 0x86 (Red hat
Santiago 6.4), it will run on AARCH64 (Juno) and
will produce binaries to be run on AARCH64 (Juno)
(If I am not mistaked) --build=0x86, --host=AARCH64, --target=AARCH64
I've never used abe to build canadian cross like this, so I don't know
the level of support for it. In theory it seems like it should work.
It is simpler to just build natively on a juno box though, which is
what I do.
Post by Virendra Kumar Pathak
RUN: copy_gcc_libs_to_sysroot
"/home/user_name/vpathak/build_abe/builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
--sysroot=/home/user_name/vpathak/build_abe/sysroots/aarch64-linux-gnu"
./builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: cannot execute
binary file
The problem here is that abe is using the host compiler binary when it
should be using the build compiler binary. Abe would need to keep
track of two compiler versions, and remember that one runs on the host
and one runs on the build machine. The GCC makefiles have this
support, but it appears that the abe scripts do not. It should be
possible to add this to abe. You could try filing a bug report
against abe for this problem.
Post by Virendra Kumar Pathak
-------------------------------------------------------------------------------------------------------
I had to disable gdb compilation. This error I faced while compiling
cross-native compilation only.
Cross compilation is successful on the same 0x86 machine.
checking for library containing waddstr... no
configure: error: no enhanced curses library found; disable TUI
make: *** [configure-gdb] Error 1
A gdb build requires the libncurses library, which is separate from
glibc. This isn't part of the sysroot that abe creates. So yes, this
isn't going to work unless you configure gdb to disable tui, or add
libncurses to the sysroot. Again, you could file an abe bug report
for that.

Jim
Rob Savoye
2015-06-03 20:11:52 UTC
Permalink
Post by Jim Wilson
On Wed, Jun 3, 2015 at 9:26 AM, Virendra Kumar Pathak
Post by Virendra Kumar Pathak
I am trying to build a cross-native toolchain for AARCH64 using ABE build
framework.
By cross native I mean that toolchain will be build on 0x86 (Red hat
Santiago 6.4), it will run on AARCH64 (Juno) and
will produce binaries to be run on AARCH64 (Juno)
(If I am not mistaked) --build=0x86, --host=AARCH64, --target=AARCH64
ABE has full support for building a Canadian cross. Just use --host
for the host. I've only tested this with win32 builds though. You can
look at abe/scripts/MakeRelease.job to see how I do this. The process to
use is first build the cross compiler, ie... arch64-linux-gnu. Make sure
where it gets installed is in your PATH. Then run ABE again with --host
for the x86 machine. Abe will use the aarch64 cross compiler for the
libraries, and in the win32 case, it'll use mingw32 for all the executables.

It's a lot easier to build natively though. In that case don't supply
--target to ABE.

- rob -

Loading...