Mail archive
alpine-devel

Re: [alpine-devel] Porting Alpine scripts

From: Timo Teras <timo.teras_at_iki.fi>
Date: Mon, 18 Jul 2016 08:40:38 +0300

On Sat, 16 Jul 2016 22:08:53 +0700
"Tuan M. Hoang" <tmhoang_at_flatglobe.org> wrote:

> I have successfully built armv7 cross-toolchain using
> createcross-toolchain.sh.

Nice.

> About crossbuild-alpine-bootstrap.sh, I have 2 questions:
>
> 1. At cross-building busybox (in the for loop), there was an error of
> missing linux/kd.h header, even though /usr/include/linux/kd.h is
> present in my Alpine build machine. So I have to install the newly
> cross-built linux-headers package from previous loop, like this:
>
> diff --git a/crossbuild-alpine-bootstrap.sh
> b/crossbuild-alpine-bootstrap.sh --- a/crossbuild-alpine-bootstrap.sh
> +++ b/crossbuild-alpine-bootstrap.sh
> _at_@ -1,6 +1,6 @@
> #!/bin/sh
>
> -TARGET_ARCH=aarch64
> +export TARGET_ARCH=armv7
>
> export
> ABUILD_CREATECROSS_CONF=$PWD/abuild-createcross-$TARGET_ARCH.conf
> export ABUILD_CONF=$PWD/abuild-crossbuild-$TARGET_ARCH.conf _at_@ -47,6
> +47,10 _at_@ for PKG in linux-headers musl libc-dev \ cd
> $APORTS/main/$PKG BOOTSTRAP=bootimage abuild -r || exit 1
>
> + if [ "$PKG" = "linux-headers" ]; then
> + ${SUDO_APK} -u --root "$CBUILDROOT" --repository
> "$REPODEST_TARGET/main" --arch "$TARGET_ARCH" add linux-headers |
> exit 1
> + fi
> +
> if [ "$PKG" = "libc-dev" ]; then
> # install libc-dev, as implicit but mandatory
> dependency ${SUDO_APK} -u --root "$CBUILDROOT" add libc-dev || exit 1
>
> How about your procedures?

busybox apkbuild has:
makedepends_host="linux-headers"

So when cross building abuild should have automatically installed this
for you. It does it for me.

> 2. At cross-building binutils step, I have the error :
>
> ./a.out: cannot execute binary file: Exec format error
>
> I checked the configure log (http://pastebin.com/t9QS9DZZ) and it
> looks like the build, host, target machines are all
> 'armv7-alpine-linux-muslgnueabihf', which is incorrect I guess. I
> think the build machine should be 'x86_64-alpine-linux-musl' because
> we are using a cross-compiler running on x86_64 targeting armv7. So
> from its point of view, the build machine is x86_64, it builds
> program to run on host machine (armv7), and I am not really sure what
> to pass as target machine, maybe armv7 too.
>
> If I try to pass to binutils configure script with
> '--build=x86_64-alpine-linux-musl
> --host=armv7-alpine-linux-muslgnueabihf
> --target=armv7-alpine-linux-muslgnueabihf ' then it configure and
> build just fine.
>
> Doing the same strategy with make, it failed.
>
> What do you think ?

Sounds like you figured out the root of the problem. CBUILD needs to be
the build host's triplet, or things will not work.

Usually it is configured in /etc/abuild.conf, and that's what my
scripts expect. E.g. my abuild-crossbuild-armv7.conf has:
  # inherit CBUILD, and other basic defines
  source /etc/abuild.conf

It expects CBUILD=<system triplet> to be in /etc/abuild.conf.

This is also used by abuild to deduce if cross building or not, and
probably caused the problem #1 too.


> 3. I am curious about CBUILD variable. Where is it defined? Can't
> find in your script nor (any) APKBUILD nor APKBUILD reference
> documentation/webpage. In cross-building binutils case, it is set to
> 'armv7-alpine-linux-muslgnueabihf', same as CHOST.

See above.

> By the way, your work is beautiful.

Thank you.

We managed to bootstrap aarch64 recently. We have it running on qemu
and on real hw too. I believe when it comes up, it could be used for
aarch64 and possibly armv7 builds.

/Timo


---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Mon Jul 18 2016 - 08:40:38 UTC