Mail archive

Re: [alpine-devel] Porting Alpine scripts

From: Tuan M. Hoang <>
Date: Sat, 16 Jul 2016 22:08:53 +0700


I have successfully built armv7 cross-toolchain using

About, 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/ b/
--- a/
+++ b/
_at_@ -1,6 +1,6 @@
+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 @@ 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?

2. At cross-building binutils step, I have the error :

./a.out: cannot execute binary file: Exec format error

I checked the configure log ( 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 ?

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.

By the way, your work is beautiful.
Thank you.

 ---- On Thu, 14 Jul 2016 05:03:43 +0700 Tuan M. Hoang <> wrote ----
> Would you mind sharing your building log ? I just need to make sure my steps are correct.
> Thank you.
> ---
> Unsubscribe:
> Help:
> ---

Received on Sat Jul 16 2016 - 22:08:53 UTC