From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id GLqGFZYqsmWiQgAAqHPOHw:P1 (envelope-from ) for ; Thu, 25 Jan 2024 10:32:06 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id GLqGFZYqsmWiQgAAqHPOHw (envelope-from ) for ; Thu, 25 Jan 2024 10:32:06 +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=imEFJKPo; 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=1706175126; 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=JvOmNPdravM11kPQ2ReMhGHECZagEoaWBIOUqN61/Y4=; b=fVlz43kI9lkmm5fhUO0+ta+ck8Qq6FwIQlXZxYOhob2zMQDTQeemdke1nxRezsHmwjFGSG pF/XvnpeEdw8sHKhzHRHpyJ3/SNGsVKQlgUcU8A3CmckaoLfgfNkOMYgFrvUHy0lDhdvCd E1O6Bt7HxAo5Ovy/Du1boo0Yh2Bzmt5rLvVvoCKp+/2IUu0/KwpYTOHPHqXUb/sHWQsX3y VC8gWxsBMSJeIFTsfT89bl/n8PbMiswjflZp6RiMN0b3ubHz0JImvjrz7v8M8GwbLexu2F y2If6VGuwDeCwS3+1/sqxzJTCyUGOrbnugcSoHojaIjAm8ggvV/cSjyLZheTnA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=imEFJKPo; 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=1706175126; a=rsa-sha256; cv=none; b=pfoh5bGYlVPG/k/Y7pXUFElOHtS9JH4HekRFuBCno0qcS1R0pNm676GEBvo7ln40uuS4II peoEEPKcraAsgnbMwdZq6rzAB7Z0NrT2tkUjbn1GMVQgM0Zzx3xMUB3lv8txQr5ouPzD8L 3UCHhirYSXdKMDrMUXxB8l+DzRCcBKJYmGYdym66BN/u4Q66yoNXOjb//xg7EyqDWzUHMY D76GvMqqmq7bAHQEwIhF+Xg7IA95d9Kdv+WLAxz/CfcYKk7+Pjk3pgaxaky8Og4FgHIO9L ftDPBADHImpR1kpNt8WwkURGNPNiqUBSjKk7OmYBSsoHK5QDCD4h3BIyKqeGEQ== 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 295942274E for ; Thu, 25 Jan 2024 10:32:06 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSw4n-0008Q7-He; Thu, 25 Jan 2024 04:31:13 -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 1rSw4c-0008Nu-AG for guix-patches@gnu.org; Thu, 25 Jan 2024 04:31:02 -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 1rSw4Y-000213-5U for guix-patches@gnu.org; Thu, 25 Jan 2024 04:30:59 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rSw4d-0007cK-5J; Thu, 25 Jan 2024 04:31:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67260] [PATCH v6 3/7] gnu: emacs: Don't hash file names in native compilation. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: andrew@trop.in, cox.katherine.e+guix@gmail.com, liliana.prikler@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 25 Jan 2024 09:31:03 +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: andrew@trop.in, cox.katherine.e+guix@gmail.com, liliana.prikler@gmail.com X-Debbugs-Original-Xcc: andrew@trop.in, cox.katherine.e+guix@gmail.com, liliana.prikler@gmail.com Received: via spool by 67260-submit@debbugs.gnu.org id=B67260.170617503029196 (code B ref 67260); Thu, 25 Jan 2024 09:31:03 +0000 Received: (at 67260) by debbugs.gnu.org; 25 Jan 2024 09:30:30 +0000 Received: from localhost ([127.0.0.1]:47322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSw45-0007al-Cq for submit@debbugs.gnu.org; Thu, 25 Jan 2024 04:30:30 -0500 Received: from mail-ej1-x642.google.com ([2a00:1450:4864:20::642]:42011) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSw3v-0007ZS-HW for 67260@debbugs.gnu.org; Thu, 25 Jan 2024 04:30:20 -0500 Received: by mail-ej1-x642.google.com with SMTP id a640c23a62f3a-a313b51cf1fso95440866b.0 for <67260@debbugs.gnu.org>; Thu, 25 Jan 2024 01:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706175008; x=1706779808; darn=debbugs.gnu.org; h=mime-version:to:subject:date:from:references:in-reply-to:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JvOmNPdravM11kPQ2ReMhGHECZagEoaWBIOUqN61/Y4=; b=imEFJKPoojJBdRdJT1wogMkUydOSdmUMW23cKDx3m6JTGFTRY6KRHZ0KvVQ1bwt3Ea XsOwdB/g5YzTfChYppTIYPmZh4X76zT5U2VTn7s7YyBwbxxdmffZbebTf5UFV/3AegZz 2/v29G01n/ffdp6cXHJjwdlrNNud244fAXVkEKWLG9k6v2tATEd4idKmjs0O2xzMINLx nx9X4/zUbrZNl54+VZnApIdoDgYi5lnhIRYycqd2LfWE+kW44d5WWuR1/sEUoMnZkgtV 2hI+5f/XKp1nYEyNdG9bWhUkPLbtTRwxXWGEeozN+sroyOk+h9y62buAnkjzYGTz5ehZ e80Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706175008; x=1706779808; h=mime-version:to:subject:date:from:references:in-reply-to:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JvOmNPdravM11kPQ2ReMhGHECZagEoaWBIOUqN61/Y4=; b=E9oZZoexWa49V3n+CSUM8x+XglpT7ZrfdMvm+vlqu0pXqrfZRTpHyxbOzbCvj7wsiG 6flGiVaICsI2RZypYD0AD2eX8qxt2t0QytLPHumgUdCTiX+Uj4Ia4Xoj8VlIPwchspou 3jKkd4e42mzkVF/7Vl8ttEqAVKETs0Wgo68OCKS68O2gk9Kt36gzcW8POItD4B4wXRZH moHrNSp+wj76LovfrqLX8LrpJlctCVMrlNvIYUJG76ITEz/7RyiRR79ZscEMQMizYZW6 n+vSzglUqYiEyXfc3koxjRGJW+wCks9RwdvTHSK+mnOrOIW/3IxfGBddxwWfirgvD+uC KIGg== X-Gm-Message-State: AOJu0YycHx1hLeegMfOqlMbDihrSxsREhsqIyU41aljTzarQzGblqFJh 4cUgOrdvQTV9OGNb2CbRzF9S/ECpSUr68OLoT/MEM3gMz5O5IGQdih5o20dbF8k= X-Google-Smtp-Source: AGHT+IFXAkb22k7LG8P8Dvjw04d8xtgScCdTAWCptpIHkrD7IlQAHRb0WllB4fzgTUQURXAi9x7xUg== X-Received: by 2002:a17:906:1594:b0:a30:428c:b1b8 with SMTP id k20-20020a170906159400b00a30428cb1b8mr722193ejd.42.1706175007750; Thu, 25 Jan 2024 01:30:07 -0800 (PST) Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id r11-20020a170906350b00b00a2af287c6b8sm843355eja.16.2024.01.25.01.30.07 for <67260@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 01:30:07 -0800 (PST) Message-ID: In-Reply-To: References: From: Liliana Marie Prikler Date: Sun, 21 Jan 2024 13:12:42 +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: 4.83 X-Spam-Score: 4.83 X-Migadu-Queue-Id: 295942274E X-Migadu-Scanner: mx12.migadu.com X-TUID: ilDJHa9YP595 * 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 --- gnu/local.mk | 1 + gnu/packages/emacs.scm | 1 + .../emacs-native-comp-fix-filenames.patch | 197 ++++++++++++++++++ 3 files changed, 199 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..714b707e47 --- /dev/null +++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch @@ -0,0 +1,197 @@ +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. + +Index: emacs-29.1/src/comp.c +=================================================================== +--- emacs-29.1.orig/src/comp.c ++++ emacs-29.1/src/comp.c +@@ -4396,26 +4396,18 @@ 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. Further, if the NATIVE_COMP_BOGUS_DIRS environment variable is set, ++the first matching prefix mentioned in it will be stripped as well. */) + (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 +4415,53 @@ 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); +- +- if (suffix_p (filename, ".gz")) +- filename = Fsubstring (filename, Qnil, make_fixnum (-3)); +- +- /* We create eln filenames with an hash in order to look-up these +- starting from the source filename, IOW have a relation +- +- /absolute/path/filename.el + content -> +- eln-cache/filename-path_hash-content_hash.eln. ++ Lisp_Object tail = Vload_path; ++ Lisp_Object name_len = Flength (filename); + +- '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 (loadsearch_re_list)) ++ FOR_EACH_TAIL_SAFE (tail) + { +- 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)); +- } +- +- 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))) ++ 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 = +- Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil); ++ filename = Fsubstring (filename, Fadd1 (len), 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)); ++ ++ if (Ffile_name_absolute_p (filename)) ++ filename = rel_name; ++ ++ Lisp_Object bogus_dirs = ++ Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil); ++ ++ if (!NILP (bogus_dirs)) ++ { ++ tail = CALL2I (split-string, bogus_dirs, build_string (":")); ++ ++ 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; ++ } ++ } ++ } ++ ++ if (suffix_p (filename, ".gz")) ++ filename = Fsubstring (filename, Qnil, make_fixnum (-3)); ++ ++ 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); + } +Index: emacs-29.1/src/Makefile.in +=================================================================== +--- emacs-29.1.orig/src/Makefile.in ++++ emacs-29.1/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 + lisp = $(addprefix ${lispsource}/,${shortlisp}) + + ## Construct full set of libraries to be linked. -- 2.41.0