[PATCH] gnu: qemu-minimal: Only build for the host's architecture.

  • Done
  • quality assurance status badge
Details
3 participants
  • Efraim Flashner
  • Leo Famulari
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Efraim Flashner
Severity
normal
E
E
Efraim Flashner wrote on 4 May 2020 12:25
(address . guix-patches@gnu.org)(name . Efraim Flashner)(address . efraim@flashner.co.il)
20200504102515.18650-1-efraim@flashner.co.il
* gnu/packages/virtualization.scm (qemu-minimal)[arguments]: Adjust
configure-flags so that each architecture only builds for its native
architectures.
[synopsis]: Adjust to clarify it's only for the host's architecture.
---

I tested this with building grub and a vm-image and both seem to have
worked without any regressions.

---
gnu/packages/virtualization.scm | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)

Toggle diff (63 lines)
diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index b9ac18820f..e5d678e685 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2016, 2017, 2018. 2019 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016, 2017, 2018. 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
;;; Copyright © 2017 Andy Patterson <ajpatter@uwaterloo.ca>
@@ -99,7 +99,8 @@
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix utils)
- #:use-module (srfi srfi-1))
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match))
(define (qemu-patch commit file-name sha256)
"Return an origin for COMMIT."
@@ -274,15 +275,33 @@ server and embedded PowerPC, and S390 guests.")
(supported-systems (delete "mips64el-linux" %supported-systems))))
(define-public qemu-minimal
- ;; QEMU without GUI support.
+ ;; QEMU without GUI support, only supporting the host's architecture
(package (inherit qemu)
(name "qemu-minimal")
- (synopsis "Machine emulator and virtualizer (without GUI)")
+ (synopsis
+ "Machine emulator and virtualizer (without GUI) for the host architecture")
(arguments
(substitute-keyword-arguments (package-arguments qemu)
((#:configure-flags _ '(list))
- ;; Restrict to the targets supported by Guix.
- ''("--target-list=i386-softmmu,x86_64-softmmu,mips64el-softmmu,arm-softmmu,aarch64-softmmu"))))
+ ;; Restrict to the host's architecture.
+ `(,@(match (or (%current-system)
+ (%current-target-system))
+ ("x86-64-linux"
+ ''("--target-list=i386-softmmu,x86_64-softmmu"))
+ ("i686-linux"
+ ''("--target-list=i386-softmmu"))
+ ("mips64el-linux"
+ ''("--target-list=mips64el-softmmu"))
+ ("aarch64-linux"
+ ''("--target-list=arm-softmmu,aarch64-softmmu"))
+ ("armhf-linux"
+ ''("--target-list=arm-softmmu"))
+ ((or "powerpc64-linux" "powerpc64le-linux")
+ ''("--target-list=ppc-softmmu,ppc64-softmmu"))
+ ("powerpc-linux"
+ ''("--target-list=ppc-softmmu"))
+ (_ ; An empty list actually builds all the targets.
+ ''()))))))
;; Remove dependencies on optional libraries, notably GUI libraries.
(native-inputs (fold alist-delete (package-native-inputs qemu)
--
2.26.2
L
L
Leo Famulari wrote on 5 May 2020 18:10
(name . Efraim Flashner)(address . efraim@flashner.co.il)(address . 41074@debbugs.gnu.org)
20200505161055.GA31092@jasmine.lan
On Mon, May 04, 2020 at 01:25:15PM +0300, Efraim Flashner wrote:
Toggle quote (5 lines)
> * gnu/packages/virtualization.scm (qemu-minimal)[arguments]: Adjust
> configure-flags so that each architecture only builds for its native
> architectures.
> [synopsis]: Adjust to clarify it's only for the host's architecture.

I admit I don't understand the impact or motivation of this change. What
will be different from what currently happens?
E
E
Efraim Flashner wrote on 6 May 2020 09:16
(name . Leo Famulari)(address . leo@famulari.name)(address . 41074@debbugs.gnu.org)
20200506071603.GB2359@E5400
On Tue, May 05, 2020 at 12:10:55PM -0400, Leo Famulari wrote:
Toggle quote (9 lines)
> On Mon, May 04, 2020 at 01:25:15PM +0300, Efraim Flashner wrote:
> > * gnu/packages/virtualization.scm (qemu-minimal)[arguments]: Adjust
> > configure-flags so that each architecture only builds for its native
> > architectures.
> > [synopsis]: Adjust to clarify it's only for the host's architecture.
>
> I admit I don't understand the impact or motivation of this change. What
> will be different from what currently happens?

Currently every architecutre building qemu-minimal builds targets for
each of the architectures we support, x86_64, i686, mips64el, armhf,
aarch64. With this change armhf only builds for armhf, x86_64 builds for
x86_64 and i686, etc. Looking through the code with a 'git grep
qemu-minimal', qemu-minimal is only used for tests for grub and system
tests and for (gnu system vm) and on core-updates a bit more similar
places. Basically it's only used for running tests and creating VMs,
which means it only needs to target the host architecture. Every other
place where we provide support for other architectures, like the binfmt
service, uses full qemu by default.

Overall it doesn't save as much space as I'd hoped, each target
architecture only costs about 16MiB, but it does save a fair amount of
time building each target architecture. Currently qemu-minimal is
303MiB, dropping the 3 architectures for x86_64 would drop it down to
~258MiB. Some more work would need to be done to trim the share/qemu
folder to only have the relevant bits. Currently there's about 200MiB of
edk2 stuff for arm/aarch64.

--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl6yZC8ACgkQQarn3Mo9
g1E9YRAAixUQwn6heijFGdKN0vvFYTottPCAoAj6DBrgaNhBI/POa0syFq2YvUwH
eDc0hXXVePFRjXCxaqtu8CeRwY5SNTNUA2TO/sOwRK3DFtnjfrLQM0ENgYRrKYjN
zTfHSKJ1Y3RPUGL5QhQjMuPETocUM/fop6DityAFqsiDVcU2u2wepxc70+UQ7st8
WXKtgQN2zRNRon58KWqRcUYDcpAxa/mMXmB73qd6g1V/uTztQJ+xB+UfxnW+ro/V
2Jm2UEFCCK6+J8i3WG2YZWUu/L4HUcwe7dynFGxNAhpUaLSwEn3CbjWbjwWgl92W
X7aTtPUEjdFrTlbVINm04nv3qA5svTUqhjhbnYSQTIFhy05NF3jFT+GMw+DS4IKX
Ay+f40PLt383p4p1285XacpcBFk2uAsywjkRMhzViRmBSTaDrMntkhDC4ykKehAZ
VqMeM3VZ9cfMZMRMiYqzLQV9WV1fd5nd5a3vqh01v7Q/KzoPS6XofSx3VkJLczXw
MNr2p+GqljgxQZNJWZVezGbdnxGcFzGi0XFUtG6DHtk74czUnNBmx4+Ld2HMngTI
R5Oxpt9XqsGoLaQgSttvhoHROEbM4HsPo/Ez3HNm3gu9oG7yubI8mIidr9f3LaBS
Q+JjW7bKDSE8khT3ImhZdo7oI3nfhseFqbqCj3EsVTEhF28lyrI=
=wJ0G
-----END PGP SIGNATURE-----


M
M
Mathieu Othacehe wrote on 8 May 2020 12:01
(name . Efraim Flashner)(address . efraim@flashner.co.il)(address . 41074@debbugs.gnu.org)
87k11mbv9p.fsf@gmail.com
Hello Efraim,

Toggle quote (3 lines)
> + `(,@(match (or (%current-system)
> + (%current-target-system))

If cross-compiling for aarch64, %current-system will be #f and
%current-target-system will be "aarch64-linux-gnu" which does not match
anything below.

I think "system->linux-architecture" could help you here. Otherwise,
this seems fine.

Thanks,

Mathieu
E
E
Efraim Flashner wrote on 14 May 2020 16:24
(name . Mathieu Othacehe)(address . m.othacehe@gmail.com)(address . 41074-done@debbugs.gnu.org)
20200514142436.GQ918@E5400
On Fri, May 08, 2020 at 12:01:22PM +0200, Mathieu Othacehe wrote:
Toggle quote (14 lines)
>
> Hello Efraim,
>
> > + `(,@(match (or (%current-system)
> > + (%current-target-system))
>
> If cross-compiling for aarch64, %current-system will be #f and
> %current-target-system will be "aarch64-linux-gnu" which does not match
> anything below.
>
> I think "system->linux-architecture" could help you here. Otherwise,
> this seems fine.
>

Thanks for the tip. I integrated the system->linux-architecture code
into qemu-minimal and it works nicely.

--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl69VKQACgkQQarn3Mo9
g1H0exAAov7T5m2KfOx6tUABNc8+oksrn8c1LLYJCTHhQSTVX9R06AGSoE6Nt5fF
rkTjhwmhYWFNnlfdJIovSYUQ3uJJSwDaMc1EtJtCuCefalqoCWH60a9kSCeqQV1L
E0Yd8yQppYjWY8RDtpVYyBu9+b72vvmJIPH6vwf2EiGUcaji1iYJChiSlAX4Defk
HoGHIBM9GaSMIRFylExxlumSnEcCSR/a8adAuk+K2CAQrmUwUzxLnVn3azgCVoRb
lj//+KzAf1Ahn5OU/xiPiUT05BUVywG0VnoorWR1Abvzd1NTzkGImcvxt4B3j0fg
2YNOrBi/+f085MSslwHBZLcxlGnyMEL+VZS/olKb1X0FiNcJrCWbyAgL7BTnsJhi
PlCZZesQf/CBMjqWLBUzXlZ5CtX5gY+vkhli83dX9DGrPlpPCSREo4lg3U6hZLt6
ce0JiGk0WiCIycyiGc5UGYLdUksPblziUJbioMvv9pagWomRmb14iL+IRSXqufd9
OAA/T6Q3xvyPZgyqYqQ3EmJ03PsR5VL56oIXUL607AU+RzJgmpx36BZHPClI/Ds9
PVTeW6RuC9W/+Cd3pU2A/4a2FdLsZsflRUXuKvnnu6Xf3jGSqtB6pOsylV5cf/Is
EikaUjqulDZlyrb4vrHefK71K6nKGrkAOTN46ohngttR0/RjRQc=
=KpOr
-----END PGP SIGNATURE-----


Closed
?