From: "Ludovic Courtès" <ludo@gnu.org>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 43513@debbugs.gnu.org
Subject: bug#43513: json-c build failure (on armhf-linux) while trying to build u-boot
Date: Fri, 25 Sep 2020 12:13:40 +0200 [thread overview]
Message-ID: <87wo0i17vv.fsf@gnu.org> (raw)
In-Reply-To: <20200921134855.2ed40eb0@scratchpost.org> (Danny Milosavljevic's message of "Mon, 21 Sep 2020 14:22:26 +0200")
Hi Danny!
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> 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 getdents64
> (on 32 bits!) and then (rightfully) checking whether d_off and the inode number
> fit into their own (32 bits/entry) struct, which they don't (the thing they get
> from the kernel is 64 bits/entry).
Looks very much like the CMake-on-emulated-hardware issue several of us
encountered before:
https://issues.guix.gnu.org/38454#3
https://issues.guix.gnu.org/42448
Glad you found an explanation!
(I see you also posted <https://issues.guix.gnu.org/43591>.)
> See also https://lore.kernel.org/lkml/20181229015453.GA6310@bombadil.infradead.org/T/
> for an analysis.
>
> See also https://sourceware.org/bugzilla/show_bug.cgi?id=23960 for a discussion.
Woow.
> 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 process the
> result. "The truth? It can't handle the truth."
OK.
> 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=64 and co). In 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 <dirent.h>
> has been included without anyone specifying -D_FILE_OFFSET_BITS=64--that would
> make finding these problems a LOT easier; if possible, emit that compile-time
> error only if readdir is actually called anywhere).
Yes; that user-space should be built with -D_FILE_OFFSET_BITS=64 is also
the conclusion at
<https://sourceware.org/bugzilla/show_bug.cgi?id=23960#c32>.
Let’s fix CMake (and JSON-C?) in ‘core-updates’ or ‘staging’ (using a
graft for CMake wouldn’t help because CMake is used at build time.)
> +(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=" 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))))))))
It doesn’t make sense to cross-compile from x86_64 to i686. Instead we
should use a native build, but an i686 one:
(package/inherit qemu
(arguments `(#:system "i686-linux" ,@(package-arguments qemu))))
Likewise for AArch64/ARMv7.
How does that sound?
Thanks,
Ludo’.
next prev parent reply other threads:[~2020-09-25 10:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-19 15:36 bug#43513: json-c build failure (on armhf-linux) while trying to build u-boot Danny Milosavljevic
2020-09-19 21:05 ` Danny Milosavljevic
2020-09-21 12:22 ` Danny Milosavljevic
2020-09-21 12:23 ` Danny Milosavljevic
2020-09-21 12:44 ` Danny Milosavljevic
2020-09-25 10:13 ` Ludovic Courtès [this message]
2020-09-25 11:13 ` Danny Milosavljevic
2020-09-25 11:18 ` Danny Milosavljevic
2020-09-25 16:00 ` Ludovic Courtès
2020-09-25 16:25 ` Danny Milosavljevic
2020-09-26 10:53 ` Danny Milosavljevic
2020-09-26 17:20 ` Andreas Enge
2020-09-27 9:50 ` Andreas Enge
2020-09-27 11:32 ` Danny Milosavljevic
2020-09-29 10:25 ` Ludovic Courtès
2020-09-29 10:43 ` Danny Milosavljevic
2020-09-29 11:05 ` Danny Milosavljevic
2020-09-30 9:10 ` Ludovic Courtès
2020-09-30 11:27 ` Danny Milosavljevic
2020-09-30 12:17 ` Andreas Enge
2020-10-01 16:18 ` Bengt Richter
2020-09-25 16:02 ` Ludovic Courtès
2020-09-25 16:23 ` Danny Milosavljevic
2020-09-25 16:37 ` Danny Milosavljevic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wo0i17vv.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=43513@debbugs.gnu.org \
--cc=dannym@scratchpost.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).