Subject: [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation.

From: Liliana Marie Prikler <[email-masked]>
Date: Tue, 13 Feb 2024 19:30:50 +0100

* gnu/packages/patches/emacs-disable-jit-compilation.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[patches]: Use it here.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/emacs.scm                        |  3 ++-
 .../emacs-disable-jit-compilation.patch       | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/emacs-disable-jit-compilation.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 7e6a0c5006..9121f13b39 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1112,6 +1112,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-all-the-icons-remove-duplicate-rs.patch	\
   %D%/packages/patches/emacs-deferred-fix-number-of-arguments.patch	\
   %D%/packages/patches/emacs-elpy-dup-test-name.patch		\
+  %D%/packages/patches/emacs-disable-jit-compilation.patch			\
   %D%/packages/patches/emacs-exec-path.patch			\
   %D%/packages/patches/emacs-fix-scheme-indent-function.patch	\
   %D%/packages/patches/emacs-git-email-missing-parens.patch	\
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 1caa2cbee0..03c50eba6d 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -108,7 +108,8 @@ (define-public emacs-minimal
               (sha256
                (base32
                 "1p3h4sz8da8vhix5140g2qkdy8mz11d7mmvsym5vy847k1428gbx"))
-              (patches (search-patches "emacs-exec-path.patch"
+              (patches (search-patches "emacs-disable-jit-compilation.patch"
+                                       "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
                                        "emacs-native-comp-fix-filenames.patch"
diff --git a/gnu/packages/patches/emacs-disable-jit-compilation.patch b/gnu/packages/patches/emacs-disable-jit-compilation.patch
new file mode 100644
index 0000000000..8b1ac5a9df
--- /dev/null
+++ b/gnu/packages/patches/emacs-disable-jit-compilation.patch
@@ -0,0 +1,19 @@
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -5648,8 +5648,12 @@ For internal use. */);
+     doc: /* If non-nil, compile loaded .elc files asynchronously.
+ 
+ After compilation, each function definition is updated to use the
+-natively-compiled one.  */);
+-  native_comp_jit_compilation = true;
++natively-compiled one.  This variable is enabled by default upstream,
++but disabled in Guix to better make use of precompiled packages.
++Notably, Guix removes the hashes that prevent inadvertent shadowing
++frm the file names of compiled libraries in order to facilitate grafts.
++Enable at your own risk!  */);
++  native_comp_jit_compilation = false;
+ 
+   DEFSYM (Qnative_comp_speed, "native-comp-speed");
+   DEFSYM (Qnative_comp_debug, "native-comp-debug");
-- 
2.41.0