Subject: [bug#76529] [PATCH 2/4] gnu: emacs-next: Update to 31.0.50-0.60232a3.

From: Morgan Smith <[email-masked]>
Date: Mon, 24 Feb 2025 17:56:24 -0500

* gnu/packages/emacs.scm (emacs-next-minimal): Update to 31.0.50-0.60232a3.
* gnu/packages/patches/emacs-next-exec-path.patch: Regenerate.
* gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch: Regenerate.
* gnu/packages/patches/emacs-next-native-comp-driver-options.patch: Delete.
* gnu/local.mk: Remove deleted patch.

Change-Id: Id89d7445a978566139b7c0a7d15f8c5eac2d111e
---
 gnu/local.mk                                  |   1 -
 gnu/packages/emacs.scm                        |  10 +-
 .../patches/emacs-next-exec-path.patch        |  28 +-
 ...macs-next-native-comp-driver-options.patch |  18 -
 ...emacs-next-native-comp-fix-filenames.patch | 325 +++++++++---------
 5 files changed, 189 insertions(+), 193 deletions(-)
 delete mode 100644 gnu/packages/patches/emacs-next-native-comp-driver-options.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 45a9cb635e..48711dc385 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1229,7 +1229,6 @@ dist_patch_DATA =						\
   %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-next-native-comp-fix-filenames.patch   \
   %D%/packages/patches/emacs-pasp-mode-quote-file-names.patch  \
   %D%/packages/patches/emacs-pgtk-super-key-fix.patch	\
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 4d14feb38b..5de87720b4 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -572,12 +572,12 @@ (define-public emacs-wide-int
         #~(cons "--with-wide-int" #$flags))))))
 
 (define-public emacs-next-minimal
-  (let ((commit "881d593a9879f3355733f1b627af7cc0c12b429e")
+  (let ((commit "60232a30e360c00fb303cb033d4aec15a9e41342")
         (revision "0"))
-   (package
+  (package
     (inherit emacs-minimal)
     (name "emacs-next-minimal")
-    (version (git-version "30.0.92" revision commit))
+    (version (git-version "31.0.50" revision commit))
     (source
      (origin
        (method git-fetch)
@@ -586,12 +586,12 @@ (define-public emacs-next-minimal
              (commit commit)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0nj3a7wsl5piqf6a8wnmfyjbpxp2dwl0r48flv9q624jx4nxfr2p"))
+        (base32 "1n1i20j92a8sqv224yzvyzk804h9x0lgyp3jlny3b6g08ka91034"))
        (patches
         (search-patches "emacs-disable-jit-compilation.patch"
                         "emacs-next-exec-path.patch"
                         "emacs-fix-scheme-indent-function.patch"
-                        "emacs-next-native-comp-driver-options.patch"
+                        "emacs-native-comp-driver-options.patch"
                         "emacs-next-native-comp-fix-filenames.patch"
                         "emacs-native-comp-pin-packages.patch"
                         "emacs-pgtk-super-key-fix.patch")))))))
diff --git a/gnu/packages/patches/emacs-next-exec-path.patch b/gnu/packages/patches/emacs-next-exec-path.patch
index 6e33e25258..d815301578 100644
--- a/gnu/packages/patches/emacs-next-exec-path.patch
+++ b/gnu/packages/patches/emacs-next-exec-path.patch
@@ -1,18 +1,24 @@
-Do not capture the build-time value of $PATH in the 'emacs' executable
-since this can noticeably increase the size of the closure of Emacs
-with things like GCC being referenced.
+Do not capture the build-time value of $PATH in the 'emacs'
+executable since this can noticeably increase the size of the closure of
+Emacs with things like GCC being referenced.
+---
+ lisp/loadup.el | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
 
-Index: emacs-next/lisp/loadup.el
-===================================================================
---- emacs-next.orig/lisp/loadup.el
-+++ emacs-next/lisp/loadup.el
-@@ -599,7 +599,8 @@ lost after dumping")))
-                           ((equal dump-mode "dump") "emacs")
-                           ((equal dump-mode "bootstrap") "emacs")
-                           ((equal dump-mode "pbootstrap") "bootstrap-emacs.pdmp")
+diff --git a/lisp/loadup.el b/lisp/loadup.el
+index 9089da9a988..3d1b9e45dd1 100644
+--- a/lisp/loadup.el
++++ b/lisp/loadup.el
+@@ -603,7 +603,8 @@ comp-subr-arities-h
+                            (if (eq system-type 'ms-dos)
+                                "b-emacs.pdmp"
+                              "bootstrap-emacs.pdmp"))
 -                          (t (error "Unrecognized dump mode %s" dump-mode)))))
 +                          (t (error "Unrecognized dump mode %s" dump-mode))))
 +            (exec-path nil))
          (when (and (featurep 'native-compile)
                     (equal dump-mode "pdump"))
            ;; Don't enable this before bootstrap is completed, as the
+-- 
+2.48.1
+
diff --git a/gnu/packages/patches/emacs-next-native-comp-driver-options.patch b/gnu/packages/patches/emacs-next-native-comp-driver-options.patch
deleted file mode 100644
index e4ed5a48f1..0000000000
--- a/gnu/packages/patches/emacs-next-native-comp-driver-options.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-We substitute this anyway, so let's make it easier to substitute.
-
---- a/lisp/emacs-lisp/comp.el
-+++ b/lisp/emacs-lisp/comp.el
-@@ -203,9 +203,7 @@ and above."
-   :type '(repeat string)
-   :version "28.1")
- 
--(defcustom native-comp-driver-options
--  (cond ((eq system-type 'darwin) '("-Wl,-w"))
--        ((eq system-type 'cygwin) '("-Wl,-dynamicbase")))
-+(defcustom native-comp-driver-options nil
-   "Options passed verbatim to the native compiler's back-end driver.
- Note that not all options are meaningful; typically only the options
- affecting the assembler and linker are likely to be useful.
--- 
-2.38.0
-
diff --git a/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch b/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch
index 7897fa9b04..830d58cc00 100644
--- a/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch
+++ b/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch
@@ -11,12 +11,163 @@ way into the actual variable despite attempts to remove it by calling
 ‘startup--update-eln-cache’.
 The user-visible procedure ‘startup-redirect-eln-cache’ is kept, as
 packages may require it, but only pushes the new value now.
+---
+ lisp/loadup.el  |  38 ++++++++------
+ lisp/startup.el |  27 ----------
+ src/Makefile.in |   1 +
+ src/comp.c      | 134 +++++++++++++++++++-----------------------------
+ 4 files changed, 78 insertions(+), 122 deletions(-)
 
-Index: emacs-next/src/comp.c
-===================================================================
---- emacs-next.orig/src/comp.c
-+++ emacs-next/src/comp.c
-@@ -4403,26 +4403,17 @@ DEFUN ("comp-el-to-eln-rel-filename", Fc
+diff --git a/lisp/loadup.el b/lisp/loadup.el
+index 3d1b9e45dd1..398ecfd519e 100644
+--- a/lisp/loadup.el
++++ b/lisp/loadup.el
+@@ -53,6 +53,14 @@
+ (setq redisplay--inhibit-bidi t)
+ 
+ (message "Dump mode: %s" dump-mode)
++;; Compensate for native-comp-eln-load-path being empty by Guix' default.
++(and (featurep 'native-compile)
++     dump-mode
++     (setq
++      native-comp-eln-load-path
++      (cons (expand-file-name "../native-lisp" invocation-directory)
++            native-comp-eln-load-path)
++      comp-file-preloaded-p t))
+ 
+ ;; Add subdirectories to the load-path for files that might get
+ ;; autoloaded when bootstrapping or running Emacs normally.
+@@ -522,27 +530,25 @@ load--fixup-all-elns
+ directory got moved.  This is set to be a pair in the form of:
+ \(rel-filename-from-install-bin . rel-filename-from-local-bin)."
+   (when (and load--bin-dest-dir load--eln-dest-dir)
+-      (setq eln-dest-dir
+-          (concat load--eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
++      (setq load--eln-versioned-dest-dir
++            (concat load--eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
+       (maphash (lambda (_ cu)
+                (when (stringp (native-comp-unit-file cu))
+                  (let* ((file (native-comp-unit-file cu))
+-                        (preloaded (equal (substring (file-name-directory file)
+-                                                     -10 -1)
+-                                          "preloaded"))
+-                        (eln-dest-dir-eff (if preloaded
+-                                              (expand-file-name "preloaded"
+-                                                                eln-dest-dir)
+-                                            eln-dest-dir)))
++                        (native-lisp-needle
++                         (regexp-quote (concat "native-lisp/"
++                                               comp-native-version-dir "/"))))
+                    (native-comp-unit-set-file
+                     cu
+ 	            (cons
+                      ;; Relative filename from the installed binary.
+-                     (file-relative-name (expand-file-name
+-                                          (file-name-nondirectory
+-                                           file)
+-                                          eln-dest-dir-eff)
+-                                         load--bin-dest-dir)
++                     (file-relative-name
++                      (expand-file-name
++                       (save-match-data
++                         (string-match native-lisp-needle file)
++                         (substring file (match-end 0)))
++                       load--eln-versioned-dest-dir)
++                      load--bin-dest-dir)
+                      ;; Relative filename from the built uninstalled binary.
+                      (file-relative-name file invocation-directory))))))
+ 	     comp-loaded-comp-units-h)))
+@@ -609,7 +615,9 @@ comp-subr-arities-h
+                    (equal dump-mode "pdump"))
+           ;; Don't enable this before bootstrap is completed, as the
+           ;; compiler infrastructure may not be usable yet.
+-          (setq native-comp-enable-subr-trampolines t))
++          (setq native-comp-enable-subr-trampolines t
++                ;; We loaded everything we could.
++                comp-file-preloaded-p nil))
+         (message "Dumping under the name %s" output)
+         (condition-case ()
+             (delete-file output)
+diff --git a/lisp/startup.el b/lisp/startup.el
+index c240fbbe28a..f038ace6695 100644
+--- a/lisp/startup.el
++++ b/lisp/startup.el
+@@ -520,9 +520,6 @@ native-comp-eln-load-path
+ (defvar native-comp-jit-compilation)
+ (defvar native-comp-enable-subr-trampolines)
+ 
+-(defvar startup--original-eln-load-path nil
+-  "Original value of `native-comp-eln-load-path'.")
+-
+ (defun startup-redirect-eln-cache (cache-directory)
+   "Redirect the user's eln-cache directory to CACHE-DIRECTORY.
+ CACHE-DIRECTORY must be a single directory, a string.
+@@ -533,22 +530,10 @@ startup-redirect-eln-cache
+ For best results, call this function in your early-init file,
+ so that the rest of initialization and package loading uses
+ the updated value."
+-  ;; Remove the original eln-cache.
+-  (setq native-comp-eln-load-path (cdr native-comp-eln-load-path))
+-  ;; Add the new eln-cache.
+   (push (expand-file-name (file-name-as-directory cache-directory)
+                           user-emacs-directory)
+         native-comp-eln-load-path))
+ 
+-(defun startup--update-eln-cache ()
+-  "Update the user eln-cache directory due to user customizations."
+-  ;; Don't override user customizations!
+-  (when (equal native-comp-eln-load-path
+-               startup--original-eln-load-path)
+-    (startup-redirect-eln-cache "eln-cache")
+-    (setq startup--original-eln-load-path
+-          (copy-sequence native-comp-eln-load-path))))
+-
+ (defun startup--rescale-elt-match-p (font-pattern font-object)
+   "Test whether FONT-OBJECT matches an element of `face-font-rescale-alist'.
+ FONT-OBJECT is a font-object that specifies a font to test.
+@@ -1385,12 +1370,6 @@ command-line
+       startup-init-directory)))
+   (setq early-init-file user-init-file)
+ 
+-  ;; Amend `native-comp-eln-load-path', since the early-init file may
+-  ;; have altered `user-emacs-directory' and/or changed the eln-cache
+-  ;; directory.
+-  (when (featurep 'native-compile)
+-    (startup--update-eln-cache))
+-
+   ;; If any package directory exists, initialize the package system.
+   (and user-init-file
+        package-enable-at-startup
+@@ -1525,12 +1504,6 @@ command-line
+         startup-init-directory))
+      t)
+ 
+-    ;; Amend `native-comp-eln-load-path' again, since the early-init
+-    ;; file may have altered `user-emacs-directory' and/or changed the
+-    ;; eln-cache directory.
+-    (when (featurep 'native-compile)
+-      (startup--update-eln-cache))
+-
+     (when (and deactivate-mark transient-mark-mode)
+       (with-current-buffer (window-buffer)
+         (deactivate-mark)))
+diff --git a/src/Makefile.in b/src/Makefile.in
+index 8296329f136..13f1cb2eeda 100644
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -567,6 +567,7 @@ shortlisp :=
+ ## 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.
+diff --git a/src/comp.c b/src/comp.c
+index 36c45f1315d..e9d1bce555b 100644
+--- a/src/comp.c
++++ b/src/comp.c
+@@ -4279,26 +4279,17 @@ DEFUN ("comp-el-to-eln-rel-filename", Fcomp_el_to_eln_rel_filename,
         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.
@@ -49,7 +200,7 @@ Index: emacs-next/src/comp.c
    if (NILP (Ffile_exists_p (filename)))
      xsignal1 (Qfile_missing, filename);
  
-@@ -4430,64 +4421,55 @@ one for the file name and another for it
+@@ -4306,64 +4297,55 @@ DEFUN ("comp-el-to-eln-rel-filename", Fcomp_el_to_eln_rel_filename,
    filename = Fw32_long_file_name (filename);
  #endif
  
@@ -131,7 +282,7 @@ Index: emacs-next/src/comp.c
 +
 +  if (!NILP (bogus_dirs))
 +  {
-+    tail = CALL2I (split-string, bogus_dirs, build_string (":"));
++    tail = CALLNI (split-string, bogus_dirs, build_string (":"));
 +
 +    FOR_EACH_TAIL_SAFE (tail)
 +      {
@@ -157,7 +308,7 @@ Index: emacs-next/src/comp.c
  }
  
  DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
-@@ -4501,13 +4483,7 @@ If BASE-DIR is non-nil, use it as the di
+@@ -4377,13 +4359,7 @@ DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
  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
@@ -172,21 +323,21 @@ Index: emacs-next/src/comp.c
    (Lisp_Object filename, Lisp_Object base_dir)
  {
    Lisp_Object source_filename = filename;
-@@ -4555,10 +4531,11 @@ the latter is supposed to be used by the
+@@ -4431,10 +4407,11 @@ DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
    Lisp_Object lisp_preloaded =
      Fgetenv_internal (build_string ("LISP_PRELOADED"), Qnil);
    base_dir = Fexpand_file_name (Vcomp_native_version_dir, base_dir);
 +  bool preloaded = comp_file_preloaded_p;
    if (comp_file_preloaded_p
        || (!NILP (lisp_preloaded)
--	  && !NILP (Fmember (CALL1I (file-name-base, source_filename),
+-	  && !NILP (Fmember (CALLNI (file-name-base, source_filename),
 -			     Fmapcar (intern_c_string ("file-name-base"),
-+	  && !NILP (Fmember (CALL1I (file-name-sans-extension, source_filename),
++	  && !NILP (Fmember (CALLNI (file-name-sans-extension, source_filename),
 +			     Fmapcar (intern_c_string ("file-name-sans-extension"),
- 				      CALL1I (split-string, lisp_preloaded))))))
+ 				      CALLNI (split-string, lisp_preloaded))))))
      base_dir = Fexpand_file_name (build_string ("preloaded"), base_dir);
  
-@@ -5875,10 +5852,7 @@ The last directory of this list is assum
+@@ -5741,10 +5718,7 @@ syms_of_comp (void)
  the system *.eln files, which are the files produced when building
  Emacs.  */);
  
@@ -198,148 +349,6 @@ Index: emacs-next/src/comp.c
  
    DEFVAR_LISP ("native-comp-enable-subr-trampolines",
  	       Vnative_comp_enable_subr_trampolines,
-Index: emacs-next/lisp/startup.el
-===================================================================
---- emacs-next.orig/lisp/startup.el
-+++ emacs-next/lisp/startup.el
-@@ -527,9 +527,6 @@ DIRS are relative."
- (defvar native-comp-jit-compilation)
- (defvar native-comp-enable-subr-trampolines)
- 
--(defvar startup--original-eln-load-path nil
--  "Original value of `native-comp-eln-load-path'.")
--
- (defun startup-redirect-eln-cache (cache-directory)
-   "Redirect the user's eln-cache directory to CACHE-DIRECTORY.
- CACHE-DIRECTORY must be a single directory, a string.
-@@ -540,22 +537,10 @@ to `user-emacs-directory'.
- For best results, call this function in your early-init file,
- so that the rest of initialization and package loading uses
- the updated value."
--  ;; Remove the original eln-cache.
--  (setq native-comp-eln-load-path (cdr native-comp-eln-load-path))
--  ;; Add the new eln-cache.
-   (push (expand-file-name (file-name-as-directory cache-directory)
-                           user-emacs-directory)
-         native-comp-eln-load-path))
- 
--(defun startup--update-eln-cache ()
--  "Update the user eln-cache directory due to user customizations."
--  ;; Don't override user customizations!
--  (when (equal native-comp-eln-load-path
--               startup--original-eln-load-path)
--    (startup-redirect-eln-cache "eln-cache")
--    (setq startup--original-eln-load-path
--          (copy-sequence native-comp-eln-load-path))))
--
- (defun startup--rescale-elt-match-p (font-pattern font-object)
-   "Test whether FONT-OBJECT matches an element of `face-font-rescale-alist'.
- FONT-OBJECT is a font-object that specifies a font to test.
-@@ -1383,12 +1368,6 @@ please check its value")
-       startup-init-directory)))
-   (setq early-init-file user-init-file)
- 
--  ;; Amend `native-comp-eln-load-path', since the early-init file may
--  ;; have altered `user-emacs-directory' and/or changed the eln-cache
--  ;; directory.
--  (when (featurep 'native-compile)
--    (startup--update-eln-cache))
--
-   ;; If any package directory exists, initialize the package system.
-   (and user-init-file
-        package-enable-at-startup
-@@ -1523,12 +1502,6 @@ please check its value")
-         startup-init-directory))
-      t)
- 
--    ;; Amend `native-comp-eln-load-path' again, since the early-init
--    ;; file may have altered `user-emacs-directory' and/or changed the
--    ;; eln-cache directory.
--    (when (featurep 'native-compile)
--      (startup--update-eln-cache))
--
-     (when (and deactivate-mark transient-mark-mode)
-       (with-current-buffer (window-buffer)
-         (deactivate-mark)))
-Index: emacs-next/lisp/loadup.el
-===================================================================
---- emacs-next.orig/lisp/loadup.el
-+++ emacs-next/lisp/loadup.el
-@@ -53,6 +53,14 @@
- (setq redisplay--inhibit-bidi t)
- 
- (message "Dump mode: %s" dump-mode)
-+;; Compensate for native-comp-eln-load-path being empty by Guix' default.
-+(and (featurep 'native-compile)
-+     dump-mode
-+     (setq
-+      native-comp-eln-load-path
-+      (cons (expand-file-name "../native-lisp" invocation-directory)
-+            native-comp-eln-load-path)
-+      comp-file-preloaded-p t))
- 
- ;; Add subdirectories to the load-path for files that might get
- ;; autoloaded when bootstrapping or running Emacs normally.
-@@ -538,27 +546,25 @@ This to have it working when installed o
- directory got moved.  This is set to be a pair in the form of:
- \(rel-filename-from-install-bin . rel-filename-from-local-bin)."
-   (when (and load--bin-dest-dir load--eln-dest-dir)
--      (setq eln-dest-dir
--          (concat load--eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
-+      (setq load--eln-versioned-dest-dir
-+            (concat load--eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
-       (maphash (lambda (_ cu)
-                (when (stringp (native-comp-unit-file cu))
-                  (let* ((file (native-comp-unit-file cu))
--                        (preloaded (equal (substring (file-name-directory file)
--                                                     -10 -1)
--                                          "preloaded"))
--                        (eln-dest-dir-eff (if preloaded
--                                              (expand-file-name "preloaded"
--                                                                eln-dest-dir)
--                                            eln-dest-dir)))
-+                        (native-lisp-needle
-+                         (regexp-quote (concat "native-lisp/"
-+                                               comp-native-version-dir "/"))))
-                    (native-comp-unit-set-file
-                     cu
- 	            (cons
-                      ;; Relative filename from the installed binary.
--                     (file-relative-name (expand-file-name
--                                          (file-name-nondirectory
--                                           file)
--                                          eln-dest-dir-eff)
--                                         load--bin-dest-dir)
-+                     (file-relative-name
-+                      (expand-file-name
-+                       (save-match-data
-+                         (string-match native-lisp-needle file)
-+                         (substring file (match-end 0)))
-+                       load--eln-versioned-dest-dir)
-+                      load--bin-dest-dir)
-                      ;; Relative filename from the built uninstalled binary.
-                      (file-relative-name file invocation-directory))))))
- 	     comp-loaded-comp-units-h)))
-@@ -644,7 +650,9 @@ directory got moved.  This is set to be
-                    (equal dump-mode "pdump"))
-           ;; Don't enable this before bootstrap is completed, as the
-           ;; compiler infrastructure may not be usable yet.
--          (setq native-comp-enable-subr-trampolines t))
-+          (setq native-comp-enable-subr-trampolines t
-+                ;; We loaded everything we could.
-+                comp-file-preloaded-p nil))
-         (message "Dumping under the name %s" output)
-         (condition-case ()
-             (delete-file output)
-Index: emacs-next/src/Makefile.in
-===================================================================
---- emacs-next.orig/src/Makefile.in
-+++ emacs-next/src/Makefile.in
-@@ -591,6 +591,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.48.1
+
-- 
2.48.1