From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 YAMdDE7XYWVMvgAAG6o9tA:P1 (envelope-from ) for ; Sat, 25 Nov 2023 12:15:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YAMdDE7XYWVMvgAAG6o9tA (envelope-from ) for ; Sat, 25 Nov 2023 12:15:26 +0100 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 C696A5D83A for ; Sat, 25 Nov 2023 12:15:25 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=gBHArZHn; 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=1700910926; 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=mYHZtJG6nIa+GI8VTKMOW5Cp0BJDMu0YaL+wAhcv1nk=; b=sftr2pwTA2mzUEEVXbm/YZUQwxi+4HVmthlVms1m6j0TxswAZo4XA1zVEXScTBl4fwhI84 h341E3gn30ZXiNO/7NIyyQcAGFt6J7EpH7aouIDAOcqVKL9KPxlDWmGPOATv+MddH+1Ytl KmvkvuoW1G62Prdto9p4N3GyIwvypr/J811oyIA//TUs+nymW43d7+5cIqFgJB3243cXTU RCVQ556PoTrIQ4EcqlVeEnhyeUscMnBWspRF549JQRaJu8d8o+ymDYwmwg8mb1rOVcS+cr a2Jx9HSiSJUvb1RFHglxN/2Z0tJsMhnfOVAulkcTQCFc2E9za19mx4rPdEa5OA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=gBHArZHn; 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=1700910926; a=rsa-sha256; cv=none; b=PgvI4CmqoONUk79v9PVr3Zx20Mnnjo412y4vZ444ACUNWY7DXsCtF4PD+7xUFOKbrM6KAZ 4t382LMBInGHpqRQU1L2z5SRluUfZFErNOjiwZ+nfEPCoLg+YiALgmb7ZsBhRHLIPJiKQu zoiyPFaaWJgoBgZ6s3cOjRF2nZ8QIAj67irIcOJ9cvdwLC+Bw1A9iqkz5xF25L3VOaL2bJ rWHzwP9nMAqMI7U/gHYHu494VYs/1sA9XVAc95S/g/q+8cKNN1be3Sh2xTMdpi2+kE9jHJ CLbQI4oVLtS2cOrnmE4h+8bDBEeM9UeCHL4Xeqd5IyHBjKyBpgDSGvOTwNd+Qw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6qcr-0001VJ-4d; Sat, 25 Nov 2023 06:15:05 -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 1r6qck-0001Ua-F3 for guix-patches@gnu.org; Sat, 25 Nov 2023 06:14: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 1r6qck-0000Ni-77 for guix-patches@gnu.org; Sat, 25 Nov 2023 06:14:58 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6qcp-00070v-6r for guix-patches@gnu.org; Sat, 25 Nov 2023 06:15:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67260] [PATCH emacs-team v3 2/3] 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: Sat, 25 Nov 2023 11:15: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: cox.katherine.e+guix@gmail.com, andrew@trop.in Received: via spool by 67260-submit@debbugs.gnu.org id=B67260.170091090126844 (code B ref 67260); Sat, 25 Nov 2023 11:15:03 +0000 Received: (at 67260) by debbugs.gnu.org; 25 Nov 2023 11:15:01 +0000 Received: from localhost ([127.0.0.1]:37991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6qcm-0006yo-Qb for submit@debbugs.gnu.org; Sat, 25 Nov 2023 06:15:01 -0500 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:61594) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6qcj-0006yJ-DN for 67260@debbugs.gnu.org; Sat, 25 Nov 2023 06:14:58 -0500 Received: by mail-ej1-x643.google.com with SMTP id a640c23a62f3a-a02cc476581so363991066b.2 for <67260@debbugs.gnu.org>; Sat, 25 Nov 2023 03:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700910886; x=1701515686; 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=mYHZtJG6nIa+GI8VTKMOW5Cp0BJDMu0YaL+wAhcv1nk=; b=gBHArZHnno6MPhda3+XSQZP1H+y5xa4f6OTLL1n0UeOuTH0N98kGCX+NnHOQxpiKfO 1uLHh0aDWDt477nB5dKI68uoa4QJmx7nVCzWTTTe+OGuMazxKbMUZZdlQaN+KBp7MuuK UWM2tIzqM4TFLEoQsEauW/H1XQdgBlwuZAydr2wRLxMDIHovy2H+VGRg76YQa1ksxRd7 KOU2tz0EdBZz7adK153c9Ypsnk4T41pZdk5+z9J38JO4spdzh5wXsSLcRb+ErEMTxd5n RL2AEMGw7th7Yqwd3t3moDtA9fm6eK52Mqqa2Xd7YvVGFB/ZHQ1JsOP23qaevpz1jvgQ qLNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700910886; x=1701515686; 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=mYHZtJG6nIa+GI8VTKMOW5Cp0BJDMu0YaL+wAhcv1nk=; b=lw3Heenjpneyt+8kb0WfraijSYU9xj2TYpICM4CMefzayvfhdq7SGVuFxX+eFq3Urs hH/opZPy+ofLDGAKuvXz/3cWgoCwOqQRB1w/6CXjnSbA3vEArhSqeMm2Ql2iTCwJT0+x DSf+DUjiZHGfJwaCH9rISv6krKncvGnZriJ0QL5iWgOdcd05EzSFjStK2L1Fm2Aw6iYG EqULUupl8qiUQOVj6Mw3YfuZisKLNqYizZCr2jAt7xBBAnrl+8CiDyPWxyCn0Z1bkiPK nvbhEMhqXPbS8Ndw0W5B1U4+XaSZ17z8SoQpOmC7PFWxkGWqCvoprcEtxZE7SgQbLoOR EClQ== X-Gm-Message-State: AOJu0YyLN2nCa21KUr/awo1zYQQgC+j1o3IYcPvrKOX7fJ6CpyOZ9G4w aua/Pk/58SfZUmtDuuKrQvPxPNmBUkY+rQ== X-Google-Smtp-Source: AGHT+IGp1bsRFiz6YLZEIiDXqvJ855ELy7LCRke9b4wtXYqpjsSehvxj/UybMpn6j1N0JGm/z35JGg== X-Received: by 2002:a17:906:1d5:b0:a0a:c652:9bf8 with SMTP id 21-20020a17090601d500b00a0ac6529bf8mr2283764ejj.45.1700910886275; Sat, 25 Nov 2023 03:14:46 -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 z2-20020a170906434200b009ad7fc17b2asm3287246ejm.224.2023.11.25.03.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 03:14:44 -0800 (PST) Message-ID: In-Reply-To: <84c0bc8c4e65af2241b9dd15f494fdc7eedd83d1.1700910860.git.liliana.prikler@gmail.com> References: <84c0bc8c4e65af2241b9dd15f494fdc7eedd83d1.1700910860.git.liliana.prikler@gmail.com> From: Liliana Marie Prikler Date: Sat, 25 Nov 2023 12:13:53 +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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.52 X-Spam-Score: -3.52 X-Migadu-Queue-Id: C696A5D83A X-Migadu-Scanner: mx10.migadu.com X-TUID: 7Ev2sJUrAzbJ * 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 8d817379a7..e878551b37 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1111,6 +1111,7 @@ dist_patch_DATA = \ %D%/packages/patches/emacs-highlight-stages-add-gexp.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 55eab48c25..822d15cc94 100644 --- a/gnu/packages/emacs.scm +++ b/gnu/packages/emacs.scm @@ -110,6 +110,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