From: "Ludovic Courtès" <ludo@gnu.org>
To: 45102@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#45102] [PATCH 3/4] guix: 'guile' executable ignores GUILE_LOAD_PATH during startup.
Date: Mon, 7 Dec 2020 16:29:58 +0100 [thread overview]
Message-ID: <20201207152959.28864-3-ludo@gnu.org> (raw)
In-Reply-To: <20201207152959.28864-1-ludo@gnu.org>
When starting the 'guix' command, this ensures Guile modules are
immediately found instead of being search for in other directories.
This reduces the number of 'stat' calls during startup when
GUILE_LOAD_PATH is set to (almost) that of "env -i $(type -P guix)".
* gnu/packages/aux-files/guile-launcher.c (load_path)
(load_compiled_path): New variables.
(inner_main): Restore GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH and
set %load-path and %load-compiled-path accordingly.
(main): Save GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH and unset them.
---
gnu/packages/aux-files/guile-launcher.c | 46 +++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-files/guile-launcher.c
index 886ede2846..1dd5d77e66 100644
--- a/gnu/packages/aux-files/guile-launcher.c
+++ b/gnu/packages/aux-files/guile-launcher.c
@@ -1,5 +1,5 @@
/* GNU Guix --- Functional package management for GNU
- Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018
+ Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018,2020
Free Software Foundation, Inc.
Copyright (C) 2020 Ludovic Courtès <ludo@gnu.org>
@@ -19,14 +19,47 @@
along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. */
/* This file implements a variant of the 'guile' executable that does not
- complain about locale issues. */
+ complain about locale issues and arranges to reduce startup time by
+ ignoring GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH until it has
+ booted. */
+#include <stdlib.h>
+#include <string.h>
#include <locale.h>
#include <libguile.h>
+/* Saved values of GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH. */
+static const char *load_path, *load_compiled_path;
+
static void
inner_main (void *unused, int argc, char **argv)
{
+ if (load_path != NULL)
+ {
+ setenv ("GUILE_LOAD_PATH", load_path, 1);
+ SCM load_path_var =
+ scm_c_public_lookup ("guile", "%load-path");
+ SCM addition =
+ scm_parse_path (scm_from_locale_string (load_path), SCM_EOL);
+ scm_variable_set_x (load_path_var,
+ scm_append
+ (scm_list_2 (scm_variable_ref (load_path_var),
+ addition)));
+ }
+
+ if (load_compiled_path != NULL)
+ {
+ setenv ("GUILE_LOAD_COMPILED_PATH", load_compiled_path, 1);
+ SCM load_compiled_path_var =
+ scm_c_public_lookup ("guile", "%load-compiled-path");
+ SCM addition =
+ scm_parse_path (scm_from_locale_string (load_compiled_path), SCM_EOL);
+ scm_variable_set_x (load_compiled_path_var,
+ scm_append
+ (scm_list_2 (scm_variable_ref (load_compiled_path_var),
+ addition)));
+ }
+
scm_shell (argc, argv);
}
@@ -40,6 +73,15 @@ main (int argc, char **argv)
which is always preferable over the C locale. */
setlocale (LC_ALL, "en_US.utf8");
+ const char *str;
+ str = getenv ("GUILE_LOAD_PATH");
+ load_path = str != NULL ? strdup (str) : NULL;
+ str = getenv ("GUILE_LOAD_COMPILED_PATH");
+ load_compiled_path = str ? strdup (str) : NULL;
+
+ unsetenv ("GUILE_LOAD_PATH");
+ unsetenv ("GUILE_LOAD_COMPILED_PATH");
+
scm_install_gmp_memory_functions = 1;
scm_boot_guile (argc, argv, inner_main, 0);
return 0; /* never reached */
--
2.29.2
next prev parent reply other threads:[~2020-12-07 15:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 15:21 [bug#45102] [PATCH 0/4] Making fewer 'stat' calls during startup Ludovic Courtès
2020-12-07 15:29 ` [bug#45102] [PATCH 1/4] build: 'script/guix' uses our own 'guile' executable Ludovic Courtès
2020-12-07 15:29 ` [bug#45102] [PATCH 2/4] self: Move Guile early in the module search path Ludovic Courtès
2020-12-07 15:29 ` Ludovic Courtès [this message]
2020-12-07 15:29 ` [bug#45102] [PATCH 4/4] self: Remove the empty string from '%load-extensions' Ludovic Courtès
2020-12-08 13:50 ` [bug#45102] [PATCH 0/4] Making fewer 'stat' calls during startup Mathieu Othacehe
2020-12-08 20:24 ` Ludovic Courtès
2020-12-11 18:12 ` bug#45102: " Ludovic Courtès
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=20201207152959.28864-3-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=45102@debbugs.gnu.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.