unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 714b707e47d93bde51f27ec35840ab1568f03c5f 8142 bytes (raw)
name: gnu/packages/patches/emacs-native-comp-fix-filenames.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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.

debug log:

solving 714b707e47 ...
found 714b707e47 in https://yhetil.org/guix-patches/388d3766e6908331c0704687141f33aeae7ee969.1705846445.git.liliana.prikler@gmail.com/ ||
	https://yhetil.org/guix-patches/daf346bcc21247579cb4a10d48c7c4407a7b7283.1700910860.git.liliana.prikler@gmail.com/ ||
	https://yhetil.org/guix-patches/aad2e3895e09474924d466b8c6c2cd15cd90e857.1705957032.git.liliana.prikler@gmail.com/

applying [1/1] https://yhetil.org/guix-patches/388d3766e6908331c0704687141f33aeae7ee969.1705846445.git.liliana.prikler@gmail.com/
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

1:34: trailing whitespace.
 
1:46: trailing whitespace.
 
1:50: trailing whitespace.
 
1:54: trailing whitespace.
 
1:67: trailing whitespace.
 
Checking patch gnu/packages/patches/emacs-native-comp-fix-filenames.patch...
Applied patch gnu/packages/patches/emacs-native-comp-fix-filenames.patch cleanly.
warning: squelched 7 whitespace errors
warning: 12 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/daf346bcc21247579cb4a10d48c7c4407a7b7283.1700910860.git.liliana.prikler@gmail.com/ for 714b707e47
skipping https://yhetil.org/guix-patches/aad2e3895e09474924d466b8c6c2cd15cd90e857.1705957032.git.liliana.prikler@gmail.com/ for 714b707e47
index at:
100644 714b707e47d93bde51f27ec35840ab1568f03c5f	gnu/packages/patches/emacs-native-comp-fix-filenames.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).