From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GHR+O+1Kzl+CYgAA0tVLHw (envelope-from ) for ; Mon, 07 Dec 2020 15:31:57 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 4MFTN+1Kzl/7LQAA1q6Kng (envelope-from ) for ; Mon, 07 Dec 2020 15:31:57 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9C3B99404D7 for ; Mon, 7 Dec 2020 15:31:57 +0000 (UTC) Received: from localhost ([::1]:50448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmIUW-0004YE-IL for larch@yhetil.org; Mon, 07 Dec 2020 10:31:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmITf-00040O-6I for guix-patches@gnu.org; Mon, 07 Dec 2020 10:31:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:43402) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmITe-0006LO-Uo for guix-patches@gnu.org; Mon, 07 Dec 2020 10:31:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kmITe-0003yV-Rp for guix-patches@gnu.org; Mon, 07 Dec 2020 10:31:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45102] [PATCH 3/4] guix: 'guile' executable ignores GUILE_LOAD_PATH during startup. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 07 Dec 2020 15:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45102 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45102@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 45102-submit@debbugs.gnu.org id=B45102.160735502215199 (code B ref 45102); Mon, 07 Dec 2020 15:31:02 +0000 Received: (at 45102) by debbugs.gnu.org; 7 Dec 2020 15:30:22 +0000 Received: from localhost ([127.0.0.1]:54942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kmIT0-0003x5-EF for submit@debbugs.gnu.org; Mon, 07 Dec 2020 10:30:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kmISy-0003wR-KM for 45102@debbugs.gnu.org; Mon, 07 Dec 2020 10:30:20 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57179) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmISt-0005xC-EF; Mon, 07 Dec 2020 10:30:15 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48438 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kmISq-0000cR-J7; Mon, 07 Dec 2020 10:30:13 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 7 Dec 2020 16:29:58 +0100 Message-Id: <20201207152959.28864-3-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201207152959.28864-1-ludo@gnu.org> References: <20201207152959.28864-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.80 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9C3B99404D7 X-Spam-Score: -1.80 X-Migadu-Scanner: ns3122888.ip-94-23-21.eu X-TUID: GXLe7P3rxhhq 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 @@ -19,14 +19,47 @@ along with GNU Guix. If not, see . */ /* 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 +#include #include #include +/* 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