From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 8BB+IVSbaF/LegAA0tVLHw (envelope-from ) for ; Mon, 21 Sep 2020 12:23:48 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qCtVHVSbaF9CNQAAbx9fmQ (envelope-from ) for ; Mon, 21 Sep 2020 12:23:48 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 287EF940365 for ; Mon, 21 Sep 2020 12:23:47 +0000 (UTC) Received: from localhost ([::1]:34278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKKrA-0002UZ-Cd for larch@yhetil.org; Mon, 21 Sep 2020 08:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKKqU-0002Ty-W7 for bug-guix@gnu.org; Mon, 21 Sep 2020 08:23:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42094) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKKqU-000824-Mj for bug-guix@gnu.org; Mon, 21 Sep 2020 08:23:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kKKqU-00032i-Iw for bug-guix@gnu.org; Mon, 21 Sep 2020 08:23:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#43513: json-c build failure (on armhf-linux) while trying to build u-boot Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 21 Sep 2020 12:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43513 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 43513@debbugs.gnu.org, Received: via spool by 43513-submit@debbugs.gnu.org id=B43513.160069097011661 (code B ref 43513); Mon, 21 Sep 2020 12:23:02 +0000 Received: (at 43513) by debbugs.gnu.org; 21 Sep 2020 12:22:50 +0000 Received: from localhost ([127.0.0.1]:53640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kKKqH-000321-VO for submit@debbugs.gnu.org; Mon, 21 Sep 2020 08:22:50 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:52604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kKKqE-00031r-UL for 43513@debbugs.gnu.org; Mon, 21 Sep 2020 08:22:48 -0400 Received: from localhost (80-110-126-103.cgn.dynamic.surfer.at [80.110.126.103]) by dd26836.kasserver.com (Postfix) with ESMTPSA id 2DCFB336013F; Mon, 21 Sep 2020 14:22:45 +0200 (CEST) Date: Mon, 21 Sep 2020 14:22:26 +0200 From: Danny Milosavljevic Message-ID: <20200921134855.2ed40eb0@scratchpost.org> In-Reply-To: <20200919173628.423331da@scratchpost.org> References: <20200919173628.423331da@scratchpost.org> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/vPS14S29omxnO4TH9b/IuZZ"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: -1.11 X-TUID: 7ZNuvUiXVz8T --Sig_/vPS14S29omxnO4TH9b/IuZZ Content-Type: multipart/mixed; boundary="MP_/Viv1tPanKIDOnV68zPcOVbm" --MP_/Viv1tPanKIDOnV68zPcOVbm Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I found the underlying cause of the problem with qemu transparent emulation: * qemu transparent emulator has 64 bit registers * the thing it's emulating has 32 bit registers * The glibc in the distro that is running in the emulator is using getdents= 64 (on 32 bits!) and then (rightfully) checking whether d_off and the inode nu= mber fit into their own (32 bits/entry) struct, which they don't (the thing they= get from the kernel is 64 bits/entry). See also https://lore.kernel.org/lkml/20181229015453.GA6310@bombadil.infrad= ead.org/T/ for an analysis. See also https://sourceware.org/bugzilla/show_bug.cgi?id=3D23960 for a disc= ussion. Least-shitty workaround: Use a 32-bit qemu (yes, a qemu compiled on 32 bit) on a 64 bit machine for transparent emulation of ANOTHER 32-bit machine. That way, the kernel can know that there's a 32 bit user lurking somewhere = up the call chain that is calling getdents64 and is not actually able to proce= ss the result. "The truth? It can't handle the truth." The right fix: One could also tell all the packages in the emulated system to use the large file size API (-D_FILE_OFFSET_BITS=3D64 and co). I= n this case cmake is affected--but it could be any number of things. I think that= that is the only good fix (we could also add a compile-time check whether has been included without anyone specifying -D_FILE_OFFSET_BITS=3D64--that = would make finding these problems a LOT easier; if possible, emit that compile-ti= me error only if readdir is actually called anywhere). For the workaround, we could adapt Guix system's gnu/services/virtualizatio= n.scm so it uses a qemu built for the 32-bit variant of the host architecture if = it's emulating a 32 bit system. So qemu could be compiled for i686 if the host is x86_64 and the emulated system is armhf, qemu could be compiled for armhf if the host is aarch64 and the emulated sy= stem is armhf and so on. That also means that if a host system is 64 bits and DOES NOT HAVE a 32 bit pendant target, then the emulation of a 32 bit system is going to be imperf= ect. One way to fix that would be to fix the kernel to accept an argument on the getdents64 syscall (and similar ones) that tells it whether the user wa= nts to have 64 bit offsets or 32 bit offsets[1]. Right now, from user space, t= hat is only possible via process personality flags. And those would switch the entire qemu executable over to 32 bits, which we don't want (qemu itself has to do stuff using kernel syscalls, so it needs to be capable of 64 bits if it itself is 64 bits). And I think that even that case is not being handled in the kernel correctly. So this fix cannot be done. @Ludo: Anyway, I have a question on how to replicate what "guix build --target=3Di= 686..." does, in the guix service definition. How can I make it use package-cross-derivation instead of package-derivation ? See attachment. With the attachment and the service definition (service qemu-binfmt-service-type (qemu-binfmt-configuration (platforms (lookup-qemu-platforms "arm")) (guix-support? #t))) in order to emulate ARM on x86_64 I eventually get: >Building qemu-minimal for i686 (That's what I want!) >[...] >starting phase `configure' > >ERROR: pkg-config binary 'i686-unknown-linux-gnu-pkg-config' not found pkg-config has not been cross-compiled... That's because it's not using package-cross-derivation, I guess. >command "./configure" "--cc=3D/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-= gcc-7.5.0/bin/gcc" "--host-cc=3D/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk= -gcc-7.5.0/bin/gcc" "--disable-debug-info" "--enable-virtfs" "--prefix=3D/g= nu/store/80ljf47lrh8arrzjmkrrqxghc0k67b3s-qemu-minimal-5.1.0" "--sysconfdir= =3D/etc" "--cross-prefix=3Di686-unknown-linux-gnu-" "--target-list=3Di386-s= oftmmu,x86_64-softmmu" failed with status 1 I think that "--cc" should use ,(cc-for-target) at all times. Better this: diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.= scm index 53e9dde125..bf712afd4a 100644 --- a/gnu/packages/virtualization.scm +++ b/gnu/packages/virtualization.scm @@ -227,7 +227,7 @@ (setenv "LDFLAGS" "-lrt") (apply invoke `("./configure" - ,(string-append "--cc=3D" (which "gcc")) + ,(string-append "--cc=3D" ,(cc-for-target)) ;; Some architectures insist on using HOST_CC ,(string-append "--host-cc=3D" (which "gcc")) "--disable-debug-info" ; save build space [1] A way for userspace to tell the kernel that is to use getdents instad of getdents64 on 32 bits, like it used to. But they don't want to do that any= more. Another way would be for qemu to translate a syscall getdents64 from the gu= est to getdents on the host if the machine they are emulating is 32 bits. But = that would mean that getdents on a 64 bit host would still have to act like it's 32 bits and translate the d_off accordingly. That's not guaranteed[2]. Or even using the old readdir syscall. [2] Linux-5.8.8: [... CONFIG_COMPAT ...] SYSCALL_DEFINE3(getdents, unsigned int, fd, struct linux_dirent __user *, dirent, unsigned int, count) { struct fd f; struct getdents_callback buf =3D { .ctx.actor =3D filldir, .count =3D count, .current_dir =3D dirent }; int error; f =3D fdget_pos(fd); if (!f.file) return -EBADF; error =3D iterate_dir(f.file, &buf.ctx); if (error >=3D 0) error =3D buf.error; if (buf.prev_reclen) { struct linux_dirent __user * lastdirent; lastdirent =3D (void __user *)buf.current_dir - buf.prev_re= clen; if (put_user(buf.ctx.pos, &lastdirent->d_off)) error =3D -EFAULT; else error =3D count - buf.count; } fdput_pos(f); return error; } It's not guaranteed. --MP_/Viv1tPanKIDOnV68zPcOVbm Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=services-qemu-transparent-emulation-make-more-exact.patch diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.= scm index 20e104f48c..77f15ba07b 100644 --- a/gnu/services/virtualization.scm +++ b/gnu/services/virtualization.scm @@ -23,6 +23,7 @@ #:use-module (gnu bootloader grub) #:use-module (gnu image) #:use-module (gnu packages admin) + #:use-module (gnu packages cross-base) #:use-module (gnu packages ssh) #:use-module (gnu packages virtualization) #:use-module (gnu services base) @@ -554,12 +555,13 @@ potential infinite waits blocking libvirt.")) =20 ;; Platforms that QEMU can emulate. (define-record-type - (qemu-platform name family magic mask) + (qemu-platform name family register-width magic mask) qemu-platform? - (name qemu-platform-name) ;string - (family qemu-platform-family) ;string - (magic qemu-platform-magic) ;bytevector - (mask qemu-platform-mask)) ;bytevector + (name qemu-platform-name) ;string + (family qemu-platform-family) ;string + (register-width qemu-platform-register-width) ;int, in b= its + (magic qemu-platform-magic) ;bytevector + (mask qemu-platform-mask)) ;bytevector =20 (define-syntax bv (lambda (s) @@ -576,123 +578,123 @@ potential infinite waits blocking libvirt.")) ;;; 'scripts/qemu-binfmt-conf.sh' in QEMU. =20 (define %i386 - (qemu-platform "i386" "i386" + (qemu-platform "i386" "i386" 32 (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x03\x00") (bv "\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %i486 - (qemu-platform "i486" "i386" + (qemu-platform "i486" "i386" 32 (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x06\x00") (bv "\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %alpha - (qemu-platform "alpha" "alpha" + (qemu-platform "alpha" "alpha" 64 (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x26\x90") (bv "\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %arm - (qemu-platform "arm" "arm" + (qemu-platform "arm" "arm" 32 (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x28\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %armeb - (qemu-platform "armeb" "arm" + (qemu-platform "armeb" "arm" 32 (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x28") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %sparc - (qemu-platform "sparc" "sparc" + (qemu-platform "sparc" "sparc" 32 ; FIXME check (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x02") (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %sparc32plus - (qemu-platform "sparc32plus" "sparc" + (qemu-platform "sparc32plus" "sparc" 32 ; FIXME check (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x12") (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %ppc - (qemu-platform "ppc" "ppc" + (qemu-platform "ppc" "ppc" 32 (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x14") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %ppc64 - (qemu-platform "ppc64" "ppc" + (qemu-platform "ppc64" "ppc" 64 (bv "\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x15") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %ppc64le - (qemu-platform "ppc64le" "ppcle" + (qemu-platform "ppc64le" "ppcle" 64 (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x15\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\x00"))) =20 (define %m68k - (qemu-platform "m68k" "m68k" + (qemu-platform "m68k" "m68k" 32 (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x04") (bv "\xff\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 ;; XXX: We could use the other endianness on a MIPS host. (define %mips - (qemu-platform "mips" "mips" + (qemu-platform "mips" "mips" 32 (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x08") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %mipsel - (qemu-platform "mipsel" "mips" + (qemu-platform "mipsel" "mips" 32 (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x08\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %mipsn32 - (qemu-platform "mipsn32" "mips" + (qemu-platform "mipsn32" "mips" 32 ; FIXME check (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x08") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %mipsn32el - (qemu-platform "mipsn32el" "mips" + (qemu-platform "mipsn32el" "mips" 32 ; FIXME check (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x08\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %mips64 - (qemu-platform "mips64" "mips" + (qemu-platform "mips64" "mips" 64 (bv "\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x08") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %mips64el - (qemu-platform "mips64el" "mips" + (qemu-platform "mips64el" "mips" 64 (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x08\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %riscv32 - (qemu-platform "riscv32" "riscv" + (qemu-platform "riscv32" "riscv" 32 ; FIXME (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\xf3\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %riscv64 - (qemu-platform "riscv64" "riscv" + (qemu-platform "riscv64" "riscv" 64 (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\xf3\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %sh4 - (qemu-platform "sh4" "sh4" + (qemu-platform "sh4" "sh4" 32 (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\x2a\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %sh4eb - (qemu-platform "sh4eb" "sh4" + (qemu-platform "sh4eb" "sh4" 32 (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x2a") (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %s390x - (qemu-platform "s390x" "s390x" + (qemu-platform "s390x" "s390x" 64 (bv "\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x00\x02\x00\x16") (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 (define %aarch64 - (qemu-platform "aarch64" "arm" + (qemu-platform "aarch64" "arm" 64 (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\= x00\x02\x00\xb7\x00") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xfe\xff\xff\xff"))) =20 (define %hppa - (qemu-platform "hppa" "hppa" + (qemu-platform "hppa" "hppa" 32 (bv "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00= \x00\x00\x00\x00\x02\x00\x0f") (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff= \xff\xff\xff\xff\xfe\xff\xff"))) =20 @@ -712,12 +714,48 @@ potential infinite waits blocking libvirt.")) qemu-binfmt-configuration make-qemu-binfmt-configuration qemu-binfmt-configuration? (qemu qemu-binfmt-configuration-qemu - (default qemu)) + (default qemu-minimal)) (platforms qemu-binfmt-configuration-platforms (default '())) ;safest default (guix-support? qemu-binfmt-configuration-guix-support? (default #f))) =20 +(define (register-width system) + (match (%current-system) + ("i686-linux" 32) + ("armhf-linux" 32) + ("aarch64-linux" 64) + ("x86_64-linux" 64))) + +(define (closest-cross-compiled-qemu qemu target-bits) + "Cross-compile QEMU for the given TARGET-BITS platform that is closest to +the actual host architecture, if possible. This is in order to prevent +https://lore.kernel.org/lkml/20181229015453.GA6310@bombadil.infradead.org/= T/" + (define (cross-compiled-qemu target) + (package + (inherit qemu) + (arguments + (substitute-keyword-arguments (package-arguments qemu) + ((#:configure-flags flags) + `(cons ,(string-append "--cross-prefix=3D" target "-") + ,flags)))) + (native-inputs + `(("cross-gcc" ,(cross-gcc target)) + ("cross-binutils" ,(cross-binutils target)) + ,@(package-native-inputs qemu))))) + (match target-bits + (64 qemu) + (32 (match (register-width (%current-system)) + (32 qemu) + (64 (match (%current-system) + ("x86_64-linux" + (cross-compiled-qemu (nix-system->gnu-triplet "i686-linux"))) + ("aarch64-linux" + (cross-compiled-qemu "arm-linux-gnueabihf")) + (_ (begin + ;; TODO: Print warning + qemu)))))))) + (define (qemu-platform->binfmt qemu platform) "Return a gexp that evaluates to a binfmt string for PLATFORM, using the given QEMU package." @@ -732,12 +770,13 @@ given QEMU package." (bytevector->u8-list bv)))) =20 (match platform - (($ name family magic mask) + (($ name family register-width magic mask) ;; See 'Documentation/binfmt_misc.txt' in the kernel. #~(string-append ":qemu-" #$name ":M::" #$(bytevector->binfmt-string magic) ":" #$(bytevector->binfmt-string mask) - ":" #$(file-append qemu "/bin/qemu-" name) + ":" #$(file-append (closest-cross-compiled-qemu qemu= register-width) + "/bin/qemu-" name) ":" ;FLAGS go here )))) =20 --MP_/Viv1tPanKIDOnV68zPcOVbm-- --Sig_/vPS14S29omxnO4TH9b/IuZZ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl9omwIACgkQ5xo1VCww uqUOEAf/f5fivmpMwTEJus4fOX94uPxsd0BYqyeXJ4TKJDlnyxQ3Fn9Ev8H56hb2 CN5ywUbG0bB8yiVvRJmPJxvuCFf4/873wWVgp9U2cBZRwsaHRV6PHcTcyUZ2ERhs ptY9SjNzuNYwOnyjPh/+mUpm6KrK8strQt8FJSYRj/vPFZ2HUhiwE4wWatRRqxlX 0ic3If+tDIF2Y/wNEZgg03PX73ncjOZ+0syABFt6iyYC7HwVf1tEer9ogL3KQX9E DbUteMlYy8veppFalQt1pILyRS9hbEJas3nWyfWy3DgXZb2kujIzixJpoUHEpf3z RY97rNeURQEBgkVACHR2kUOwWiAipg== =beSN -----END PGP SIGNATURE----- --Sig_/vPS14S29omxnO4TH9b/IuZZ--