Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] Mixed arch chroot to optimise building in qemu Ed W <lists@××××××××××.com>