From: "Ludovic Courtès" <ludo@gnu.org>
To: Christopher Baines <mail@cbaines.net>
Cc: 63263@debbugs.gnu.org
Subject: [bug#63263] [PATCH] gexp: Stop generating unreadable builder scripts.
Date: Thu, 04 May 2023 14:47:23 +0200 [thread overview]
Message-ID: <87zg6kqn50.fsf@gnu.org> (raw)
In-Reply-To: <20230504112448.22462-1-mail@cbaines.net> (Christopher Baines's message of "Thu, 4 May 2023 12:24:48 +0100")
Hi,
Christopher Baines <mail@cbaines.net> skribis:
> In Guile, it's possible to produce output from write that can't be read, and
> this applies to the code staged through g-expressions for derivations. This
> commit detects this early when the derivation is being created, rather than
> leaving the error to happen when the derivation is built.
>
> This is important as it means that tools like guix lint will indicate that
> there's a problem, hopefully reducing the number of broken derivations in
> Guix.
>
> * guix/gexp.scm (gexp->derivation): Check that the builder script can be read.
Calling ‘read’ on every generated sexp is definitely not something we
should do, performance-wise.
Commit 24ab804ce11fe12ff49cd144a3d9c4bfcf55b41c addressed that to some
extent. It works in examples like this:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,lower (computed-file "foo" #~(list #$(current-module)))
While executing meta-command:
ERROR:
1. &gexp-input-error: #<directory (guile-user) 7f26d5918c80>
--8<---------------cut here---------------end--------------->8---
… where ‘current-module’ returns a non-serializable object.
I think the problem you’re trying to address that we frequently
encounter is old-style packages that end up splicing gexps inside sexps,
as in:
(package
;; …
(arguments `(#:phases (modify-phases whatever ,#~doh!))))
Is that right?
The problem here is that ‘sexp->gexp’, which was added precisely as an
optimization for build systems¹, does not check the sexp it’s given.
Example:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,lower (computed-file "foo" (sexp->gexp `(list a b c ,(current-module))))
$19 = #<derivation /gnu/store/j5rgrmdzk4mic67zkal4759bcm5xbk1c-foo.drv => 7f26baf56be0>
scheme@(guile-user)> (sexp->gexp `(list a b c ,(current-module)))
$20 = #<gexp (list a b c #<directory (guile-user) 7f26d5918c80>) 7f26bbf2f090>
--8<---------------cut here---------------end--------------->8---
Oops!
It would be tempting to change ‘sexp->gexp’ to traverse the sexp in
search of non-serializable things… but that’d defeat the whole point of
‘sexp->gexp’.
How about a linter instead, with the understanding that use of sexps in
packages is vanishing? Perhaps coupled with a ‘guix style’ automatic
rewriter.
Thanks,
Ludo’.
¹ Packages would get long lists/trees in their ‘arguments’ field.
Traversing them in search of lowerable objects is costly, and
‘sexp->gexp’ was introduced precisely do we don’t have to traverse the
sexp. (Gexps are designed so that no such traversal is necessary at
run time.)
next prev parent reply other threads:[~2023-05-04 12:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 11:24 [bug#63263] [PATCH] gexp: Stop generating unreadable builder scripts Christopher Baines
2023-05-04 12:47 ` Ludovic Courtès [this message]
2023-05-04 12:57 ` Christopher Baines
2023-05-04 19:14 ` Josselin Poiret via Guix-patches via
2023-05-06 8:05 ` Christopher Baines
2023-05-05 21:45 ` Ludovic Courtès
2023-05-06 7:39 ` Christopher Baines
2023-05-10 15:22 ` Ludovic Courtès
2023-05-10 16:02 ` Christopher Baines
2023-09-01 14:16 ` Maxim Cournoyer
2023-09-02 10:36 ` bug#63263: " Christopher Baines
2023-09-03 14:54 ` [bug#63263] " Maxim Cournoyer
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=87zg6kqn50.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=63263@debbugs.gnu.org \
--cc=mail@cbaines.net \
/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.