From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id sJOZGM/Uy2VCgQEAqHPOHw:P1 (envelope-from ) for ; Tue, 13 Feb 2024 21:45:03 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id sJOZGM/Uy2VCgQEAqHPOHw (envelope-from ) for ; Tue, 13 Feb 2024 21:45:03 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=f3ou0R0t; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707857103; a=rsa-sha256; cv=none; b=pGp3/2qInPly2EzOdi0MHn/y2ijrf5Iycy+Wz05EoownBz2DW8W29wak3aszuV65swLXh9 aMuHYNUVw5FNd9yvYzSJgKb1uRv/Z3D20XxNmiU1ZnrJkbFuhgOvSOzJXZPyqojWFMlcU9 2NkmUfk9A2rbjYqaYB8SvJfZySYPk2IqTrSu+JPAUTe1oNHsH2Z+QoaiWXRxW6ppjznQ/w VIyuAPcHVLL+QETEWYKU03TpQoEhDMZx2GyotvNxl237KrnF7aNED5W885C7IuZ+MpFr0c 3L0PFCR+afzVYo8VlQJC7SXgJtS3Ajtvuric4XAeLHQFF0cDMl32pzJjiomwrA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=f3ou0R0t; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707857103; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=unx0WlA09N7LGaCQR5w6UZT4NRsTI6qSoHqG9oNqu1k=; b=k+KUPLjgsQyUzWLXQ5XUlu9QmKfGZnrkUKAl2e9yNBhXCcipqB5KtJ4XMK1U6s6Gh/UVgj 0c1pgC3PA1EPIxel+9zsbOgq+rhDjlVMA1C6VjzPJJ/PL8yDCxLL5EQOzroj84sOVtegVd uK9YP16yjZTP6FslRtjp4KKG4LRqOQR0yfavZQqacwUwiMtklgRi+I+SEltaWJlfyF0Lb5 OSq4bk8LxMd7zt6vSqv8/vyq9sruVQ9NQrQC84lA9ZCuHZc2qZt0DSDsxujhxfxm1Sm/RW GvovZWU4g6550vrpm1CnQ2Jqm88Z8Xy71eS9SkL5+60KhB9j0fEPwFCFLZKKPQ== 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 07E4C77A36 for ; Tue, 13 Feb 2024 21:45:03 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyW3-0007uy-Ow; Tue, 13 Feb 2024 14:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZyVX-0007qv-JF for guix-patches@gnu.org; Tue, 13 Feb 2024 14:31:58 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZyVO-0004HD-UH for guix-patches@gnu.org; Tue, 13 Feb 2024 14:31:55 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZyVg-0004GP-FS for guix-patches@gnu.org; Tue, 13 Feb 2024 14:32:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 13 Feb 2024 19:32:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67260 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67260@debbugs.gnu.org Cc: cox.katherine.e+guix@gmail.com, Suhail , andrew@trop.in Received: via spool by 67260-submit@debbugs.gnu.org id=B67260.170785268616286 (code B ref 67260); Tue, 13 Feb 2024 19:32:04 +0000 Received: (at 67260) by debbugs.gnu.org; 13 Feb 2024 19:31:26 +0000 Received: from localhost ([127.0.0.1]:47415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZyV3-0004EV-5L for submit@debbugs.gnu.org; Tue, 13 Feb 2024 14:31:26 -0500 Received: from mail-ej1-f66.google.com ([209.85.218.66]:43206) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZyUw-0004Cw-6L for 67260@debbugs.gnu.org; Tue, 13 Feb 2024 14:31:20 -0500 Received: by mail-ej1-f66.google.com with SMTP id a640c23a62f3a-a30e445602cso16317766b.0 for <67260@debbugs.gnu.org>; Tue, 13 Feb 2024 11:31:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707852594; x=1708457394; darn=debbugs.gnu.org; h=mime-version:cc:to:subject:date:from:references:in-reply-to :message-id:from:to:cc:subject:date:message-id:reply-to; bh=unx0WlA09N7LGaCQR5w6UZT4NRsTI6qSoHqG9oNqu1k=; b=f3ou0R0toySzjcGs/OpJ7NrHJle/YkyDtynVENB52lSrv/7gpJH5twToxxk36uQsCg LvoxsW7VGV5Th+FoWUgew2zr+N2g9nDsf89AgI/1Bw7k9DB8arP8DMiz+mozlshFwtF0 iwUOVDJJtA45bExaoDlcdrksxQ/5k5p2wzyxPY83Y9qs3uP+1+Rlv+PvaMM/06IoOYbX OezlqiR2I9iNtmRgaS2j+xWd030zS4GJYaaUkfDSG+F6vUfops5vzRDKxx3Zh9yDwqXo orvT5YXQzN/zkQXRa9cWnT86ihTBpcMBoB7KS2X3q3lY+ysqa+Z4HNX5a+T8RNv8tk5/ niGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707852594; x=1708457394; h=mime-version:cc:to:subject:date:from:references:in-reply-to :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=unx0WlA09N7LGaCQR5w6UZT4NRsTI6qSoHqG9oNqu1k=; b=HdFFaiks2SG1Bh00k21gr8a+0fgEg8Nc57SXDDxv5x9hnxlwYf8EzdWQA0lBD+/oMP AfltM1JBDxfkYY0I5haB7ZwAyzqPWnWZ1m9Bv9EvocRjoYKbcHcUUsMVToCXg4ROqOR/ Dav/ZEgrRuCjaFL2Ie04p04OgiZodnoMIiwX0JMhb/Zyj58NkLugXaMLr7L9DB2WPNP8 rnCKVVFXuUKPEbLj6cdKfrf1MEWhwRTNHm9ByS98tRZo3bX/vWVIyUnTE5pRPSfqggv7 tS2R8Pvv1Em5zIkM87xRL+drRA0kWt8i/QzqITF9Sw5pTzhJHCFCrbKoabwXvsoakyRc JxVg== X-Gm-Message-State: AOJu0Yy8EXeJP1py9tSZ2T1/w0DcqGyoW2DnNZkldvE56BJ7tRs77+hd EEgROkqgAouh+8dmk1MKa1y0WAoK+UsLMB5Oncj0XEq22ycP0KcFpJ20JTVP1xk= X-Google-Smtp-Source: AGHT+IEedvko7D2Bq9FpivwFzEuHafO1XrBnG7bMXp3elaMLyn4sBrMQoi84EcqhskylCGRSQ0vW/w== X-Received: by 2002:a17:906:fcb6:b0:a3c:2c8e:9030 with SMTP id qw22-20020a170906fcb600b00a3c2c8e9030mr2960352ejb.6.1707852593670; Tue, 13 Feb 2024 11:29:53 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUGygQtxBh+eNXddPovI1bQhXHKBySGEtPJRuLA4L7qULdHTrHY6ZXVLF36AfUXtMbFHNKvgmeRL4W2E4yhQCw0qz62nYC3bvJK4Lsu3OhgoI0gCqN2QTzhBZx4Ca/l Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id sd18-20020a170906ce3200b00a3c456b0c0esm1573041ejb.108.2024.02.13.11.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 11:29:53 -0800 (PST) Message-ID: <60a52b40655fd27afa7d35564fb640c435c215b1.1707852049.git.liliana.prikler@gmail.com> In-Reply-To: References: From: Liliana Marie Prikler Date: Tue, 13 Feb 2024 19:30:50 +0100 MIME-Version: 1.0 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Spam-Score: -0.38 X-Migadu-Queue-Id: 07E4C77A36 X-Migadu-Spam-Score: -0.38 X-TUID: Y01PdYDvfxTJ * gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it here. * gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here. Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5 --- Am Sonntag, dem 28.01.2024 um 16:17 +0000 schrieb Suhail: > What surprised me was that not only was the "preloaded" directory > special-cased, but so too was the last entry of "comp-eln-load-path" > (which I imagine is referring to native-comp-eln-load-path). Judging > by your message, I'm guessing you're well aware of this. I, > unfortunately, have no additional insights or suggestions. Welp, I managed to find a workaround. The emacs produced by this patch has its own native-lisp directory twice (once per wrapping, once per bootstrap), but it ought to load your natively-compiled whatever fine. Cheers gnu/local.mk | 1 + gnu/packages/emacs.scm | 1 + .../emacs-native-comp-fix-filenames.patch | 322 ++++++++++++++++++ 3 files changed, 324 insertions(+) create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch diff --git a/gnu/local.mk b/gnu/local.mk index 3d1afd4555..7e6a0c5006 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1121,6 +1121,7 @@ dist_patch_DATA = \ %D%/packages/patches/emacs-kv-fix-tests.patch \ %D%/packages/patches/emacs-lispy-fix-thread-last-test.patch \ %D%/packages/patches/emacs-native-comp-driver-options.patch \ + %D%/packages/patches/emacs-native-comp-fix-filenames.patch \ %D%/packages/patches/emacs-next-exec-path.patch \ %D%/packages/patches/emacs-next-native-comp-driver-options.patch \ %D%/packages/patches/emacs-pasp-mode-quote-file-names.patch \ diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index 0292b1bd16..1caa2cbee0 100644 --- a/gnu/packages/emacs.scm +++ b/gnu/packages/emacs.scm @@ -111,6 +111,7 @@ (define-public emacs-minimal (patches (search-patches "emacs-exec-path.patch" "emacs-fix-scheme-indent-function.patch" "emacs-native-comp-driver-options.patch" + "emacs-native-comp-fix-filenames.patch" "emacs-pgtk-super-key-fix.patch")) (modules '((guix build utils))) (snippet diff --git a/gnu/packages/patches/emacs-native-comp-fix-filenames.patch b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch new file mode 100644 index 0000000000..8e9f9a8fd6 --- /dev/null +++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch @@ -0,0 +1,322 @@ +Upstream hashes both the absolute file name and the content of a file +to derive the name for the natively compiled files. This breaks the +staged install used in guix, as any $GUIX_PROFILE is distinct from +the build directory. It also breaks grafts, as hardcoded store file +names get rewritten; thus changing the file hash. + +In addition, this patch changes how native-comp-eln-load-path is +constructed. Upstream, an entry of the directory “../lisp” is added +supposedly for bootstrap only, but this directory appears to find its +way into the actual variable despite attempts to remove it by calling +‘startup--update-eln-cache’. +The user-visible procedure ‘startup-redirect-eln-cache’ is kept, as +packages may require it, but only pushes the new value now. + +Index: emacs-29.2/src/comp.c +=================================================================== +--- emacs-29.2.orig/src/comp.c ++++ emacs-29.2/src/comp.c +@@ -4396,26 +4396,17 @@ DEFUN ("comp-el-to-eln-rel-filename", Fc + Scomp_el_to_eln_rel_filename, 1, 1, 0, + doc: /* Return the relative name of the .eln file for FILENAME. + FILENAME must exist, and if it's a symlink, the target must exist. +-If FILENAME is compressed, it must have the \".gz\" extension, +-and Emacs must have been compiled with zlib; the file will be +-uncompressed on the fly to hash its contents. +-Value includes the original base name, followed by 2 hash values, +-one for the file name and another for its contents, followed by .eln. */) ++FILENAME is resolved relative to `load-path' and only the suffix of ++the first matching path is kept. If FILENAME is not found to be relative ++to any directory `load-path', it is used as-is to construct the return ++value. */) + (Lisp_Object filename) + { + CHECK_STRING (filename); + +- /* Resolve possible symlinks in FILENAME, so that path_hash below +- always compares equal. (Bug#44701). */ +- filename = Fexpand_file_name (filename, Qnil); +- char *file_normalized = realpath (SSDATA (ENCODE_FILE (filename)), NULL); +- if (file_normalized) +- { +- filename = DECODE_FILE (make_unibyte_string (file_normalized, +- strlen (file_normalized))); +- xfree (file_normalized); +- } ++ Lisp_Object rel_name = filename; + ++ filename = Fexpand_file_name (filename, Qnil); + if (NILP (Ffile_exists_p (filename))) + xsignal1 (Qfile_missing, filename); + +@@ -4423,64 +4414,54 @@ one for the file name and another for it + filename = Fw32_long_file_name (filename); + #endif + +- Lisp_Object content_hash = comp_hash_source_file (filename); ++ Lisp_Object tail = Vload_path; ++ Lisp_Object name_len = Flength (filename); + +- if (suffix_p (filename, ".gz")) +- filename = Fsubstring (filename, Qnil, make_fixnum (-3)); ++ FOR_EACH_TAIL_SAFE (tail) ++ { ++ Lisp_Object len = Flength (XCAR (tail)); ++ if (XFIXNUM (name_len) < XFIXNUM (len)) ++ continue; ++ else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len, ++ XCAR (tail), make_fixnum (0), len, ++ Qnil))) ++ { ++ filename = Fsubstring (filename, Fadd1 (len), Qnil); ++ break; ++ } ++ } + +- /* We create eln filenames with an hash in order to look-up these +- starting from the source filename, IOW have a relation ++ if (Ffile_name_absolute_p (filename)) ++ filename = rel_name; + +- /absolute/path/filename.el + content -> +- eln-cache/filename-path_hash-content_hash.eln. ++ Lisp_Object bogus_dirs = ++ Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil); + +- 'dlopen' can return the same handle if two shared with the same +- filename are loaded in two different times (even if the first was +- deleted!). To prevent this scenario the source file content is +- included in the hashing algorithm. +- +- As at any point in time no more then one file can exist with the +- same filename, should be possible to clean up all +- filename-path_hash-* except the most recent one (or the new one +- being recompiled). +- +- As installing .eln files compiled during the build changes their +- absolute path we need an hashing mechanism that is not sensitive +- to that. For this we replace if match PATH_DUMPLOADSEARCH or +- *PATH_REL_LOADSEARCH with '//' before computing the hash. */ ++ if (!NILP (bogus_dirs)) ++ { ++ tail = CALL2I (split-string, bogus_dirs, build_string (":")); ++ ++ FOR_EACH_TAIL_SAFE (tail) ++ { ++ Lisp_Object directory = Ffile_name_as_directory (XCAR (tail)); ++ Lisp_Object len = Flength (directory); ++ if (XFIXNUM (name_len) < XFIXNUM (len)) ++ continue; ++ else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len, ++ directory, make_fixnum (0), len, ++ Qnil))) ++ { ++ filename = Fsubstring (filename, len, Qnil); ++ break; ++ } ++ } ++ } + +- if (NILP (loadsearch_re_list)) +- { +- Lisp_Object sys_re = +- concat2 (build_string ("\\`[[:ascii:]]+"), +- Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/"))); +- Lisp_Object dump_load_search = +- Fexpand_file_name (build_string (PATH_DUMPLOADSEARCH "/"), Qnil); +-#ifdef WINDOWSNT +- dump_load_search = Fw32_long_file_name (dump_load_search); +-#endif +- loadsearch_re_list = list2 (sys_re, Fregexp_quote (dump_load_search)); +- } ++ if (suffix_p (filename, ".gz")) ++ filename = Fsubstring (filename, Qnil, make_fixnum (-3)); + +- Lisp_Object lds_re_tail = loadsearch_re_list; +- FOR_EACH_TAIL (lds_re_tail) +- { +- Lisp_Object match_idx = +- Fstring_match (XCAR (lds_re_tail), filename, Qnil, Qnil); +- if (BASE_EQ (match_idx, make_fixnum (0))) +- { +- filename = +- Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil); +- break; +- } +- } +- Lisp_Object separator = build_string ("-"); +- Lisp_Object path_hash = comp_hash_string (filename); +- filename = concat2 (Ffile_name_nondirectory (Fsubstring (filename, Qnil, +- make_fixnum (-3))), +- separator); +- Lisp_Object hash = concat3 (path_hash, separator, content_hash); +- return concat3 (filename, hash, build_string (NATIVE_ELISP_SUFFIX)); ++ return concat2(Fsubstring (filename, Qnil, make_fixnum (-3)), ++ build_string (NATIVE_ELISP_SUFFIX)); + } + + DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename, +@@ -4494,13 +4475,7 @@ If BASE-DIR is non-nil, use it as the di + non-absolute BASE-DIR is interpreted as relative to `invocation-directory'. + If BASE-DIR is omitted or nil, look for the first writable directory + in `native-comp-eln-load-path', and use as BASE-DIR its subdirectory +-whose name is given by `comp-native-version-dir'. +-If FILENAME specifies a preloaded file, the directory for the .eln +-file is the \"preloaded/\" subdirectory of the directory determined +-as described above. FILENAME is considered to be a preloaded file if +-the value of `comp-file-preloaded-p' is non-nil, or if FILENAME +-appears in the value of the environment variable LISP_PRELOADED; +-the latter is supposed to be used by the Emacs build procedure. */) ++whose name is given by `comp-native-version-dir'. */) + (Lisp_Object filename, Lisp_Object base_dir) + { + Lisp_Object source_filename = filename; +@@ -4541,19 +4516,7 @@ the latter is supposed to be used by the + + if (!file_name_absolute_p (SSDATA (base_dir))) + base_dir = Fexpand_file_name (base_dir, Vinvocation_directory); +- +- /* In case the file being compiled is found in 'LISP_PRELOADED' or +- `comp-file-preloaded-p' is non-nil target for output the +- 'preloaded' subfolder. */ +- Lisp_Object lisp_preloaded = +- Fgetenv_internal (build_string ("LISP_PRELOADED"), Qnil); + base_dir = Fexpand_file_name (Vcomp_native_version_dir, base_dir); +- if (comp_file_preloaded_p +- || (!NILP (lisp_preloaded) +- && !NILP (Fmember (CALL1I (file-name-base, source_filename), +- Fmapcar (intern_c_string ("file-name-base"), +- CALL1I (split-string, lisp_preloaded)))))) +- base_dir = Fexpand_file_name (build_string ("preloaded"), base_dir); + + return Fexpand_file_name (filename, base_dir); + } +@@ -5863,10 +5826,7 @@ The last directory of this list is assum + the system *.eln files, which are the files produced when building + Emacs. */); + +- /* Temporary value in use for bootstrap. We can't do better as +- `invocation-directory' is still unset, will be fixed up during +- dump reload. */ +- Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil); ++ Vnative_comp_eln_load_path = Qnil; + + DEFVAR_LISP ("native-comp-enable-subr-trampolines", + Vnative_comp_enable_subr_trampolines, +Index: emacs-29.2/lisp/startup.el +=================================================================== +--- emacs-29.2.orig/lisp/startup.el ++++ emacs-29.2/lisp/startup.el +@@ -545,9 +545,6 @@ DIRS are relative." + (defvar native-comp-jit-compilation) + (defvar native-comp-enable-subr-trampolines) + +-(defvar startup--original-eln-load-path nil +- "Original value of `native-comp-eln-load-path'.") +- + (defun startup-redirect-eln-cache (cache-directory) + "Redirect the user's eln-cache directory to CACHE-DIRECTORY. + CACHE-DIRECTORY must be a single directory, a string. +@@ -558,22 +555,10 @@ to `user-emacs-directory'. + For best results, call this function in your early-init file, + so that the rest of initialization and package loading uses + the updated value." +- ;; Remove the original eln-cache. +- (setq native-comp-eln-load-path (cdr native-comp-eln-load-path)) +- ;; Add the new eln-cache. + (push (expand-file-name (file-name-as-directory cache-directory) + user-emacs-directory) + native-comp-eln-load-path)) + +-(defun startup--update-eln-cache () +- "Update the user eln-cache directory due to user customizations." +- ;; Don't override user customizations! +- (when (equal native-comp-eln-load-path +- startup--original-eln-load-path) +- (startup-redirect-eln-cache "eln-cache") +- (setq startup--original-eln-load-path +- (copy-sequence native-comp-eln-load-path)))) +- + (defun normal-top-level () + "Emacs calls this function when it first starts up. + It sets `command-line-processed', processes the command-line, +@@ -1362,12 +1347,6 @@ please check its value") + startup-init-directory))) + (setq early-init-file user-init-file) + +- ;; Amend `native-comp-eln-load-path', since the early-init file may +- ;; have altered `user-emacs-directory' and/or changed the eln-cache +- ;; directory. +- (when (featurep 'native-compile) +- (startup--update-eln-cache)) +- + ;; If any package directory exists, initialize the package system. + (and user-init-file + package-enable-at-startup +@@ -1502,12 +1481,6 @@ please check its value") + startup-init-directory)) + t) + +- ;; Amend `native-comp-eln-load-path' again, since the early-init +- ;; file may have altered `user-emacs-directory' and/or changed the +- ;; eln-cache directory. +- (when (featurep 'native-compile) +- (startup--update-eln-cache)) +- + (when (and deactivate-mark transient-mark-mode) + (with-current-buffer (window-buffer) + (deactivate-mark))) +Index: emacs-29.2/src/Makefile.in +=================================================================== +--- emacs-29.2.orig/src/Makefile.in ++++ emacs-29.2/src/Makefile.in +@@ -553,6 +553,7 @@ shortlisp := $(filter-out ${shortlisp_fi + ## We don't really need to sort, but may as well use it to remove duplicates. + shortlisp := loaddefs.el loadup.el $(sort ${shortlisp}) + export LISP_PRELOADED = ${shortlisp} ++export NATIVE_COMP_BOGUS_DIRS = emacs-lisp + lisp = $(addprefix ${lispsource}/,${shortlisp}) + + ## Construct full set of libraries to be linked. +Index: emacs-29.2/Makefile.in +=================================================================== +--- emacs-29.2.orig/Makefile.in ++++ emacs-29.2/Makefile.in +@@ -329,6 +329,7 @@ TRANSFORM = @program_transform_name@ + + # Prevent any settings in the user environment causing problems. + unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH ++export EMACSNATIVELOADPATH = @abs_top_builddir@/native-lisp + + # What emacs should be called when installed. + EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'` +Index: emacs-29.2/lisp/loadup.el +=================================================================== +--- emacs-29.2.orig/lisp/loadup.el ++++ emacs-29.2/lisp/loadup.el +@@ -53,6 +53,13 @@ + (setq redisplay--inhibit-bidi t) + + (message "Dump mode: %s" dump-mode) ++;; Compensate for native-comp-eln-load-path being empty by Guix' default. ++(and (featurep 'native-compile) ++ (equal dump-mode "pdump") ++ (setq ++ native-comp-eln-load-path ++ (cons (expand-file-name "../native-lisp" invocation-directory) ++ native-comp-eln-load-path))) + + ;; Add subdirectories to the load-path for files that might get + ;; autoloaded when bootstrapping or running Emacs normally. +Index: emacs-29.2/lisp/Makefile.in +=================================================================== +--- emacs-29.2.orig/lisp/Makefile.in ++++ emacs-29.2/lisp/Makefile.in +@@ -110,6 +110,7 @@ MAIN_FIRST = ./emacs-lisp/eieio.el ./ema + + # Prevent any settings in the user environment causing problems. + unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH ++export NATIVE_COMP_BOGUS_DIRS = emacs-lisp:international:language:progmodes:term:textmodes:vc + + # The actual Emacs command run in the targets below. + emacs = '$(EMACS)' $(EMACSOPT) -- 2.41.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id QCuiOC/uy2U5cgAA62LTzQ:P1 (envelope-from ) for ; Tue, 13 Feb 2024 23:33:20 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id QCuiOC/uy2U5cgAA62LTzQ (envelope-from ) for ; Tue, 13 Feb 2024 23:33:20 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="GDzcOE//"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707863599; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=unx0WlA09N7LGaCQR5w6UZT4NRsTI6qSoHqG9oNqu1k=; b=nk1y+9qIiyuO7NrVE/h17IgRqKi7VMBRe2B/JL2Z86MWAUCfb8GLV87AlZ//ZT9jrfHXZa bQi8PZv/HnS8KdagUjLY1Piv4b+hXoevpSU//iOSBeoQwJspavpe0lGISQDBAs3zpThwhZ qEewU2Hk8BZhhTRVJBl0AH+aBLZ3wsUfQinl/ghEwBFVMRUwf8Imh7KeQJRL2gcgp5JhYq htoTXy1VCT0ZMkUL3gPTAXPHWDqy4UnKnz3h8h4UfyzHgXmH7+zZVf4hZh0yFVMtL2IKhs tFpcGlaJC5mw/vmgH2b9x9UrBF79sjSjj9CvHlLlSB/d9EqHP2O254y2GcIGhQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="GDzcOE//"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707863599; a=rsa-sha256; cv=none; b=AnXX4zFx+qfuwJlNy/8/AzEY4PSiH4I6vZIxFC0uISeMtVRF2malUT9eDA6GYhCMDCd2A7 b9ksJKuD0p7W7mBjA2gWwAOxpUnjkUO6dBnE9murIHaBSrOY6Ap1/evGgRho/flYacYIP9 +fR8E46es8Bpsxvn00ZrK5uKOBVsU6HrxDQuzEtLOGj6HFiD6Ltw//VHMZnqmdp2F2/Fbw /zy3AZpGlMX0H45lVx47e1rBtrrQlitmxIbduKYC2KNpU6hAJRxIKy+f0GrBI0TiGWIkIS 1fVKkHGTYBOFXB1DDEYuKvb1WNT9F/RNlFlhQkTsWj5uve2R3W+qXmVIXdo8Og== 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 6A1F13A5F4 for ; Tue, 13 Feb 2024 23:33:18 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra1Kb-0005VO-CS; Tue, 13 Feb 2024 17:32:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra1KX-0005Ur-Jq for guix-patches@gnu.org; Tue, 13 Feb 2024 17:32:45 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra1KX-0003D7-B3 for guix-patches@gnu.org; Tue, 13 Feb 2024 17:32:45 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ra1Ko-0002kt-Ux for guix-patches@gnu.org; Tue, 13 Feb 2024 17:33:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67260] [PATCH v9 3/7] gnu: emacs: Don't hash file names in native compilation. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 13 Feb 2024 22:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67260 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67260@debbugs.gnu.org Cc: cox.katherine.e+guix@gmail.com, Suhail , andrew@trop.in Received: via spool by 67260-submit@debbugs.gnu.org id=B67260.170786356810496 (code B ref 67260); Tue, 13 Feb 2024 22:33:02 +0000 Received: (at 67260) by debbugs.gnu.org; 13 Feb 2024 22:32:48 +0000 Received: from localhost ([127.0.0.1]:48474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ra1KZ-0002jC-6o for submit@debbugs.gnu.org; Tue, 13 Feb 2024 17:32:48 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:43281) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ra1KS-0002hz-S4 for 67260@debbugs.gnu.org; Tue, 13 Feb 2024 17:32:42 -0500 Received: by mail-wm1-f67.google.com with SMTP id 5b1f17b1804b1-410e820a4feso1050255e9.1 for <67260@debbugs.gnu.org>; Tue, 13 Feb 2024 14:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707863477; x=1708468277; darn=debbugs.gnu.org; h=mime-version:cc:to:subject:date:from:references:in-reply-to :message-id:from:to:cc:subject:date:message-id:reply-to; bh=unx0WlA09N7LGaCQR5w6UZT4NRsTI6qSoHqG9oNqu1k=; b=GDzcOE//DSmR7sO/xqyqREJsa9xhegTdV0w3Ie+GLjTamCQlVxcO/jelmMrSJ6do5S pdRtSymkwHP3eZvMuVf33pDKUVIF9qJjCLIxi1BL3DKA9m6BGKblyWrhq/2n/rKzB4Zx 4+80kHiqFfi7YzJafozdo1dvO3ZOYG4OW9wZqdYegritLpRYvsuDkYQKQuigrdQZRQx5 zIyuuBc1FOmOKl+Qd2yefw1ikkFlu15E4O3S1WuoXmZnZFRt49EbWqxTCPuZ32FEnLYS aFNN9luu+kcFu4uyQGPtzKTw9vCAgYVznwByrzfHktMys2w9gFd9CKs+dQfgH/QfWC7v 6ztw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707863477; x=1708468277; h=mime-version:cc:to:subject:date:from:references:in-reply-to :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=unx0WlA09N7LGaCQR5w6UZT4NRsTI6qSoHqG9oNqu1k=; b=lAbThyaptpmrkC3NxslcgPcMBxJwPOiHzMjPHMopW9hJ/+Ypa5P6hofXTyj4KEnmk1 81rYrogHtQChek/6TSjhlWtCvVkJHkBVq5d4nxxFGRnpq6aKE1S+oQYNgZQXhjabFX2D sAlbbnyAFFTO0vj/A9gnkBtMGHLGfcF5KD/pqsxr1gYALDr/DRcDi7AXP5fsDkj+NGmq WlkwtE5RQX9E5FjR0XoVen9NQGa2ijDR8Mf460H3YrDI09Tv8AxpyfO5uINTWIlULhSO l2eaCiMNolz1stvO5sn5rdtEeZgui9Mdniq24Rq7zGF7sKhhi56PraasJgnnWp2AW3xv d/fQ== X-Gm-Message-State: AOJu0Yy2E1ylDPjl8+COZUxmjDrrr7ortMwt4MmRezxfZnpn01dUTx2V 589GcSlqlvS3vRJCUi1rynIMm2mBgrIQ7gXHSXp5/4IHa+QMnx2PmeiD10x0E5Y= X-Google-Smtp-Source: AGHT+IG+THsStOQAG5dHekxGdTBdTqxdAVprvof0ELq/Y6tkZ5+DDHehbfqaQ4EYL7K82vy+cKvJuw== X-Received: by 2002:a05:600c:3150:b0:40e:45c0:ad64 with SMTP id h16-20020a05600c315000b0040e45c0ad64mr139580wmo.14.1707863477453; Tue, 13 Feb 2024 14:31:17 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVf0/bitHMUm0pEyOuKKTRGunIQyUy8hcWNjH4fFvTUxcc1kUnt2JYE8PqZ4NI/iaUi3nzZk9QiDB20g3xxQB1vjRwweqRrdPFrYDMpZnrbvNlcm2es6daXU073NvV4 Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id fm7-20020a05600c0c0700b00411062c123esm66629wmb.26.2024.02.13.14.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:31:17 -0800 (PST) Message-ID: <60a52b40655fd27afa7d35564fb640c435c215b1.1707852049.git.liliana.prikler@gmail.com> In-Reply-To: References: From: Liliana Marie Prikler Date: Tue, 13 Feb 2024 19:30:50 +0100 MIME-Version: 1.0 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 7.53 X-Migadu-Queue-Id: 6A1F13A5F4 X-Spam-Score: 7.53 X-Migadu-Scanner: mx11.migadu.com X-TUID: 7ZHz4/GdJQaz Message-ID: <20240213183050.Phhhgkv8PMld3VZ5ftiWNTXKZHSSIdAvwWF1CmtpfxQ@z> * gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it here. * gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here. Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5 --- Am Sonntag, dem 28.01.2024 um 16:17 +0000 schrieb Suhail: > What surprised me was that not only was the "preloaded" directory > special-cased, but so too was the last entry of "comp-eln-load-path" > (which I imagine is referring to native-comp-eln-load-path). Judging > by your message, I'm guessing you're well aware of this. I, > unfortunately, have no additional insights or suggestions. Welp, I managed to find a workaround. The emacs produced by this patch has its own native-lisp directory twice (once per wrapping, once per bootstrap), but it ought to load your natively-compiled whatever fine. Cheers gnu/local.mk | 1 + gnu/packages/emacs.scm | 1 + .../emacs-native-comp-fix-filenames.patch | 322 ++++++++++++++++++ 3 files changed, 324 insertions(+) create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch diff --git a/gnu/local.mk b/gnu/local.mk index 3d1afd4555..7e6a0c5006 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1121,6 +1121,7 @@ dist_patch_DATA = \ %D%/packages/patches/emacs-kv-fix-tests.patch \ %D%/packages/patches/emacs-lispy-fix-thread-last-test.patch \ %D%/packages/patches/emacs-native-comp-driver-options.patch \ + %D%/packages/patches/emacs-native-comp-fix-filenames.patch \ %D%/packages/patches/emacs-next-exec-path.patch \ %D%/packages/patches/emacs-next-native-comp-driver-options.patch \ %D%/packages/patches/emacs-pasp-mode-quote-file-names.patch \ diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index 0292b1bd16..1caa2cbee0 100644 --- a/gnu/packages/emacs.scm +++ b/gnu/packages/emacs.scm @@ -111,6 +111,7 @@ (define-public emacs-minimal (patches (search-patches "emacs-exec-path.patch" "emacs-fix-scheme-indent-function.patch" "emacs-native-comp-driver-options.patch" + "emacs-native-comp-fix-filenames.patch" "emacs-pgtk-super-key-fix.patch")) (modules '((guix build utils))) (snippet diff --git a/gnu/packages/patches/emacs-native-comp-fix-filenames.patch b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch new file mode 100644 index 0000000000..8e9f9a8fd6 --- /dev/null +++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch @@ -0,0 +1,322 @@ +Upstream hashes both the absolute file name and the content of a file +to derive the name for the natively compiled files. This breaks the +staged install used in guix, as any $GUIX_PROFILE is distinct from +the build directory. It also breaks grafts, as hardcoded store file +names get rewritten; thus changing the file hash. + +In addition, this patch changes how native-comp-eln-load-path is +constructed. Upstream, an entry of the directory “../lisp” is added +supposedly for bootstrap only, but this directory appears to find its +way into the actual variable despite attempts to remove it by calling +‘startup--update-eln-cache’. +The user-visible procedure ‘startup-redirect-eln-cache’ is kept, as +packages may require it, but only pushes the new value now. + +Index: emacs-29.2/src/comp.c +=================================================================== +--- emacs-29.2.orig/src/comp.c ++++ emacs-29.2/src/comp.c +@@ -4396,26 +4396,17 @@ DEFUN ("comp-el-to-eln-rel-filename", Fc + Scomp_el_to_eln_rel_filename, 1, 1, 0, + doc: /* Return the relative name of the .eln file for FILENAME. + FILENAME must exist, and if it's a symlink, the target must exist. +-If FILENAME is compressed, it must have the \".gz\" extension, +-and Emacs must have been compiled with zlib; the file will be +-uncompressed on the fly to hash its contents. +-Value includes the original base name, followed by 2 hash values, +-one for the file name and another for its contents, followed by .eln. */) ++FILENAME is resolved relative to `load-path' and only the suffix of ++the first matching path is kept. If FILENAME is not found to be relative ++to any directory `load-path', it is used as-is to construct the return ++value. */) + (Lisp_Object filename) + { + CHECK_STRING (filename); + +- /* Resolve possible symlinks in FILENAME, so that path_hash below +- always compares equal. (Bug#44701). */ +- filename = Fexpand_file_name (filename, Qnil); +- char *file_normalized = realpath (SSDATA (ENCODE_FILE (filename)), NULL); +- if (file_normalized) +- { +- filename = DECODE_FILE (make_unibyte_string (file_normalized, +- strlen (file_normalized))); +- xfree (file_normalized); +- } ++ Lisp_Object rel_name = filename; + ++ filename = Fexpand_file_name (filename, Qnil); + if (NILP (Ffile_exists_p (filename))) + xsignal1 (Qfile_missing, filename); + +@@ -4423,64 +4414,54 @@ one for the file name and another for it + filename = Fw32_long_file_name (filename); + #endif + +- Lisp_Object content_hash = comp_hash_source_file (filename); ++ Lisp_Object tail = Vload_path; ++ Lisp_Object name_len = Flength (filename); + +- if (suffix_p (filename, ".gz")) +- filename = Fsubstring (filename, Qnil, make_fixnum (-3)); ++ FOR_EACH_TAIL_SAFE (tail) ++ { ++ Lisp_Object len = Flength (XCAR (tail)); ++ if (XFIXNUM (name_len) < XFIXNUM (len)) ++ continue; ++ else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len, ++ XCAR (tail), make_fixnum (0), len, ++ Qnil))) ++ { ++ filename = Fsubstring (filename, Fadd1 (len), Qnil); ++ break; ++ } ++ } + +- /* We create eln filenames with an hash in order to look-up these +- starting from the source filename, IOW have a relation ++ if (Ffile_name_absolute_p (filename)) ++ filename = rel_name; + +- /absolute/path/filename.el + content -> +- eln-cache/filename-path_hash-content_hash.eln. ++ Lisp_Object bogus_dirs = ++ Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil); + +- 'dlopen' can return the same handle if two shared with the same +- filename are loaded in two different times (even if the first was +- deleted!). To prevent this scenario the source file content is +- included in the hashing algorithm. +- +- As at any point in time no more then one file can exist with the +- same filename, should be possible to clean up all +- filename-path_hash-* except the most recent one (or the new one +- being recompiled). +- +- As installing .eln files compiled during the build changes their +- absolute path we need an hashing mechanism that is not sensitive +- to that. For this we replace if match PATH_DUMPLOADSEARCH or +- *PATH_REL_LOADSEARCH with '//' before computing the hash. */ ++ if (!NILP (bogus_dirs)) ++ { ++ tail = CALL2I (split-string, bogus_dirs, build_string (":")); ++ ++ FOR_EACH_TAIL_SAFE (tail) ++ { ++ Lisp_Object directory = Ffile_name_as_directory (XCAR (tail)); ++ Lisp_Object len = Flength (directory); ++ if (XFIXNUM (name_len) < XFIXNUM (len)) ++ continue; ++ else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len, ++ directory, make_fixnum (0), len, ++ Qnil))) ++ { ++ filename = Fsubstring (filename, len, Qnil); ++ break; ++ } ++ } ++ } + +- if (NILP (loadsearch_re_list)) +- { +- Lisp_Object sys_re = +- concat2 (build_string ("\\`[[:ascii:]]+"), +- Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/"))); +- Lisp_Object dump_load_search = +- Fexpand_file_name (build_string (PATH_DUMPLOADSEARCH "/"), Qnil); +-#ifdef WINDOWSNT +- dump_load_search = Fw32_long_file_name (dump_load_search); +-#endif +- loadsearch_re_list = list2 (sys_re, Fregexp_quote (dump_load_search)); +- } ++ if (suffix_p (filename, ".gz")) ++ filename = Fsubstring (filename, Qnil, make_fixnum (-3)); + +- Lisp_Object lds_re_tail = loadsearch_re_list; +- FOR_EACH_TAIL (lds_re_tail) +- { +- Lisp_Object match_idx = +- Fstring_match (XCAR (lds_re_tail), filename, Qnil, Qnil); +- if (BASE_EQ (match_idx, make_fixnum (0))) +- { +- filename = +- Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil); +- break; +- } +- } +- Lisp_Object separator = build_string ("-"); +- Lisp_Object path_hash = comp_hash_string (filename); +- filename = concat2 (Ffile_name_nondirectory (Fsubstring (filename, Qnil, +- make_fixnum (-3))), +- separator); +- Lisp_Object hash = concat3 (path_hash, separator, content_hash); +- return concat3 (filename, hash, build_string (NATIVE_ELISP_SUFFIX)); ++ return concat2(Fsubstring (filename, Qnil, make_fixnum (-3)), ++ build_string (NATIVE_ELISP_SUFFIX)); + } + + DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename, +@@ -4494,13 +4475,7 @@ If BASE-DIR is non-nil, use it as the di + non-absolute BASE-DIR is interpreted as relative to `invocation-directory'. + If BASE-DIR is omitted or nil, look for the first writable directory + in `native-comp-eln-load-path', and use as BASE-DIR its subdirectory +-whose name is given by `comp-native-version-dir'. +-If FILENAME specifies a preloaded file, the directory for the .eln +-file is the \"preloaded/\" subdirectory of the directory determined +-as described above. FILENAME is considered to be a preloaded file if +-the value of `comp-file-preloaded-p' is non-nil, or if FILENAME +-appears in the value of the environment variable LISP_PRELOADED; +-the latter is supposed to be used by the Emacs build procedure. */) ++whose name is given by `comp-native-version-dir'. */) + (Lisp_Object filename, Lisp_Object base_dir) + { + Lisp_Object source_filename = filename; +@@ -4541,19 +4516,7 @@ the latter is supposed to be used by the + + if (!file_name_absolute_p (SSDATA (base_dir))) + base_dir = Fexpand_file_name (base_dir, Vinvocation_directory); +- +- /* In case the file being compiled is found in 'LISP_PRELOADED' or +- `comp-file-preloaded-p' is non-nil target for output the +- 'preloaded' subfolder. */ +- Lisp_Object lisp_preloaded = +- Fgetenv_internal (build_string ("LISP_PRELOADED"), Qnil); + base_dir = Fexpand_file_name (Vcomp_native_version_dir, base_dir); +- if (comp_file_preloaded_p +- || (!NILP (lisp_preloaded) +- && !NILP (Fmember (CALL1I (file-name-base, source_filename), +- Fmapcar (intern_c_string ("file-name-base"), +- CALL1I (split-string, lisp_preloaded)))))) +- base_dir = Fexpand_file_name (build_string ("preloaded"), base_dir); + + return Fexpand_file_name (filename, base_dir); + } +@@ -5863,10 +5826,7 @@ The last directory of this list is assum + the system *.eln files, which are the files produced when building + Emacs. */); + +- /* Temporary value in use for bootstrap. We can't do better as +- `invocation-directory' is still unset, will be fixed up during +- dump reload. */ +- Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil); ++ Vnative_comp_eln_load_path = Qnil; + + DEFVAR_LISP ("native-comp-enable-subr-trampolines", + Vnative_comp_enable_subr_trampolines, +Index: emacs-29.2/lisp/startup.el +=================================================================== +--- emacs-29.2.orig/lisp/startup.el ++++ emacs-29.2/lisp/startup.el +@@ -545,9 +545,6 @@ DIRS are relative." + (defvar native-comp-jit-compilation) + (defvar native-comp-enable-subr-trampolines) + +-(defvar startup--original-eln-load-path nil +- "Original value of `native-comp-eln-load-path'.") +- + (defun startup-redirect-eln-cache (cache-directory) + "Redirect the user's eln-cache directory to CACHE-DIRECTORY. + CACHE-DIRECTORY must be a single directory, a string. +@@ -558,22 +555,10 @@ to `user-emacs-directory'. + For best results, call this function in your early-init file, + so that the rest of initialization and package loading uses + the updated value." +- ;; Remove the original eln-cache. +- (setq native-comp-eln-load-path (cdr native-comp-eln-load-path)) +- ;; Add the new eln-cache. + (push (expand-file-name (file-name-as-directory cache-directory) + user-emacs-directory) + native-comp-eln-load-path)) + +-(defun startup--update-eln-cache () +- "Update the user eln-cache directory due to user customizations." +- ;; Don't override user customizations! +- (when (equal native-comp-eln-load-path +- startup--original-eln-load-path) +- (startup-redirect-eln-cache "eln-cache") +- (setq startup--original-eln-load-path +- (copy-sequence native-comp-eln-load-path)))) +- + (defun normal-top-level () + "Emacs calls this function when it first starts up. + It sets `command-line-processed', processes the command-line, +@@ -1362,12 +1347,6 @@ please check its value") + startup-init-directory))) + (setq early-init-file user-init-file) + +- ;; Amend `native-comp-eln-load-path', since the early-init file may +- ;; have altered `user-emacs-directory' and/or changed the eln-cache +- ;; directory. +- (when (featurep 'native-compile) +- (startup--update-eln-cache)) +- + ;; If any package directory exists, initialize the package system. + (and user-init-file + package-enable-at-startup +@@ -1502,12 +1481,6 @@ please check its value") + startup-init-directory)) + t) + +- ;; Amend `native-comp-eln-load-path' again, since the early-init +- ;; file may have altered `user-emacs-directory' and/or changed the +- ;; eln-cache directory. +- (when (featurep 'native-compile) +- (startup--update-eln-cache)) +- + (when (and deactivate-mark transient-mark-mode) + (with-current-buffer (window-buffer) + (deactivate-mark))) +Index: emacs-29.2/src/Makefile.in +=================================================================== +--- emacs-29.2.orig/src/Makefile.in ++++ emacs-29.2/src/Makefile.in +@@ -553,6 +553,7 @@ shortlisp := $(filter-out ${shortlisp_fi + ## We don't really need to sort, but may as well use it to remove duplicates. + shortlisp := loaddefs.el loadup.el $(sort ${shortlisp}) + export LISP_PRELOADED = ${shortlisp} ++export NATIVE_COMP_BOGUS_DIRS = emacs-lisp + lisp = $(addprefix ${lispsource}/,${shortlisp}) + + ## Construct full set of libraries to be linked. +Index: emacs-29.2/Makefile.in +=================================================================== +--- emacs-29.2.orig/Makefile.in ++++ emacs-29.2/Makefile.in +@@ -329,6 +329,7 @@ TRANSFORM = @program_transform_name@ + + # Prevent any settings in the user environment causing problems. + unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH ++export EMACSNATIVELOADPATH = @abs_top_builddir@/native-lisp + + # What emacs should be called when installed. + EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'` +Index: emacs-29.2/lisp/loadup.el +=================================================================== +--- emacs-29.2.orig/lisp/loadup.el ++++ emacs-29.2/lisp/loadup.el +@@ -53,6 +53,13 @@ + (setq redisplay--inhibit-bidi t) + + (message "Dump mode: %s" dump-mode) ++;; Compensate for native-comp-eln-load-path being empty by Guix' default. ++(and (featurep 'native-compile) ++ (equal dump-mode "pdump") ++ (setq ++ native-comp-eln-load-path ++ (cons (expand-file-name "../native-lisp" invocation-directory) ++ native-comp-eln-load-path))) + + ;; Add subdirectories to the load-path for files that might get + ;; autoloaded when bootstrapping or running Emacs normally. +Index: emacs-29.2/lisp/Makefile.in +=================================================================== +--- emacs-29.2.orig/lisp/Makefile.in ++++ emacs-29.2/lisp/Makefile.in +@@ -110,6 +110,7 @@ MAIN_FIRST = ./emacs-lisp/eieio.el ./ema + + # Prevent any settings in the user environment causing problems. + unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH ++export NATIVE_COMP_BOGUS_DIRS = emacs-lisp:international:language:progmodes:term:textmodes:vc + + # The actual Emacs command run in the targets below. + emacs = '$(EMACS)' $(EMACSOPT) -- 2.41.0