This reduces the number of 'add-data-to-store' cache lookups from 3329
to 2743 (hit rate: 27% to 11%) when running:
GUIX_PROFILING=add-data-to-store-cache guix build libreoffice -nd
Execution time of "guix build libreoffice -nd" goes from 1.86s to 1.80s.
* guix/gexp.scm (imported+compiled-modules): Wrap body in 'mcached'.
* guix/gexp.scm (imported+compiled-modules): New procedure.
(lower-gexp): Use it instead of separate calls to 'imported-modules' and
'compiled-modules'.
* guix/gexp.scm (load-path-expression): Use ungexp-splicing instead of
ungexp-native-splicing so that the cross extensions are used when target is
set.
Fixes <https://bugs.gnu.org/37531>.
"herd eval root '(length %load-path)'" on a freshly-booted bare-bones
system now returns 8 instead of 119 before.
* guix/gexp.scm (load-path-expression): Rewrite expression to that it
deletes duplicates.
Previously we would, for example, generate build scripts in the store;
when trying to run them, we'd get a 'read' error due to the presence
of #<foo> syntax in there.
* guix/gexp.scm (gexp->sexp)[self-quoting?]: New procedure.
[reference->sexp]: Check whether the argument in a <gexp-input> box is
self-quoting. Raise a '&gexp-input-error' condition if it's not.
* tests/gexp.scm ("lower-gexp, non-self-quoting input"): New test.
Fixes <https://bugs.gnu.org/36813>.
Reported by Jakob L. Kreuze <zerodaysfordays.sdf.org@sdf.org>.
* guix/gexp.scm (program-file-compiler): Pass #:system and #:target to
'gexp->script'.
(load-path-expression): Add #:system and #:target and honor them.
(gexp->script): Likewise.
* tests/gexp.scm ("program-file #:system"): New test.
* doc/guix.texi (G-Expressions): Adjust accordingly.
* guix/gexp.scm (lower-inputs): Return either <derivation-input> records
or store items.
(lower-reference-graphs): Return file/input pairs.
(<lowered-gexp>)[sources]: New field.
(lower-gexp): Adjust accordingly.
(gexp->input-tuple): Remove.
(gexp->derivation)[graphs-file-names]: Handle only the
'derivation-input?' and 'string?' cases.
Pass #:sources to 'raw-derivation'; ensure #:inputs contains only
<derivation-input> records.
* guix/remote.scm (remote-eval): Adjust to the new <lowered-gexp>
interface.
* tests/gexp.scm ("lower-gexp"): Adjust to expect <derivation-input>
records instead of <gexp-input>
* guix/gexp.scm (gexp-input-thing, gexp-input-output)
(gexp-input-native?): Export.
(lower-inputs): Return <gexp-input> records instead of tuples.
(lower-reference-graphs): Adjust accordingly.
(<lowered-gexp>): New record type.
(lower-gexp, gexp-input->tuple): New procedure.
(gexp->derivation)[%modules]: Remove.
[requested-graft?]: New variable.
[add-modules]: New procedure.
Rewrite in terms of 'lower-gexp'.
(gexp-inputs): Add TODO comment.
* tests/gexp.scm ("lower-gexp"): New test.
This works around <https://bugs.gnu.org/15602> in the context of
modules specified with 'with-imported-modules'.
* guix/gexp.scm (gexp->derivation): Add #:pre-load-modules? parameter
and pass it to 'compiled-modules'.
(compiled-modules): Add #:pre-load-modules? parameter and honor it.
* guix/packages.scm (patch-and-repack): Pass #:pre-load-modules? to
'gexp->derivation'.
Fixes <https://bugs.gnu.org/27476>.
This fixes multi-threaded compilation of this code where syntax
parameters could end up being redefined and where a race condition could
lead a thread to see the "wrong" value of the syntax parameter.
* guix/monads.scm (define-syntax-parameter-once): New macro.
(>>=, return): Use it.
* guix/gexp.scm (define-syntax-parameter-once): New macro.
(current-imported-modules, current-imported-extensions): Use it.
This removes two elements from %LOAD-PATH and %LOAD-COMPILED-PATH of the
'guix' command and thus further reduces the number of 'stat' calls it
makes.
* guix/gexp.scm (load-path-expression): Return #f when MODULES and
EXTENSIONS are both empty.
(gexp->script): Don't emit anything when SET-LOAD-PATH is #f.
Previously we'd use the (sequence M (map P L)) idiom just because 'mapm'
was slower (not specialized for the given monad). This is no longer the
case since commit dcb95c1fc9.
* guix/gexp.scm (lower-inputs): Use (mapm M P L) instead of (sequence
M (map P L)).
(lower-references, gexp->sexp, imported-files): Likewise.
* guix/profiles.scm (profile-derivation): Likewise.
* guix/scripts/environment.scm (inputs->requisites): Likewise.
* guix/scripts/system.scm (copy-closure): Likewise.
This leads to ~25% improvements on things like:
guix system build desktop.tmpl --no-grafts -d
* guix/store.scm (<nix-server>)[object-cache]: New field.
* guix/store.scm (open-connection): Initialize it.
(cache-object-mapping, lookup-cached-object, %mcached): New procedures.
(mcached): New macro.
* guix/gexp.scm (lower-object): Use it.
* guix/grafts.scm (grafting?): New procedure.
Fixes <https://bugs.gnu.org/32966>.
Reported by Clément Lassieur <clement@lassieur.org>.
* guix/gexp.scm (gexp-attribute): Add 'equal?' optional parameter; pass
it to 'delete-duplicates'.
(gexp-modules)[module=?]: New procedure.
Pass it to 'gexp-attribute'.
* tests/gexp.scm ("gexp-modules deletes duplicates"): New test.
This is a followup to 30d722c392.
* guix/gexp.scm (imported-files/derivation): Remove
#:deprecation-warnings. Pass "GUILE_WARN_DEPRECATED=no"
unconditionally to #:env-vars of 'gexp->derivation'. Adjust caller.
(imported-files): Remove #:deprecation-warnings and adjust callers.
(imported-modules): Likewise.
(compiled-modules, gexp->derivation): Adjust accordingly.
* guix/gexp.scm (imported-files/derivation): Add #:symlink? and honor
it.
(imported-files): Pass #:symlink? to 'imported-files/derivation'.
* tests/gexp.scm ("imported-files with file-like objects"): Add 'file=?'
and use it instead of calling 'readlink'.
* guix/gexp.scm (gexp->derivation): Add #:import-creates-derivation?.
Pass #:derivation? to 'imported-modules' and 'compiled-modules'. In -L
argument, check whether MODULES is a derivation.
(%not-slash): New variable.
(file-mapping->tree): New procedure.
(imported-files): Rename to...
(imported-files/derivation): ... this.
(imported-files): New procedure. Rewrite in terms of
'interned-file-tree' when possible; add #:derivation? parameter.
(imported-modules, compiled-modules): Add #:derivation? parameter and
pass it to 'imported-files'.
* guix/packages.scm (patch-and-repack): Pass
#:import-creates-derivation? to 'gexp->derivation'.
* tests/gexp.scm ("imported-files"): Adjust to no longer expect a
derivation.
Until now 'compiled-modules' would override (guix build utils) with its
own. Thus, when asked to build a different (guix build utils),
via #:module-path, it would fail badly because a (guix build utils)
module was already loaded and possibly incompatible with the new one.
This happened when running 'guix pull --branch=core-updates' from
current master: in 'core-updates', (guix build utils) exports
'ignore-error?' but in 'master' it does not. Thus, 'guix pull' would
fail with:
no binding `invoke-error?' in module (guix build utils)
builder for `/gnu/store/…-module-import-compiled.drv' failed with exit code 1
cannot build derivation `/gnu/store/…-compute-guix-derivation.drv': 1 dependencies couldn't be built
This patch fixes it.
* guix/gexp.scm (compiled-modules)[build-utils-hack?]: New variable.
[build]: Load MODULES/build/utils.scm when it exists.
Fixes <https://bugs.gnu.org/31450>.
Reported by Martin Castillo <castilma@uni-bremen.de>.
* guix/gexp.scm (gexp->derivation): Pass #:deprecation-warnings to
'imported-modules'.
(imported-files): Add #:deprecation-warnings and pass #:env-vars to
'gexp->derivation'.
(imported-modules): Add #:deprecation-warnings and pass it to
'imported-files'.
* guix/gexp.scm (<scheme-file>)[splice?]: New field.
(scheme-file): Add #:splice? and pass it to '%scheme-file'.
(scheme-file-compiler): Pass SPLICE? to 'gexp->file'.
(gexp->file): Add #:splice? and honor it.
* tests/gexp.scm ("gexp->file + #:splice?"): New test.
("gexp->derivation & with-imported-module & computed module"): Use
#:splice? #t.
* guix/gexp.scm (compiled-modules)[build]: Add 'processed' parameter to
'process-entry' and 'process-directory'. Print a message before each
'compile-file' call.