Gentoo Archives: gentoo-embedded

From: Ed W <lists@××××××××××.com>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] Mixed arch chroot to optimise building in qemu
Date: Thu, 23 Sep 2021 11:58:37
Message-Id: 040a9f96-f67d-4712-0c44-efaf8369ef58@wildgooses.com
In Reply to: Re: [gentoo-embedded] Mixed arch chroot to optimise building in qemu by Michael Jones
1 On 22/09/2021 21:03, Michael Jones wrote:
2 >
3 > Like I said, I think there'd be a big benefit to collaborating, but the image builder is usable as
4 > is for your purpose, if I understand it correctly. Its just missing the native binaries to speed
5 > things up.
6 >
7
8 OK, so have a look here for inspiration:
9
10     https://wiki.gentoo.org/wiki/Crossdev_qemu-static-user-chroot
11
12
13 I think that lxc script won't function as is today, but the intent seems clear. Basically what I had
14 failed to notice is:
15
16 - The cross compiler is a mix of target arch gcc libs and native binaries, so this seems safe to
17 copy into the chroot
18
19 - the libc binary is tagged with the arch, at least when not on amd64, so it's possible to have both
20 arm and amd64 libcs in the chroot at the same time without a collision
21
22 - setting LD_LIBRARY_PATH is an interesting way to keep the other libs in an unusual directory
23
24
25 So I think it should be possible to simply copy in some/all of the files created by crossdev into
26 the arm chroot and then either simply setup your own gcc symlinks (as per distcc) or to use the guts
27 of the crossdev emerge wrapper scripts to do the same
28
29 Simplest way to accurately copy in would seem to be the usual trick (from the host):
30
31     ROOT=/chroot_dir emerge -1vK --nodeps cross-armv7a-unknown-linux-musleabihf/gcc
32
33 Where the package at the end is your crossdev gcc
34
35 However, the symlinks would seem to support the case of upgrades in the host get carried through
36 into the target... Need to ponder which is simplest. Installing the package allows for uninstall and
37 tracking the files (I guess it completely replaces and overwrites the chroot compiler?). The symlink
38 method will clash and mask out some files in the chroot, accidentally upgrading in the chroot would
39 break everything.
40
41
42 As an aside, getting static exes is a bit of a pain on gentoo, so to note it here for the benefit of
43 google, you can get a static binutils with the following incantation:
44
45   CFLAGS="$(portageq envvar CFLAGS) -static" EXTRA_ECONF="--disable-shared LDFLAGS=--static"
46 CXXFLAGS=$CFLAGS  ROOT=/tmp/test-binutils emerge -1v --nodeps sys-devel/binutils
47
48
49 Generally just the CFLAGS and CXXFLAGS parts are needed, the EXTRA_ECONF is just a trick needed for
50 binutils. My thought was just to install this static package direct into the chroot as per the above.
51
52
53 Ed W