aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/emacs-native-comp-pin-packages.patch
blob: dc328f03a85ee9dbdbd307c604b71e35bce20332 (about) (plain)
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
Index: emacs-29.4/src/lread.c
===================================================================
--- emacs-29.4.orig/src/lread.c
+++ emacs-29.4/src/lread.c
@@ -1668,9 +1668,34 @@ directories, make sure the PREDICATE fun
 
 #ifdef HAVE_NATIVE_COMP
 static bool
+permit_swap_for_eln (Lisp_Object src_name, Lisp_Object eln_name)
+{
+  char *src = SSDATA (src_name), *eln = SSDATA (eln_name);
+  size_t eln_ln = strlen (eln);
+
+  while (*src && *eln && *src == *eln)
+    {
+      ++src; ++eln; --eln_ln;
+    }
+
+  /* After stripping common prefixes, the first directory should be
+   * "lib/" (inside the Guix store) or "native-lisp" (inside Emacs build).
+   * Alternatively, if eln contains "eln-cache", it's likely the user's
+   * cache, which we will also permit. */
+
+  return
+    (eln_ln > 4 && !strncmp (eln, "lib/", 4)) ||
+    (eln_ln > 12 && !strncmp (eln, "native-lisp/", 12)) ||
+    strstr (eln, "eln-cache") != NULL;
+}
+
+static bool
 maybe_swap_for_eln1 (Lisp_Object src_name, Lisp_Object eln_name,
 		     Lisp_Object *filename, int *fd, struct timespec mtime)
 {
+  if (!permit_swap_for_eln (src_name, eln_name))
+    return false;
+
   struct stat eln_st;
   int eln_fd = emacs_open (SSDATA (ENCODE_FILE (eln_name)), O_RDONLY, 0);