all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: 20239@debbugs.gnu.org
Subject: bug#20239: [wishlist] Add build hook to build for other platforms using qemu
Date: Tue, 28 Mar 2017 18:04:25 +0200	[thread overview]
Message-ID: <87tw6d1j7a.fsf@gnu.org> (raw)
In-Reply-To: <87y3vvziqh.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 24 Mar 2017 00:16:54 +0100")

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

ludo@gnu.org (Ludovic Courtès) skribis:

> Mark H Weaver <mhw@netris.org> skribis:
>
>> It would be great if we had a build hook to enable guix-daemon to
>> natively build packages for any system supported by qemu, by running the
>> build processes within qemu.
>
> QEMU has a ‘qemu-binfmt-conf.sh’ script that installs binfmt_misc
> handlers for all the architecture-specific ELF variants.  Once you’ve
> run this script, you can transparently run, say, ARM executables (the
> kernel takes care of invoking ‘qemu-arm’ for you).

[...]

> Then we just need to tell the daemon to not complain (“but I’m an
> 'x86_64-linux'”).

The attached patch does that.

However, there’s an added complication: the file name of the qemu-*
executables registered in binfmt_misc are apparently resolved relative
to the root directory of the process that does ‘execve’.

So we would need to add a guix-daemon --chroot-directory=DIR argument
for each element in the closure of QEMU.  Not great.

Thoughts?

Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1631 bytes --]

diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 9b7bb5391..bca75a4f9 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1672,15 +1672,6 @@ void DerivationGoal::startBuilder()
     f.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
     startNest(nest, lvlInfo, f % showPaths(missingPaths) % curRound % nrRounds);
 
-    /* Right platform? */
-    if (!canBuildLocally(drv.platform)) {
-        if (settings.printBuildTrace)
-            printMsg(lvlError, format("@ unsupported-platform %1% %2%") % drvPath % drv.platform);
-        throw Error(
-            format("a `%1%' is required to build `%3%', but I am a `%2%'")
-            % drv.platform % settings.thisSystem % drvPath);
-    }
-
     /* Note: built-in builders are *not* running in a chroot environment so
        that we can easily implement them in Guile without having it as a
        derivation input (they are running under a separate build user,
@@ -2305,6 +2296,18 @@ void DerivationGoal::runChild()
 
         execve(drv.builder.c_str(), stringsToCharPtrs(args).data(), stringsToCharPtrs(envStrs).data());
 
+	int error = errno;
+
+	/* Right platform? */
+	if (error == ENOEXEC && !canBuildLocally(drv.platform)) {
+	    if (settings.printBuildTrace)
+		printMsg(lvlError, format("@ unsupported-platform %1% %2%") % drvPath % drv.platform);
+	    throw Error(
+		format("a `%1%' is required to build `%3%', but I am a `%2%'")
+		% drv.platform % settings.thisSystem % drvPath);
+	}
+
+	errno = error;
         throw SysError(format("executing `%1%'") % drv.builder);
 
     } catch (std::exception & e) {

  reply	other threads:[~2017-03-28 16:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 21:37 bug#20239: [wishlist] Add build hook to build for other platforms using qemu Mark H Weaver
2015-09-11 17:36 ` Ludovic Courtès
2017-03-23 23:16 ` Ludovic Courtès
2017-03-28 16:04   ` Ludovic Courtès [this message]
2018-01-09 16:14     ` bug#20239: [PATCH 0/4] Transparent emulation with QEMU and binfmt_misc Ludovic Courtès
2018-01-09 16:14       ` bug#20239: [PATCH 1/4] services: Add qemu-binfmt Ludovic Courtès
2018-01-09 20:41         ` Danny Milosavljevic
2018-01-11 13:46         ` Ludovic Courtès
2018-01-09 16:14       ` bug#20239: [PATCH 2/4] services: guix: Add 'chroot-directories' field Ludovic Courtès
2018-01-09 20:48         ` Danny Milosavljevic
2018-01-09 16:14       ` bug#20239: [PATCH 3/4] services: qemu-binfmt: Extend guix-daemon with extra chroot directories Ludovic Courtès
2018-01-09 20:43         ` Danny Milosavljevic
2018-01-09 16:14       ` bug#20239: [PATCH 4/4] daemon: Always try to execute the builder regardless of the platform Ludovic Courtès
2018-01-09 20:34         ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tw6d1j7a.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=20239@debbugs.gnu.org \
    --cc=mhw@netris.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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.