all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: 67292@debbugs.gnu.org
Cc: Mekeor Melire <mekeor@posteo.de>,
	Maxime Devos <maximedevos@telenet.be>,
	Simon Tournier <zimon.toutoune@gmail.com>,
	andrew@trop.in, cox.katherine.e+guix@gmail.com,
	liliana.prikler@gmail.com
Subject: bug#67292: [PATCH] gnu: emacs: Pin natively compiled packages.
Date: Sun, 8 Dec 2024 18:30:54 +0100	[thread overview]
Message-ID: <01f9481f9ab86a21bc85e82a6f2a7e3457d2709e.1733679675.git.liliana.prikler@gmail.com> (raw)
In-Reply-To: <5b74251c-e6ab-bb39-7892-3a792ed6854d@telenet.be>

* gnu/packages/patches/emacs-native-comp-pin-packages.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs)[source]: Use it here.
[#:phases]: Remove ‘disable-native-compilation’.

Fixes: Emacs native-comp collisions <https://issues.guix.gnu.org/67292>
---
Hi Guix

I finally got around to fixing this issue.  The fix is actually quite simple:
it checks that the candidate eln file resides under the same prefix as the elc
file it was generated from.  With this change applied

* `guix shell emacs` will allow emacs to load its own natively-compiled
  transient, assuming a previously clean environment
* `guix shell emacs emacs-transient` will instead load the byte-compiled
  transient from emacs-transient
* `guix shell emacs emacs-transient --with-input=emacs-minimal=emacs` will
  load the native-compiled emacs

We still have to find a better way to enable native compilation for everything,
but this will give us the best performance possible while avoiding similar
issues in the future (side-eyeing org-mode, cc-mode et al. for possible
breakages).

Cheers

 gnu/local.mk                                  |  1 +
 gnu/packages/emacs.scm                        | 11 +-----
 .../emacs-native-comp-pin-packages.patch      | 39 +++++++++++++++++++
 3 files changed, 41 insertions(+), 10 deletions(-)
 create mode 100644 gnu/packages/patches/emacs-native-comp-pin-packages.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a02745d59c..652a6c1748 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1195,6 +1195,7 @@ dist_patch_DATA =						\
   %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-native-comp-pin-packages.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 8140f61882..b0690fc4fb 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -117,6 +117,7 @@ (define-public emacs-minimal
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
                                        "emacs-native-comp-fix-filenames.patch"
+                                       "emacs-native-comp-pin-packages.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
@@ -233,16 +234,6 @@ (define-public emacs-minimal
                 (("\\(tramp-compat-process-running-p \"(.*)\"\\)" all process)
                  (format #f "(or ~a (tramp-compat-process-running-p ~s))"
                          all (string-append "." process "-real"))))))
-          (add-after 'unpack 'disable-native-compilation
-            (lambda _
-              ;; Temporary workaround to prevent the behaviour discussed in
-              ;; <https://issues.guix.gnu.org/72333>.
-              ;; Please remove once the native-compilation for Emacs packages
-              ;; is fully supported.
-              (substitute* "lisp/transient.el"
-                ((";; End:")
-                 ";; no-native-compile: t
-;; End:"))))
           (add-before 'configure 'fix-/bin/pwd
             (lambda _
               ;; Use `pwd', not `/bin/pwd'.
diff --git a/gnu/packages/patches/emacs-native-comp-pin-packages.patch b/gnu/packages/patches/emacs-native-comp-pin-packages.patch
new file mode 100644
index 0000000000..dc328f03a8
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-pin-packages.patch
@@ -0,0 +1,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);
+ 

base-commit: 17d86ac9df841deca4f2f5e173f50bd2461fe680
-- 
2.46.0





  parent reply	other threads:[~2024-12-08 17:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-19 22:44 bug#67292: emacs / emacs-transient collisions and bundling Maxime Devos
2023-11-20 10:22 ` Simon Tournier
2023-11-20 12:39   ` Maxime Devos
2023-11-20 12:42     ` Maxime Devos
2023-11-20 13:46     ` Simon Tournier
2023-11-21 18:01       ` Maxime Devos
2023-11-22 20:53         ` Simon Tournier
2023-11-28  1:47           ` Maxime Devos
2023-11-28  9:45             ` Simon Tournier
2023-11-28 11:15             ` Mekeor Melire
2023-11-23 14:17     ` Mekeor Melire
2023-11-28  0:58       ` Maxime Devos
2023-11-28 11:12         ` Mekeor Melire
2024-12-08 17:30 ` Liliana Marie Prikler [this message]
2024-12-09  7:45   ` bug#67292: [PATCH] gnu: emacs: Pin natively compiled packages Andrew Tropin via Bug reports for GNU Guix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01f9481f9ab86a21bc85e82a6f2a7e3457d2709e.1733679675.git.liliana.prikler@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=67292@debbugs.gnu.org \
    --cc=andrew@trop.in \
    --cc=cox.katherine.e+guix@gmail.com \
    --cc=maximedevos@telenet.be \
    --cc=mekeor@posteo.de \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.