Gentoo Archives: gentoo-embedded

From: Ed W <lists@××××××××××.com>
To: gentoo-embedded@l.g.o
Subject: [gentoo-embedded] Mixed arch chroot to optimise building in qemu
Date: Wed, 22 Sep 2021 18:20:19
Message-Id: 15daab32-737d-621e-20b6-18c34294a37c@wildgooses.com
1 Hi all, traffic seems to have dropped off here significantly, but here goes
2
3 I am building a bunch of armv7a images on an AMD Ryzen9 machine (amd64). So to keep things simple I
4 have just been doing the whole thing using qemu up until now, by which I mean I have an arm stage 3
5 somewhere, I chroot into it and then using userspace qemu binaries I just run my whole script to
6 generate the target build from inside that chroot. This works but it's at least a 5x slowdown from
7 native
8
9 To optimise this I have tried
10
11 - turning on the various compiler options for python (claimed to give a 30% improvement) + LTO/PGO.
12 I don't notice any difference in the chroot - presume that the emulation overhead is dominant effect
13
14 - tried compiling qemu with -O3 and LTO (claimed to be supported since 6.0). Doesn't give any
15 noticeable different in performance of emerge
16
17 - Added a static compiled amd64 /bin/bash to the chroot - now this does give a noticeable boost to
18 compile and emerge speeds. (random benchmark went from 26s to 22s)
19
20
21 So motivated by the last item I want to try and see how many native exes I can push into the chroot
22 (since I'm running under usermode qemu! why not!). The obvious one is the compiler
23
24 Now, I have a cross compiler built, but a) that's not static, so I would need to find a way to get
25 native libc into the chroot, and b) I'm not clear how I would call it inside the chroot, could I
26 just move a symlink to the other compiler into the path? How does it find things like libgcc*.so etc?
27
28 Or perhaps this is easier than this? Can I just use some incantation in the same way that the
29 crosscompiler must be working to build myself a straight gcc inside the chroot which is native arch
30 and statically compiled? eg is it enough that assuming I can build gcc static, can I just do this
31 from outside the chroot and overwrite the native:
32
33     ROOT=$PWD emerge -1v --nodeps gcc
34
35
36 It seems to me that this should work at least for the gcc binaries, etc. However, I'm completely
37 ignorant of whether I want things like the linker plugin in native arch or target arch? What about
38 the libgcc*.so files? (They don't actually exist in my cross compiler directories, but they are
39 linked in as dependencies in some binaries in target and exist in the native compiler dir)
40
41 Hacker news had someone do this recently and I believe meego used to do something similar, so really
42 just trying to work out the details for this on gentoo. Any thoughts?
43
44 Thanks
45
46 Ed W

Replies

Subject Author
Re: [gentoo-embedded] Mixed arch chroot to optimise building in qemu Michael Jones <gentoo@×××××××.com>
Re: [gentoo-embedded] Mixed arch chroot to optimise building in qemu Peter Stuge <peter@×××××.se>