Mail archive
alpine-devel

Re: Cross-building (was: Re: [alpine-devel] musl and ARM in 2.7 (and an introduction))

From: Timo Teras <timo.teras_at_iki.fi>
Date: Wed, 30 Oct 2013 11:14:16 +0200

On Fri, 25 Oct 2013 14:30:48 +0200
"Leslie P. Polzer | PORT ZERO" <polzer_at_port-zero.com> wrote:

> On 10/18/2013 12:16 PM, Timo Teras wrote:
>
> >> Also, is there an established way already of building Alpine based
> >> on musl and/or cross-compiling for ARM? It doesn't seem to be a big
> >> deal, but I'd like to know the efforts that have already been put
> >> into this so I'm not duplicating any work.
> >
> > We've patched aports so that a minimal bootstrap system can be cross
> > compiled. All changes are in git already. And some minor notes +
> > links to the scripts I used to bootstrap musl builders are at my
> > wiki wall: http://wiki.alpinelinux.org/wiki/User:Fabled
>
> That helped! I had to clear out some roadblocks, after which I now
> have a successful and reproducible bootstrap crossbuild of
> i486-alpine-linux-musl (without KERNEL_PKG and DEBUG_PKG so far; I
> simply haven't tried).

Very good!

> The problems I encountered, working with your scripts on current edge:
>
> In createcross-toolchain.sh:
>
> * I instructed abuild to clean up the musl build before installing
> headers. This is necessary to prevent the patches from being applied
> multiple times by the "prepare" step if you call the script more
> than once.

Ah, right. I think this can be affected in abuild.conf - but it's good
to have it explicit.

> In abuild-crossbuild-x86.conf:
>
> * CBUILD is no longer being set in /etc/abuild.conf (this was changed
> pretty recently). This prevented gmp from being built correctly
> (I think it just used the host setting for the build).
> More packages might be affected by this.

Yes, I noticed this too.

> In crossbuild-alpine-bootstrap.sh:
>
> * Set up the proper pkgconfig environment for the cross root.
> Without this the relevant .pc files cannot be found. The first
> package that broke in the ordered crossbuild because of this
> was apk-tools.

And this too - I added this to x86_64.conf's earlier.

> * Added installation of all packages after they have been built.
> This is a necessary step since later packages require files from
> earlier ones. Also attempt to install $PKG-dev. Some packages need
> special casing here since their -dev packages have a different
> name. Maybe this should be fixed in the packages themselves.
> The packages affected are gmp5 (gmp-dev) and mpfr3 (mpfr-dev).

Hmm - this worked for me without this. Though, I did have to fix some
makedepends in the aports. This was done not long ago.

> * Non-essential: also added per-package logging to cut down on the
> output.

Ok.

> I'm attaching a rough diff against your x86 conf files and the two
> scripts. Please let me know how you want to proceed with integrating
> these changes.

I need think what to do with the scripts. Might be an idea to bundle
them in abuild git tree. Even if they are not shipped in abuild.
Ultimately I would abuild to have "--target" and "--host" flags that
can be used to trigger the cross build so no additional "kludge" config
files would be needed.

> I wonder how we can test packages for their sanity properly after
> we have built them. The usual way is running the testsuite (make
> check) after compilation. Obviously this won't work when
> cross-compiling to a different machine architecture. Any ideas?

I don't think we plan to support cross-compiling all of aports. So this
would not be a goal for us.

I believe scratchbox etc. use statically built qemu-user, or some
binfmt_misc magic to launch the files on remote target. In either case
both will be "kludgy" and probably not doing 100% testing.

- Timo


---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Wed Oct 30 2013 - 11:14:16 UTC