unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#67260] [PATCH emacs-team 2/2] gnu: emacs: Don't hash file names in native compilation.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
@ 2023-11-18 13:38 ` Liliana Marie Prikler
  2023-11-18 15:44 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Andrew Tropin
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-18 13:38 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |  1 +
 gnu/packages/emacs.scm                        |  1 +
 .../emacs-native-comp-fix-filenames.patch     | 93 +++++++++++++++++++
 3 files changed, 95 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 8d817379a7..e878551b37 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1111,6 +1111,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
   %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-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 55eab48c25..822d15cc94 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -110,6 +110,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..f461bc8a78
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,93 @@
+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.
+
+Index: emacs-29.1/src/comp.c
+===================================================================
+--- emacs-29.1.orig/src/comp.c
++++ emacs-29.1/src/comp.c
+@@ -4399,8 +4399,8 @@ FILENAME must exist, and if it's a symli
+ 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.  */)
++Value includes the original base name, followed by a hash of its
++content, followed by .eln.  */)
+   (Lisp_Object filename)
+ {
+   CHECK_STRING (filename);
+@@ -4423,64 +4423,26 @@ 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
++  /* We create eln filenames with a 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.
++     filename.el + content -> eln-cache/filename-content_hash.eln.
+ 
+      '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.
++     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.  */
++  Lisp_Object content_hash = comp_hash_source_file (filename);
++  Lisp_Object separator = build_string ("-");
+ 
+-  if (NILP (loadsearch_re_list))
+-    {
+-      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));
+-    }
++  if (suffix_p (filename, ".gz"))
++    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
+ 
+-  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)))
+-	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, 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));
++  return concat3 (filename, content_hash, build_string (NATIVE_ELISP_SUFFIX));
+ }
+ 
+ DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling
@ 2023-11-18 13:42 Liliana Marie Prikler
  2023-11-18 13:38 ` [bug#67260] [PATCH emacs-team 2/2] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
                   ` (28 more replies)
  0 siblings, 29 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-18 13:42 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

Hi Guix,

this series (hopefully) makes it so that everything we need to be natively
compiled in Emacs a) is natively compiled, and b) is found in the right
location.  Please check that you no longer get gratuitous writes to your
local eln-cache when trying this out.

Cheers

Fixes: emacs-build-system … mismatching hashes <https://bugs.gnu.org/66864>

Liliana Marie Prikler (2):
  gnu: emacs: Build trampolines.
  gnu: emacs: Don't hash file names in native compilation.

 gnu/local.mk                                  |  1 +
 gnu/packages/emacs.scm                        |  6 +-
 .../emacs-native-comp-fix-filenames.patch     | 93 +++++++++++++++++++
 3 files changed, 99 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch


base-commit: 60c97924e9519361494aaf0686e28eb831a42315
-- 
2.41.0





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
  2023-11-18 13:38 ` [bug#67260] [PATCH emacs-team 2/2] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2023-11-18 15:44 ` Andrew Tropin
  2023-11-18 15:51   ` Liliana Marie Prikler
  2023-11-22 12:09 ` Mekeor Melire
                   ` (26 subsequent siblings)
  28 siblings, 1 reply; 96+ messages in thread
From: Andrew Tropin @ 2023-11-18 15:44 UTC (permalink / raw)
  To: Liliana Marie Prikler, 67260; +Cc: cox.katherine.e+guix, liliana.prikler

[-- Attachment #1: Type: text/plain, Size: 2803 bytes --]

On 2023-11-18 14:42, Liliana Marie Prikler wrote:

> Hi Guix,
>
> this series (hopefully) makes it so that everything we need to be natively
> compiled in Emacs a) is natively compiled, and b) is found in the right
> location.  Please check that you no longer get gratuitous writes to your
> local eln-cache when trying this out.
>
> Cheers
>
> Fixes: emacs-build-system … mismatching hashes <https://bugs.gnu.org/66864>
>
> Liliana Marie Prikler (2):
>   gnu: emacs: Build trampolines.
>   gnu: emacs: Don't hash file names in native compilation.
>
>  gnu/local.mk                                  |  1 +
>  gnu/packages/emacs.scm                        |  6 +-
>  .../emacs-native-comp-fix-filenames.patch     | 93 +++++++++++++++++++
>  3 files changed, 99 insertions(+), 1 deletion(-)
>  create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch
>
>
> base-commit: 60c97924e9519361494aaf0686e28eb831a42315

--8<---------------cut here---------------start------------->8---
$ rm -r ~/.config/emacs/eln-cache/29.1-09dbbf4e
$ guix time-machine --branch=emacs-team -- shell emacs-pgtk emacs-magit --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q
(require 'magit)
C-x C-c
$ ls ~/.config/emacs/eln-cache/29.1-09dbbf4e
dash-6c86c585-82fea3ab.eln              magit-log-58eeae71-b655dbfb.eln      magit-section-6e195547-0461e8af.eln
git-commit-927a864a-05a352a6.eln        magit-margin-ec1cc1e9-b1c0e957.eln   magit-sequence-40a35869-1b719931.eln
magit-7056b331-38ef85d9.eln             magit-merge-0070f654-7bc0ed2b.eln    magit-stash-06fe9f6e-f2a708b65jGJrl.eln.tmp
magit-autorevert-54dea36c-bf1f5ea3.eln  magit-mode-5ad95198-31fbb927.eln     magit-status-70fcb10a-f6654216.eln
magit-base-cd520092-751fcac2.eln        magit-notes-17dfe23c-ce57b283.eln    magit-tag-e968dc8c-f7b42d89.eln
magit-bisect-8f9f6b8f-6fbb9bc2.eln      magit-process-3e9d760a-410e523c.eln  magit-transient-1d163154-ba4b9651.eln
magit-branch-b9c8386b-b362e334.eln      magit-pull-1f116009-3bf3af7f.eln     magit-wip-99682fc2-0371c052.eln
magit-clone-28b35658-e3db2e06.eln       magit-push-08e42ed4-b67bbe05.eln     magit-worktree-8f50ba9f-7b120e5d.eln
magit-commit-18780595-ac089f0e.eln      magit-reflog-4106970e-69fc9edb.eln   subr--trampoline-6d616b652d70726f63657373_make_process_0.eln
magit-diff-278da2fe-8132fe46.eln        magit-refs-1e67efee-ab4fef69.eln     transient-29183598-be63c251.eln
magit-fetch-5ba6406a-029daf61.eln       magit-remote-55bccbe3-bb4a4595.eln   with-editor-415da08e-ddc1b93b.eln
magit-files-1ee9fbef-d629cbfc.eln       magit-repos-a48553be-da9ca79c.eln
magit-git-736caf3b-1398a0cc.eln         magit-reset-902f52f7-709d5f56.eln
--8<---------------cut here---------------end--------------->8---

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling
  2023-11-18 15:44 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Andrew Tropin
@ 2023-11-18 15:51   ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-18 15:51 UTC (permalink / raw)
  To: Andrew Tropin, 67260; +Cc: cox.katherine.e+guix

Am Samstag, dem 18.11.2023 um 19:44 +0400 schrieb Andrew Tropin:
> On 2023-11-18 14:42, Liliana Marie Prikler wrote:
> 
> > Hi Guix,
> > 
> > this series (hopefully) makes it so that everything we need to be
> > natively compiled in Emacs a) is natively compiled, and b) is found
> > in the right location.  Please check that you no longer get
> > gratuitous writes to your local eln-cache when trying this out.
> > 
> > Cheers
> > 
> > Fixes: emacs-build-system … mismatching hashes
> > <https://bugs.gnu.org/66864>
> > 
> > Liliana Marie Prikler (2):
> >   gnu: emacs: Build trampolines.
> >   gnu: emacs: Don't hash file names in native compilation.
> > 
> >  gnu/local.mk                                  |  1 +
> >  gnu/packages/emacs.scm                        |  6 +-
> >  .../emacs-native-comp-fix-filenames.patch     | 93
> > +++++++++++++++++++
> >  3 files changed, 99 insertions(+), 1 deletion(-)
> >  create mode 100644 gnu/packages/patches/emacs-native-comp-fix-
> > filenames.patch
> > 
> > 
> > base-commit: 60c97924e9519361494aaf0686e28eb831a42315
> 
> --8<---------------cut here---------------start------------->8---
> $ rm -r ~/.config/emacs/eln-cache/29.1-09dbbf4e
> $ guix time-machine --branch=emacs-team -- shell emacs-pgtk emacs-
> magit --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q
> (require 'magit)
> C-x C-c
> $ ls ~/.config/emacs/eln-cache/29.1-09dbbf4e
> dash-6c86c585-82fea3ab.eln              magit-log-58eeae71-
> b655dbfb.eln      magit-section-6e195547-0461e8af.eln
> git-commit-927a864a-05a352a6.eln        magit-margin-ec1cc1e9-
> b1c0e957.eln   magit-sequence-40a35869-1b719931.eln
> magit-7056b331-38ef85d9.eln             magit-merge-0070f654-
> 7bc0ed2b.eln    magit-stash-06fe9f6e-f2a708b65jGJrl.eln.tmp
> magit-autorevert-54dea36c-bf1f5ea3.eln  magit-mode-5ad95198-
> 31fbb927.eln     magit-status-70fcb10a-f6654216.eln
> magit-base-cd520092-751fcac2.eln        magit-notes-17dfe23c-
> ce57b283.eln    magit-tag-e968dc8c-f7b42d89.eln
> magit-bisect-8f9f6b8f-6fbb9bc2.eln      magit-process-3e9d760a-
> 410e523c.eln  magit-transient-1d163154-ba4b9651.eln
> magit-branch-b9c8386b-b362e334.eln      magit-pull-1f116009-
> 3bf3af7f.eln     magit-wip-99682fc2-0371c052.eln
> magit-clone-28b35658-e3db2e06.eln       magit-push-08e42ed4-
> b67bbe05.eln     magit-worktree-8f50ba9f-7b120e5d.eln
> magit-commit-18780595-ac089f0e.eln      magit-reflog-4106970e-
> 69fc9edb.eln   subr--trampoline-
> 6d616b652d70726f63657373_make_process_0.eln
> magit-diff-278da2fe-8132fe46.eln        magit-refs-1e67efee-
> ab4fef69.eln     transient-29183598-be63c251.eln
> magit-fetch-5ba6406a-029daf61.eln       magit-remote-55bccbe3-
> bb4a4595.eln   with-editor-415da08e-ddc1b93b.eln
> magit-files-1ee9fbef-d629cbfc.eln       magit-repos-a48553be-
> da9ca79c.eln
> magit-git-736caf3b-1398a0cc.eln         magit-reset-902f52f7-
> 709d5f56.eln
> --8<---------------cut here---------------end--------------->8---
Oof.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
  2023-11-18 13:38 ` [bug#67260] [PATCH emacs-team 2/2] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
  2023-11-18 15:44 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Andrew Tropin
@ 2023-11-22 12:09 ` Mekeor Melire
  2023-11-22 17:39   ` Liliana Marie Prikler
  2023-11-25 11:13 ` [bug#67260] [PATCH emacs-team v3 1/3] gnu: emacs: Build trampolines Liliana Marie Prikler
                   ` (25 subsequent siblings)
  28 siblings, 1 reply; 96+ messages in thread
From: Mekeor Melire @ 2023-11-22 12:09 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

2023-11-18 14:42 liliana.prikler@gmail.com:

> Hi Guix,

Hello and thank you for your efforts on this issue.

> Liliana Marie Prikler (2):
>   gnu: emacs: Build trampolines.
>   gnu: emacs: Don't hash file names in native compilation.

It seems like this is a series of two commits but I only received one, namely the second one ("2/2"). Is it just me or did the first commit went missing for everyone?

Also, are these commits still on emacs-team branch? Andrew's command (guix time-machine --branch=emacs-team -- shell ...) made me assume that these commits were pushed to emacs-team branch, but I can't find them there.

I'd be glad to try this patch-series out - at some point, when I have more time.




^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling
  2023-11-22 12:09 ` Mekeor Melire
@ 2023-11-22 17:39   ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-22 17:39 UTC (permalink / raw)
  To: Mekeor Melire; +Cc: cox.katherine.e+guix, 67260, andrew

Am Mittwoch, dem 22.11.2023 um 12:09 +0000 schrieb Mekeor Melire:
> 2023-11-18 14:42 liliana.prikler@gmail.com:
> 
> > Hi Guix,
> 
> Hello and thank you for your efforts on this issue.
> 
> > Liliana Marie Prikler (2):
> >   gnu: emacs: Build trampolines.
> >   gnu: emacs: Don't hash file names in native compilation.
> 
> It seems like this is a series of two commits but I only received
> one, namely the second one ("2/2"). Is it just me or did the first
> commit went missing for everyone?
> 
> Also, are these commits still on emacs-team branch? Andrew's command
> (guix time-machine --branch=emacs-team -- shell ...) made me assume
> that these commits were pushed to emacs-team branch, but I can't find
> them there.
> 
> I'd be glad to try this patch-series out - at some point, when I have
> more time.
These are commits submitted to the emacs-branch – they are not
upstreamed yet.

I'll have a v2 up hopefully soon; things sadly aren't as smooth as I'd
assumed.

Cheers




^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v3 1/3] gnu: emacs: Build trampolines.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (2 preceding siblings ...)
  2023-11-22 12:09 ` Mekeor Melire
@ 2023-11-25 11:13 ` Liliana Marie Prikler
  2023-11-25 11:13   ` [bug#67260] [PATCH emacs-team v3 3/3] build-system: emacs: Compute relative file names Liliana Marie Prikler
  2023-11-25 11:13   ` [bug#67260] [PATCH emacs-team v3 2/3] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
  2024-01-18  5:55 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Suhail via Guix-patches via
                   ` (24 subsequent siblings)
  28 siblings, 2 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-25 11:13 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, andrew

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index b9d9e2b891..55eab48c25 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -327,7 +327,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls

base-commit: 60c97924e9519361494aaf0686e28eb831a42315
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v3 2/3] gnu: emacs: Don't hash file names in native compilation.
  2023-11-25 11:13 ` [bug#67260] [PATCH emacs-team v3 1/3] gnu: emacs: Build trampolines Liliana Marie Prikler
  2023-11-25 11:13   ` [bug#67260] [PATCH emacs-team v3 3/3] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2023-11-25 11:13   ` Liliana Marie Prikler
  1 sibling, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-25 11:13 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, andrew

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 197 ++++++++++++++++++
 3 files changed, 199 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 8d817379a7..e878551b37 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1111,6 +1111,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
   %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-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 55eab48c25..822d15cc94 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -110,6 +110,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,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.
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v3 3/3] build-system: emacs: Compute relative file names.
  2023-11-25 11:13 ` [bug#67260] [PATCH emacs-team v3 1/3] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2023-11-25 11:13   ` Liliana Marie Prikler
  2023-11-25 11:13   ` [bug#67260] [PATCH emacs-team v3 2/3] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
  1 sibling, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2023-11-25 11:13 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, andrew

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (3 preceding siblings ...)
  2023-11-25 11:13 ` [bug#67260] [PATCH emacs-team v3 1/3] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-01-18  5:55 ` Suhail via Guix-patches via
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-18  5:55 UTC (permalink / raw)
  To: 67260

Reporting some observations for the benefit of the community.

I managed to install the following sequence of patches on emacs-team
commit 60c97924e9 :
- v3 1/3
- v3 2/3
- v3 3/3
- v4 4/5
- v4 5/5

I was able to build emacs, emacs-org and a few additional packages using
the options "--no-grafts --with-input=emacs-minimal=emacs".  When
building "emacs-org-contrib" the additional option
"--without-tests=emacs-clojure-mode" was needed as well.

Having done so, upon starting emacs via guix-shell, I noticed a few
messages in *Async-native-compile-log* which noted that libraries such
as rx.el.gz and cl-macs.el.gz were being compiled.  I observed
native-compiled versions of these show up in ~/.emacs.d/eln-cache.  Now
this seems similar to the behaviour I observe in a non-Guix host where
Emacs 29.1 is installed via the OS.  There too my ~/.emacs.d/eln-cache
has a number of entries that I was a little surprised to see such as
those corresponding to rx and cl-macs.

One difference, however, is in the names and the relative locations of
these natively-compiled files.  Outside of the guix shell (i.e., using
the OS's native Emacs package) the eln files are named like
~/.emacs.d/eln-cache/29.1-115521d4/cl-macs-7ae82f81-e626a10e.eln whereas
within the Guix shell using Emacs built from the installed patches you
get names like
~/.emacs.d/eln-cache/29.1-c187d49d/emacs-lisp/cl-macs.eln.  Note the
sub-directory within the 29.1-* directory present within guix-shell
container, as well as the lack of hash fingerprint in the *.eln file
itself.

I do not know if these differences are to be expected, or whether or not
they're material in any way.

Thoughts?  Can this patch series be installed into emacs-team as-is?  If
not, what are the current blockers, if any?  On a somewhat related note,
when is the next merge from emacs-team to master expected to be?

-- 
Suhail

This email is not an offer capable of acceptance, does not evidence an
intention to enter into an agreement, has no operative effect until a
definitive agreement is signed in writing by both parties, and that no
party should act in reliance on the email or any representations of the
sender until a definitive agreement is signed in writing by both
parties.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (4 preceding siblings ...)
  2024-01-18  5:55 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Suhail via Guix-patches via
@ 2024-01-21 12:12 ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 2/6] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
                     ` (4 more replies)
  2024-01-22  4:16 ` Suhail via Guix-patches via
                   ` (22 subsequent siblings)
  28 siblings, 5 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..e4119ec21d 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -376,7 +376,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls

base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 2/7] gnu: emacs: Build trampolines.
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 5/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2cdc9b8bca..0292b1bd16 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -384,7 +384,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines.
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2cdc9b8bca..0292b1bd16 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -384,7 +384,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 2/7] gnu: emacs: Build trampolines.
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2cdc9b8bca..0292b1bd16 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -384,7 +384,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 2/6] gnu: emacs: Don't hash file names in native compilation.
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 5/6] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 197 ++++++++++++++++++
 3 files changed, 199 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 e4119ec21d..182de0204d 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,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.
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 4/6] gnu: emacs-org: Fix native builds.
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 3/6] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v5 6/6] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  4 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 5/6] gnu: emacs-magit: Fix native builds.
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 2/6] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 3/6] build-system: emacs: Compute relative file names Liliana Marie Prikler
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 3/6] build-system: emacs: Compute relative file names.
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 2/6] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 5/6] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 4/6] gnu: emacs-org: Fix native builds Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v5 6/6] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  4 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 6/7] gnu: emacs-magit: Fix native builds.
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 4/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v6 7/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 5/7] gnu: emacs-org: Fix native builds.
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 4/7] build-system: emacs: Compute relative file names.
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 6/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v6 7/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 3/7] gnu: emacs: Don't hash file names in native compilation.
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 5/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 4/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 197 ++++++++++++++++++
 3 files changed, 199 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 0292b1bd16..1caa2cbee0 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,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.
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names.
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds.
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds.
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation.
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 14430 bytes --]

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 291 ++++++++++++++++++
 3 files changed, 293 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 0292b1bd16..1caa2cbee0 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..d4bddc5901
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,291 @@
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -4396,26 +4396,17 @@ 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.  */)
+   (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 +4414,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);
++  Lisp_Object tail = Vload_path;
++  Lisp_Object name_len = Flength (filename);
+ 
+-  if (suffix_p (filename, ".gz"))
+-    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
++  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;
++	}
++    }
+ 
+-  /* We create eln filenames with an hash in order to look-up these
+-     starting from the source filename, IOW have a relation
++  if (Ffile_name_absolute_p (filename))
++    filename = rel_name;
+ 
+-     /absolute/path/filename.el + content ->
+-     eln-cache/filename-path_hash-content_hash.eln.
++  Lisp_Object bogus_dirs =
++    Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil);
+ 
+-     '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 (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 (NILP (loadsearch_re_list))
+-    {
+-      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));
+-    }
++  if (suffix_p (filename, ".gz"))
++    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
+ 
+-  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)))
+-	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, 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));
++  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 +4474,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 +4515,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);
+ }
+@@ -5859,10 +5821,7 @@ The last directory of this list is assum
+ the system *.eln files, which are the files produced when building
+ Emacs.  */);
+ 
+-  /* Temporary value in use for bootstrap.  We can't do better as
+-     `invocation-directory' is still unset, will be fixed up during
+-     dump reload.  */
+-  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
++  Vnative_comp_eln_load_path = Qnil;
+ 
+   DEFVAR_LISP ("native-comp-enable-subr-trampolines",
+ 	       Vnative_comp_enable_subr_trampolines,
+Index: emacs-29.2/lisp/startup.el
+===================================================================
+--- emacs-29.2.orig/lisp/startup.el
++++ emacs-29.2/lisp/startup.el
+@@ -545,9 +545,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.
+@@ -558,22 +555,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 normal-top-level ()
+   "Emacs calls this function when it first starts up.
+ It sets `command-line-processed', processes the command-line,
+@@ -1362,12 +1347,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
+@@ -1502,12 +1481,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-29.2/src/Makefile.in
+===================================================================
+--- emacs-29.2.orig/src/Makefile.in
++++ emacs-29.2/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.
+Index: emacs-29.2/Makefile.in
+===================================================================
+--- emacs-29.2.orig/Makefile.in
++++ emacs-29.2/Makefile.in
+@@ -329,6 +329,7 @@ TRANSFORM = @program_transform_name@
+ 
+ # Prevent any settings in the user environment causing problems.
+ unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
++export EMACSNATIVELOADPATH = @abs_top_builddir@/native-lisp
+ 
+ # What emacs should be called when installed.
+ EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 6/7] gnu: emacs-org: Fix native builds.
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 3/7] gnu: emacs: Don't hash file names in native compilation.
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v8 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 14484 bytes --]

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 292 ++++++++++++++++++
 3 files changed, 294 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 0292b1bd16..1caa2cbee0 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..8e7edfe5c3
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,292 @@
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -4396,26 +4396,17 @@ 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.  */)
+   (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 +4414,54 @@ 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);
++  Lisp_Object tail = Vload_path;
++  Lisp_Object name_len = Flength (filename);
+ 
+-  if (suffix_p (filename, ".gz"))
+-    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
++  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;
++	}
++    }
+ 
+-  /* We create eln filenames with an hash in order to look-up these
+-     starting from the source filename, IOW have a relation
++  if (Ffile_name_absolute_p (filename))
++    filename = rel_name;
+ 
+-     /absolute/path/filename.el + content ->
+-     eln-cache/filename-path_hash-content_hash.eln.
++  Lisp_Object bogus_dirs =
++    Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil);
+ 
+-     '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 (bogus_dirs))
++  {
++    tail = CALL2I (split-string, bogus_dirs, build_string (":"));
++
++    FOR_EACH_TAIL_SAFE (tail)
++      {
++	Lisp_Object directory = Ffile_name_as_directory (XCAR (tail));
++	Lisp_Object len = Flength (directory);
++	if (XFIXNUM (name_len) < XFIXNUM (len))
++	  continue;
++	else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					   directory, make_fixnum (0), len,
++					   Qnil)))
++	  {
++	    filename = Fsubstring (filename, len, Qnil);
++	    break;
++	  }
++      }
++  }
+ 
+-  if (NILP (loadsearch_re_list))
+-    {
+-      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));
+-    }
++  if (suffix_p (filename, ".gz"))
++    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
+ 
+-  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)))
+-	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, 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));
++  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 +4474,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 +4515,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);
+ }
+@@ -5859,10 +5821,7 @@ The last directory of this list is assum
+ the system *.eln files, which are the files produced when building
+ Emacs.  */);
+ 
+-  /* Temporary value in use for bootstrap.  We can't do better as
+-     `invocation-directory' is still unset, will be fixed up during
+-     dump reload.  */
+-  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
++  Vnative_comp_eln_load_path = Qnil;
+ 
+   DEFVAR_LISP ("native-comp-enable-subr-trampolines",
+ 	       Vnative_comp_enable_subr_trampolines,
+Index: emacs-29.2/lisp/startup.el
+===================================================================
+--- emacs-29.2.orig/lisp/startup.el
++++ emacs-29.2/lisp/startup.el
+@@ -545,9 +545,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.
+@@ -558,22 +555,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 normal-top-level ()
+   "Emacs calls this function when it first starts up.
+ It sets `command-line-processed', processes the command-line,
+@@ -1362,12 +1347,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
+@@ -1502,12 +1481,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-29.2/src/Makefile.in
+===================================================================
+--- emacs-29.2.orig/src/Makefile.in
++++ emacs-29.2/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.
+Index: emacs-29.2/Makefile.in
+===================================================================
+--- emacs-29.2.orig/Makefile.in
++++ emacs-29.2/Makefile.in
+@@ -329,6 +329,7 @@ TRANSFORM = @program_transform_name@
+ 
+ # Prevent any settings in the user environment causing problems.
+ unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
++export EMACSNATIVELOADPATH = @abs_top_builddir@/native-lisp
+ 
+ # What emacs should be called when installed.
+ EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 7/7] gnu: emacs-magit: Fix native builds.
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 6/7] gnu: emacs-org: " Liliana Marie Prikler
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 5/7] build-system: emacs: Compute relative file names.
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 6/7] gnu: emacs-org: " Liliana Marie Prikler
@ 2024-01-21 12:12   ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
  2024-01-21 14:09   ` [bug#67260] [PATCH v8 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 12:12 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 6/6] gnu: emacs: Disable jit compilation.
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v5 4/6] gnu: emacs-org: Fix native builds Liliana Marie Prikler
@ 2024-01-21 14:09   ` Liliana Marie Prikler
  4 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 14:09 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* 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 182de0204d..c83d6114ef 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..3320fda779
--- /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, with this switch enabled, Emacs will recompile libraries
++that were already natively compiled with Guix, so use it with
++caution.  */);
++  native_comp_jit_compilation = false;
+ 
+   DEFSYM (Qnative_comp_speed, "native-comp-speed");
+   DEFSYM (Qnative_comp_debug, "native-comp-debug");
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 7/7] gnu: emacs: Disable jit compilation.
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (4 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 6/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-01-21 14:09   ` Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 14:09 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

* 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation.
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (4 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-01-21 14:09   ` Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 14:09 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 4/7] gnu: emacs: Disable jit compilation.
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (4 preceding siblings ...)
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-01-21 14:09   ` Liliana Marie Prikler
  5 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-21 14:09 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 6/6] gnu: emacs: Disable jit compilation.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (5 preceding siblings ...)
  2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-01-22  4:16 ` Suhail via Guix-patches via
  2024-01-22  4:36 ` Suhail via Guix-patches via
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-22  4:16 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> * 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

I don't believe this patch is sufficient.  It seems that the variable
'native-comp-eln-load-path may also need to be tweaked.  The path to the
"native-lisp" directory needs to be specified absolutely to make it not
be dependent on the invocation-directory.  Details below.

#+begin_src bash :results replace
  emacs --batch --eval "(message \"%s\" (car (split-string (describe-function 'describe-function) \"\n\")))"
#+end_src

#+RESULTS:
: Type q in help window to delete it
: describe-function is an autoloaded interactive byte-compiled Lisp

#+begin_src bash :results replace
  type emacs
  ls ~/.guix-profile/lib/emacs/29.2/native-lisp/29.2-e9db68ab/help-fns.eln
  ls ~/.guix-profile/lib/emacs/29.2/native-lisp/29.2-e9db68ab/*.eln | wc -l
  ls ~/.guix-profile/lib/emacs/native-site-lisp/29.2-e9db68ab/*.eln | wc -l
  emacs --batch --eval "(message \"%s\" native-comp-eln-load-path)"
#+end_src

#+RESULTS:
: emacs is hashed (/home/user/.guix-profile/bin/emacs)
: /home/user/.guix-profile/lib/emacs/29.2/native-lisp/29.2-e9db68ab/help-fns.eln
: 1715
: 236
: (/home/user/.emacs.d/eln-cache/ /home/user/.guix-profile/lib/emacs/native-site-lisp ../native-lisp/)

#+begin_src bash :results replace
  emacs --batch --eval "(message \"%s\" (progn (add-to-list 'native-comp-eln-load-path \"/home/user/.guix-profile/lib/emacs/29.2/native-lisp\") (car (split-string (describe-function 'describe-function) \"\n\"))))"
#+end_src

#+RESULTS:
: Type q in help window to delete it
: describe-function is an autoloaded interactive native-compiled Lisp

-- 
Suhail

This email is not an offer capable of acceptance, does not evidence an
intention to enter into an agreement, has no operative effect until a
definitive agreement is signed in writing by both parties, and that no
party should act in reliance on the email or any representations of the
sender until a definitive agreement is signed in writing by both
parties.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v5 6/6] gnu: emacs: Disable jit compilation.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (6 preceding siblings ...)
  2024-01-22  4:16 ` Suhail via Guix-patches via
@ 2024-01-22  4:36 ` Suhail via Guix-patches via
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-22  4:36 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Liliana Marie Prikler, andrew

Suhail via Guix-patches via <guix-patches@gnu.org> writes:

> I don't believe this patch is sufficient.  It seems that the variable
> 'native-comp-eln-load-path may also need to be tweaked.  The path to the
> "native-lisp" directory needs to be specified absolutely to make it not
> be dependent on the invocation-directory.

Or it's possible that a patch that ensures that
'native-comp-eln-load-path contains the absolute value of the
"native-lisp" directory obviates this one (6/6) in its entirety.

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (7 preceding siblings ...)
  2024-01-22  4:36 ` Suhail via Guix-patches via
@ 2024-01-22 20:21 ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v6 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (5 more replies)
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                   ` (19 subsequent siblings)
  28 siblings, 6 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-22 20:21 UTC (permalink / raw)
  To: 67260; +Cc: andrew, cox.katherine.e+guix, liliana.prikler

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]

* gnu/packages/emacs.scm (emacs-minimal)[wrap-emacs-paths]: Also wrap
EMACSNATIVELOADPATH.
---
Am Montag, dem 22.01.2024 um 04:36 +0000 schrieb Suhail:
> Suhail via Guix-patches via <guix-patches@gnu.org> writes:
> 
> > I don't believe this patch is sufficient.  It seems that the
> > variable 'native-comp-eln-load-path may also need to be tweaked.
> > The path to the "native-lisp" directory needs to be specified
> > absolutely to make it not be dependent on the invocation-directory.
> 
> Or it's possible that a patch that ensures that
> 'native-comp-eln-load-path contains the absolute value of the
> "native-lisp" directory obviates this one (6/6) in its entirety.
This was the most cryptic hint towards the actual issue, but I've
managed to resolve it anyhow.  We still shouldn't enable jit compilation
however; I've updated our reason as to why.

 gnu/packages/emacs.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..2cdc9b8bca 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -273,7 +273,11 @@ (define-public emacs-minimal
               (let* ((out (assoc-ref outputs "out"))
                      (lisp-dirs (find-files (string-append out "/share/emacs")
                                             "^lisp$"
-                                            #:directories? #t)))
+                                            #:directories? #t))
+                     (native-lisp-dirs (find-files
+                                        (string-append out "/lib/emacs")
+                                        "^native-lisp$"
+                                        #:directories? #t)))
                 (for-each
                  (lambda (prog)
                    (wrap-program prog
@@ -285,7 +289,11 @@ (define-public emacs-minimal
                              (list (search-input-file inputs "/bin/gzip")
                                    ;; for coreutils
                                    (search-input-file inputs "/bin/yes"))))
-                     `("EMACSLOADPATH" suffix ,lisp-dirs)))
+                     `("EMACSLOADPATH" suffix ,lisp-dirs)
+                     ;; Note: the interpretation order of EMACSNATIVELOADPATH
+                     ;; is reversed, so 'prefix functions just like 'suffix
+                     ;; for EMACSLOADPATH.
+                     `("EMACSNATIVELOADPATH" prefix ,native-lisp-dirs)))
                  (find-files (string-append out "/bin")
                              ;; Matches versioned and unversioned emacs binaries.
                              ;; We don't patch emacsclient, because it takes its

base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (8 preceding siblings ...)
  2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-01-22 20:21 ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (5 more replies)
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                   ` (18 subsequent siblings)
  28 siblings, 6 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-22 20:21 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-minimal)[wrap-emacs-paths]: Also wrap
EMACSNATIVELOADPATH.
---
 gnu/packages/emacs.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..2cdc9b8bca 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -273,7 +273,11 @@ (define-public emacs-minimal
               (let* ((out (assoc-ref outputs "out"))
                      (lisp-dirs (find-files (string-append out "/share/emacs")
                                             "^lisp$"
-                                            #:directories? #t)))
+                                            #:directories? #t))
+                     (native-lisp-dirs (find-files
+                                        (string-append out "/lib/emacs")
+                                        "^native-lisp$"
+                                        #:directories? #t)))
                 (for-each
                  (lambda (prog)
                    (wrap-program prog
@@ -285,7 +289,11 @@ (define-public emacs-minimal
                              (list (search-input-file inputs "/bin/gzip")
                                    ;; for coreutils
                                    (search-input-file inputs "/bin/yes"))))
-                     `("EMACSLOADPATH" suffix ,lisp-dirs)))
+                     `("EMACSLOADPATH" suffix ,lisp-dirs)
+                     ;; Note: the interpretation order of EMACSNATIVELOADPATH
+                     ;; is reversed, so 'prefix functions just like 'suffix
+                     ;; for EMACSLOADPATH.
+                     `("EMACSNATIVELOADPATH" prefix ,native-lisp-dirs)))
                  (find-files (string-append out "/bin")
                              ;; Matches versioned and unversioned emacs binaries.
                              ;; We don't patch emacsclient, because it takes its

base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (9 preceding siblings ...)
  2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-01-22 20:21 ` Liliana Marie Prikler
  2024-01-21 12:12   ` [bug#67260] [PATCH v8 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (5 more replies)
  2024-01-25 23:53 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Suhail via Guix-patches via
                   ` (17 subsequent siblings)
  28 siblings, 6 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-01-22 20:21 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-minimal)[wrap-emacs-paths]: Also wrap
EMACSNATIVELOADPATH.
---
 gnu/packages/emacs.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..2cdc9b8bca 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -273,7 +273,11 @@ (define-public emacs-minimal
               (let* ((out (assoc-ref outputs "out"))
                      (lisp-dirs (find-files (string-append out "/share/emacs")
                                             "^lisp$"
-                                            #:directories? #t)))
+                                            #:directories? #t))
+                     (native-lisp-dirs (find-files
+                                        (string-append out "/lib/emacs")
+                                        "^native-lisp$"
+                                        #:directories? #t)))
                 (for-each
                  (lambda (prog)
                    (wrap-program prog
@@ -285,7 +289,11 @@ (define-public emacs-minimal
                              (list (search-input-file inputs "/bin/gzip")
                                    ;; for coreutils
                                    (search-input-file inputs "/bin/yes"))))
-                     `("EMACSLOADPATH" suffix ,lisp-dirs)))
+                     `("EMACSLOADPATH" suffix ,lisp-dirs)
+                     ;; Note: the interpretation order of EMACSNATIVELOADPATH
+                     ;; is reversed, so 'prefix functions just like 'suffix
+                     ;; for EMACSLOADPATH.
+                     `("EMACSNATIVELOADPATH" prefix ,native-lisp-dirs)))
                  (find-files (string-append out "/bin")
                              ;; Matches versioned and unversioned emacs binaries.
                              ;; We don't patch emacsclient, because it takes its

base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (10 preceding siblings ...)
  2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-01-25 23:53 ` Suhail via Guix-patches via
  2024-01-26  7:49 ` Suhail via Guix-patches via
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-25 23:53 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

>> Suhail via Guix-patches via <guix-patches@gnu.org> writes:
>> 
>> > I don't believe this patch is sufficient.  It seems that the
>> > variable 'native-comp-eln-load-path may also need to be tweaked.
>> > The path to the "native-lisp" directory needs to be specified
>> > absolutely to make it not be dependent on the invocation-directory.
>> 
> ... I've managed to resolve it

I can confirm that Emacs built by installing v6 patches on emacs-team
branch and built with --no-grafts is now able to locate
natively-compiled versions of features like help-fns etc. (which it
couldn't with v5 patches).

#+begin_src bash :results replace
  emacs --batch --eval "(message \"%s\" (car (split-string (describe-function 'describe-function) \"\n\")))"
#+end_src

#+RESULTS:
: Type q in help window to delete it
: describe-function is an autoloaded interactive native-compiled Lisp


However, there may be a spurious entry in native-comp-eln-load-path that
should probably be removed.

#+begin_src bash :results replace
  emacs --batch --eval "(message \"%s\" native-comp-eln-load-path)"
#+end_src

#+RESULTS:
: (/home/user/.emacs.d/eln-cache/ /home/user/.guix-profile/lib/emacs/native-site-lisp /gnu/store/4jvap9wxifizm56p6pmxc6rk0zyvm5zc-emacs-29.2/lib/emacs/29.2/native-lisp ../native-lisp/)


The "../native-lisp/" entry above, seems out of place.  Based on the
documentation of native-comp-eln-load-path:

> If the name of a directory in this list is not absolute, it is assumed
> to be relative to invocation-directory.

Contrasting the above with an Emacs 29.1 installation on a non-Guix
system, I notice that the latter doesn't have any non-absolute paths in
native-comp-eln-load-path.  Thoughts?

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (11 preceding siblings ...)
  2024-01-25 23:53 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Suhail via Guix-patches via
@ 2024-01-26  7:49 ` Suhail via Guix-patches via
  2024-01-26  8:20 ` Suhail via Guix-patches via
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-26  7:49 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

>> Contrasting the above with an Emacs 29.1 installation on a non-Guix
>> system, I notice that the latter doesn't have any non-absolute paths
>> in native-comp-eln-load-path.  Thoughts?
> I have noticed this myself, but I don't think that it's related to this
> series.

It seems to be.  It's possible that it may also be related to other
things already in the emacs-team branch (e.g. if the patch series is
only responsible for uncovering a pre-existing defect as opposed to
causing it), but the relative path only shows up during the series.

> Can you try 29.2 without the patches?

emacs-team branch at aae61f54ff doesn't have the relative path in
native-comp-eln-load-path.  The relative path shows up only after
[PATCH v6 3/7] is applied.  Hope this helps and hopefully the patch
series can soon be merged into master for general availability.


[PATCH v6 3/7] gnu: emacs: Don't hash file names in native compilation.

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (12 preceding siblings ...)
  2024-01-26  7:49 ` Suhail via Guix-patches via
@ 2024-01-26  8:20 ` Suhail via Guix-patches via
  2024-01-26 22:45 ` Suhail via Guix-patches via
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-26  8:20 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Suhail via Guix-patches via <guix-patches@gnu.org> writes:

> hopefully the patch series can soon be merged into master for general
> availability.

Btw, does every package require something like [PATCH v6 5/7] or
[PATCH v6 6/7] in order for it to be natively compiled?

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (13 preceding siblings ...)
  2024-01-26  8:20 ` Suhail via Guix-patches via
@ 2024-01-26 22:45 ` Suhail via Guix-patches via
  2024-01-27 15:36 ` Suhail via Guix-patches via
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-26 22:45 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

>> Btw, does every package require something like [PATCH v6 5/7] or
>> [PATCH v6 6/7] in order for it to be natively compiled?
> No, these patches are only for natively compiled packages that don't
> use emacs-build-system.

I.e., any and all packages using the emacs-build-system should be
natively-compiled?  If so, I believe I've found a counter-example.

After installing v6 series and building emacs-htmlize my expectation is
that functions provided by it, such as htmlize-buffer, would be
natively-compiled.  However, I get:

> htmlize-buffer is an autoloaded interactive Lisp function in
> `htmlize.el'.

Note the lack of "native-compiled" in the above.

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (14 preceding siblings ...)
  2024-01-26 22:45 ` Suhail via Guix-patches via
@ 2024-01-27 15:36 ` Suhail via Guix-patches via
  2024-01-27 16:24 ` Suhail via Guix-patches via
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-27 15:36 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> If you compile with emacs-minimal, that's the expected results. 

It was compiled with emacs-minimal=emacs.  For reference, I have inlined
the manifest file that was used (with the --no-grafts CLI option to
guix-package) towards the end of this email.  I'm sharing the one that
was actually used, but it could be minimized.

I believe there are two issues (not including the spurious entry in
native-comp-eln-load-path which may already have been resolved in v7 of
the series).  All my observations below are based on v6 patch series.

For emacs-htmlize, I believe the issue may stem from the fact that some
.eln files are available from entries in native-comp-eln-load-path only
via symlinks and the .eln loader may not be able to load symlinks.
Packages such as ox-html are available from two locations in the
native-comp-eln-load-path.  In one location they are symlinked, but
(presumably because org is a builtin package) it is also available from
another location in the native-comp-eln-load-path and in the latter
location it's not symlinked in.  I believe this difference is why for
some packages natively-compiled versions are loaded (e.g. org, ox-html
etc) whereas for others it's not the case.

In addition, I believe there's another issue.  Some packages' names are
getting  truncated.  For instance, instead of uniquify.eln, I observe
niquify.eln.  In this case, the .eln isn't symlinked (presumably because
it's a builtin), but due to the name being messed up (perhaps too
aggressive a truncation of hashes?) the natively compiled version is not
available:

> uniquify-item-p is a byte-compiled Lisp function in `uniquify.el'.

The manifest file that was used is below.

#+begin_src scheme
  (use-modules (guix transformations)
               (gnu packages))

  (define transform1
    (options->transformation
     '((with-input . "emacs-minimal=emacs")
       (without-tests . "emacs-clojure-mode"))))

  (packages->manifest
    (list (transform1 (specification->package "bash"))
          (transform1 (specification->package "coreutils"))
          (transform1 (specification->package "git"))
          (transform1 (specification->package "make"))
          (transform1 (specification->package "emacs"))
          (transform1 (specification->package "emacs-org"))
          (transform1
            (specification->package "emacs-org-contrib"))
          (transform1
            (specification->package "emacs-citeproc-el"))
          (transform1
            (specification->package "emacs-engrave-faces"))
          (transform1
            (specification->package "emacs-haskell-mode"))
          (transform1
            (specification->package "emacs-htmlize"))
          (transform1
            (specification->package "emacs-markdown-mode"))
          (transform1
            (specification->package
              "emacs-org-pandoc-import"))
          (transform1 (specification->package "pandoc"))
          ))
#+end_src

Thank you for your continued work on this!

-- 
Suhail

This email is not an offer capable of acceptance, does not evidence an
intention to enter into an agreement, has no operative effect until a
definitive agreement is signed in writing by both parties, and that no
party should act in reliance on the email or any representations of the
sender until a definitive agreement is signed in writing by both
parties.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (15 preceding siblings ...)
  2024-01-27 15:36 ` Suhail via Guix-patches via
@ 2024-01-27 16:24 ` Suhail via Guix-patches via
  2024-01-27 17:15 ` Suhail via Guix-patches via
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-27 16:24 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, liliana.prikler, suhail, andrew

Suhail via Guix-patches via <guix-patches@gnu.org> writes:

> I believe there are two issues (not including the spurious entry in
> native-comp-eln-load-path which may already have been resolved in v7 of
> the series).  All my observations below are based on v6 patch series.

I can confirm that the v7 series fixes the spurious entry in
native-comp-eln-load-path.

However, the 2 issues pointed out in the previous email remain:

1. failure to load natively-compiled version of non-builtin libraries
   like emacs-htmlize possibly due to symlinks, and

2. failure to load natively-compiled version of some builtin libraries
   like uniquify due to incorrect naming of .eln files

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (16 preceding siblings ...)
  2024-01-27 16:24 ` Suhail via Guix-patches via
@ 2024-01-27 17:15 ` Suhail via Guix-patches via
  2024-01-27 19:39 ` Suhail via Guix-patches via
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-27 17:15 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> Would you care to debug this a bit more and report your findings?

The locations in question are in the store and hence write-protected.
What's a "safe" way to debug this?

>> Packages such as ox-html are available from two locations in the
>> native-comp-eln-load-path.  In one location they are symlinked, but
>> (presumably because org is a builtin package) it is also available
>> from another location in the native-comp-eln-load-path and in the
>> latter location it's not symlinked in.  I believe this difference is
>> why for some packages natively-compiled versions are loaded (e.g.
>> org, ox-html, etc) whereas for others it's not the case.
> Well, as pointed out in the deleted code, dlopen has a "one shared
> library per file name" limitation.  I don't think we're hit by that
> thanks to unique hashes in the store directory, but I might be wrong
> about that.  Maybe we have to do java-style FQDNs instead.

Perhaps.  I'd wondered, more simply, if symlinked .eln files were ever
being loaded.  In the limited testing I did, I didn't find such an
instance.  For what it's worth, only one of the entries in
native-comp-eln-load-path seems to have symlinked entries (namely,
~/.guix-profile/lib/emacs/native-site-lisp).

>> In addition, I believe there's another issue.  Some packages' names
>> are getting  truncated.  For instance, instead of uniquify.eln, I
>> observe niquify.eln.  In this case, the .eln isn't symlinked
>> (presumably because it's a builtin), but due to the name being messed
>> up (perhaps too aggressive a truncation of hashes?) the natively
>> compiled version is not available:
> I am not truncating any hashes, I'm not even computing them in the
> first place.  The functions I'm modifying are publicly callable, namely
> comp-el-to-eln-rel-filename for the relative file names, and
> comp-el-to-eln-filename for the absolute ones.
>
> There could be an off-by-one error hidden in the stripping of the
> BOGUS_DIRS, however.  Let's investigate that.

Were you thinking out loud, or are there specific steps you'd like me to
help with?

> Note, that you can map transform1, saving some typing overhead, and
> since you are transforming all of your packages you could compose that
> with specification->package.

Appreciate the tips, but I should clarify that the manifest file in
question was generated by way of guix shell --export-manifest.  I'd
omitted the header.

-- 
Suhail

This email is not an offer capable of acceptance, does not evidence an
intention to enter into an agreement, has no operative effect until a
definitive agreement is signed in writing by both parties, and that no
party should act in reliance on the email or any representations of the
sender until a definitive agreement is signed in writing by both
parties.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (17 preceding siblings ...)
  2024-01-27 17:15 ` Suhail via Guix-patches via
@ 2024-01-27 19:39 ` Suhail via Guix-patches via
  2024-01-28  0:13 ` Suhail via Guix-patches via
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-27 19:39 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

Suhail via Guix-patches via <guix-patches@gnu.org> writes:

> However, the 2 issues pointed out in the previous email remain:

Correction, there's only 1 issue.  The first issue was a false positive.
Apologies for the noise.

> 1. failure to load natively-compiled version of non-builtin libraries
>    like emacs-htmlize possibly due to symlinks, and

This was a false positive.  Turns out, if the function in question is
only autoloaded describe-function won't correctly identify the function
as being natively-compiled.  This is consistent with what happens on
Emacs 29.1 on a non-Guix system.  Not an issue.

> 2. failure to load natively-compiled version of some builtin libraries
>    like uniquify due to incorrect naming of .eln files

This issue remains as of v7 of the patch series.

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (18 preceding siblings ...)
  2024-01-27 19:39 ` Suhail via Guix-patches via
@ 2024-01-28  0:13 ` Suhail via Guix-patches via
  2024-01-28  0:18 ` Suhail via Guix-patches via
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-28  0:13 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

>> > 2. failure to load natively-compiled version of some builtin
>> > libraries like uniquify due to incorrect naming of .eln files
>> 
>> This issue remains as of v7 of the patch series.
> I fixed this one locally,

I can confirm that the .eln filenames are no longer truncated (as far as
I can tell).

> but ‘uniquify’ remains byte-compiled for no explainable reason.

And too that as of v8 patch, uniquify still isn't natively-compiled.
However, if you unload it and then reload it, it becomes
natively-compiled.

#+begin_src bash
  emacs --batch --eval "(message \"%s\" (progn (unload-feature 'uniquify) (require 'uniquify) (take 1 (split-string (substring-no-properties (describe-function 'uniquify-item-p)) \"\\n\" t))))"
#+end_src

#+RESULTS:
: Type q in help window to delete it
: (uniquify-item-p is a native-compiled Lisp function in `uniquify.el'.)


I think the issue is because uniquify (along with some others such as
prog-mode, backquote etc that I tested) are preloaded in Emacs.  I
believe that these preloaded packages need to be treated specially.  In
a non-Guix system, these preloaded packages have their .eln files stored
under something like
<native-comp-eln-load-path-entry>/29.x-<hash>/preloaded/ , whereas in
the v8 series there is no "preloaded" directory.  Instead .eln files for
packages such as uniquify, prog-mode, backquote etc. are in various
locations:

- uniquify :: <n-c-e-l-p-entry>/29.2-<hash>/uniquify.eln
- prog-mode :: <n-c-e-l-p-entry>/29.2-<hash>/progmodes/prog-mode.eln
- backquote :: <n-c-e-l-p-entry>/29.2-<hash>/emacs-lisp/backquote.eln

I suspect that the code which does the preloading may need to be patched
and/or the preloaded packages may need to have their .eln files
generated under a preloaded sub-directory (similar to what happens in
non-Guix systems).

Below is a list of .eln files that exist in the preloaded sub-directory
in Emacs 29.1 on a non-Guix system.  It's possible that the set of
preloaded packages on Emacs 29.2 is different.  I suspect that all of
these packages are similarly affected.

#+begin_example
  abbrev.eln
  backquote.eln
  bindings.eln
  buff-menu.eln
  burmese.eln
  button.eln
  byte-run.eln
  case-table.eln
  cconv.eln
  cham.eln
  characters.eln
  chinese.eln
  cl-generic.eln
  cl-preloaded.eln
  common-win.eln
  composite.eln
  cp51932.eln
  cus-face.eln
  cus-start.eln
  custom.eln
  cyrillic.eln
  czech.eln
  debug-early.eln
  disp-table.eln
  dnd.eln
  dos-fns.eln
  dos-vars.eln
  dos-w32.eln
  dynamic-setting.eln
  easymenu.eln
  ediff-hook.eln
  eldoc.eln
  electric.eln
  elisp-mode.eln
  english.eln
  env.eln
  epa-hook.eln
  ethiopic.eln
  eucjp-ms.eln
  european.eln
  faces.eln
  files.eln
  fill.eln
  float-sup.eln
  font-core.eln
  font-lock.eln
  fontset.eln
  format.eln
  frame.eln
  fringe.eln
  georgian.eln
  greek.eln
  haiku-win.eln
  hebrew.eln
  help.eln
  image.eln
  indent.eln
  indian.eln
  indonesian.eln
  internal.eln
  isearch.eln
  iso-transl.eln
  japanese.eln
  jit-lock.eln
  jka-cmpr-hook.eln
  keymap.eln
  khmer.eln
  korean.eln
  lao.eln
  lisp.eln
  lisp-mode.eln
  ls-lisp.eln
  macroexp.eln
  map-ynp.eln
  menu-bar.eln
  minibuffer.eln
  misc-lang.eln
  mouse.eln
  mule.eln
  mule-cmds.eln
  mule-conf.eln
  mule-util.eln
  mwheel.eln
  nadvice.eln
  newcomment.eln
  ns-win.eln
  obarray.eln
  oclosure.eln
  page.eln
  paragraphs.eln
  paren.eln
  pc-win.eln
  pgtk-dnd.eln
  pgtk-win.eln
  philippine.eln
  prog-mode.eln
  regexp-opt.eln
  register.eln
  replace.eln
  rfn-eshadow.eln
  rmc.eln
  romanian.eln
  scroll-bar.eln
  select.eln
  seq.eln
  shorthands.eln
  simple.eln
  sinhala.eln
  slovak.eln
  startup.eln
  subr.eln
  syntax.eln
  tab-bar.eln
  tabulated-list.eln
  tai-viet.eln
  text-mode.eln
  thai.eln
  tibetan.eln
  timer.eln
  tool-bar.eln
  tooltip.eln
  tty-colors.eln
  ucs-normalize.eln
  uniquify.eln
  utf-8-lang.eln
  vc-hooks.eln
  version.eln
  vietnamese.eln
  w32-fns.eln
  w32-vars.eln
  w32-win.eln
  widget.eln
  window.eln
  x-dnd.eln
  x-win.eln
#+end_example


-- 
Suhail

This email is not an offer capable of acceptance, does not evidence an
intention to enter into an agreement, has no operative effect until a
definitive agreement is signed in writing by both parties, and that no
party should act in reliance on the email or any representations of the
sender until a definitive agreement is signed in writing by both
parties.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (19 preceding siblings ...)
  2024-01-28  0:13 ` Suhail via Guix-patches via
@ 2024-01-28  0:18 ` Suhail via Guix-patches via
  2024-01-28 16:17 ` Suhail via Guix-patches via
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-28  0:18 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

Suhail via Guix-patches via <guix-patches@gnu.org> writes:

> Below is a list of .eln files that exist in the preloaded
> sub-directory in Emacs 29.1 on a non-Guix system.

Minor correction.  The list of files I posted was /adapted/ from the
list of files in the preloaded sub-directory on a non-Guix system (with
Emacs 29.1).  Specifically, the list I shared had the hash suffix
removed to make comparison with the .eln file on Guix easier.

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (20 preceding siblings ...)
  2024-01-28  0:18 ` Suhail via Guix-patches via
@ 2024-01-28 16:17 ` Suhail via Guix-patches via
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-01-28 16:17 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, andrew

I'm assuming you're able to reproduce the issue on your end as well with
other features like prog-mode, backquote etc.

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> I instrumented lread.c to print the relative and absolute file names
> tried, and it appears that these aren't loaded at all after install
> while EMACSNATIVELOADPATH is ignored when dumping.

Interesting.  I did a grep of the Emacs source (branch emacs-29) and
line 1770 of src/lread.c (in maybe_swap_for_eln) seemed relevant:

>   /* Look also in preloaded subfolder of the last entry in
>      `comp-eln-load-path'.  */

What surprised me was that not only was the "preloaded" directory
special-cased, but so too was the last entry of "comp-eln-load-path"
(which I imagine is referring to native-comp-eln-load-path).  Judging by
your message, I'm guessing you're well aware of this.  I, unfortunately,
have no additional insights or suggestions.

However, given that ensuring Emacs is able to find the natively-compiled
version of files seems non-trivial, it might help for a future patch
series to be accompanied with tests.  Thoughts?

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
                     ` (4 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v9 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  6 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (21 preceding siblings ...)
  2024-01-28 16:17 ` Suhail via Guix-patches via
@ 2024-02-13 18:30 ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
                     ` (6 more replies)
  2024-02-14  0:56 ` [bug#67260] [PATCH emacs-team v9*] Think ahead when compiling Suhail via Guix-patches via
                   ` (5 subsequent siblings)
  28 siblings, 7 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-minimal)[wrap-emacs-paths]: Also wrap
EMACSNATIVELOADPATH.
---
 gnu/packages/emacs.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..2cdc9b8bca 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -273,7 +273,11 @@ (define-public emacs-minimal
               (let* ((out (assoc-ref outputs "out"))
                      (lisp-dirs (find-files (string-append out "/share/emacs")
                                             "^lisp$"
-                                            #:directories? #t)))
+                                            #:directories? #t))
+                     (native-lisp-dirs (find-files
+                                        (string-append out "/lib/emacs")
+                                        "^native-lisp$"
+                                        #:directories? #t)))
                 (for-each
                  (lambda (prog)
                    (wrap-program prog
@@ -285,7 +289,11 @@ (define-public emacs-minimal
                              (list (search-input-file inputs "/bin/gzip")
                                    ;; for coreutils
                                    (search-input-file inputs "/bin/yes"))))
-                     `("EMACSLOADPATH" suffix ,lisp-dirs)))
+                     `("EMACSLOADPATH" suffix ,lisp-dirs)
+                     ;; Note: the interpretation order of EMACSNATIVELOADPATH
+                     ;; is reversed, so 'prefix functions just like 'suffix
+                     ;; for EMACSLOADPATH.
+                     `("EMACSNATIVELOADPATH" prefix ,native-lisp-dirs)))
                  (find-files (string-append out "/bin")
                              ;; Matches versioned and unversioned emacs binaries.
                              ;; We don't patch emacsclient, because it takes its

base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v9 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  6 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2cdc9b8bca..0292b1bd16 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -384,7 +384,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (3 subsequent siblings)
  6 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 16362 bytes --]

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---

Am Sonntag, dem 28.01.2024 um 16:17 +0000 schrieb Suhail:
> What surprised me was that not only was the "preloaded" directory
> special-cased, but so too was the last entry of "comp-eln-load-path"
> (which I imagine is referring to native-comp-eln-load-path).  Judging
> by your message, I'm guessing you're well aware of this.  I,
> unfortunately, have no additional insights or suggestions.
Welp, I managed to find a workaround.  The emacs produced by this patch
has its own native-lisp directory twice (once per wrapping, once per
bootstrap), but it ought to load your natively-compiled whatever fine.

Cheers

 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 322 ++++++++++++++++++
 3 files changed, 324 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 0292b1bd16..1caa2cbee0 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..8e9f9a8fd6
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,322 @@
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -4396,26 +4396,17 @@ 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.  */)
+   (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 +4414,54 @@ 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);
++  Lisp_Object tail = Vload_path;
++  Lisp_Object name_len = Flength (filename);
+ 
+-  if (suffix_p (filename, ".gz"))
+-    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
++  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;
++	}
++    }
+ 
+-  /* We create eln filenames with an hash in order to look-up these
+-     starting from the source filename, IOW have a relation
++  if (Ffile_name_absolute_p (filename))
++    filename = rel_name;
+ 
+-     /absolute/path/filename.el + content ->
+-     eln-cache/filename-path_hash-content_hash.eln.
++  Lisp_Object bogus_dirs =
++    Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil);
+ 
+-     '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 (bogus_dirs))
++  {
++    tail = CALL2I (split-string, bogus_dirs, build_string (":"));
++
++    FOR_EACH_TAIL_SAFE (tail)
++      {
++	Lisp_Object directory = Ffile_name_as_directory (XCAR (tail));
++	Lisp_Object len = Flength (directory);
++	if (XFIXNUM (name_len) < XFIXNUM (len))
++	  continue;
++	else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					   directory, make_fixnum (0), len,
++					   Qnil)))
++	  {
++	    filename = Fsubstring (filename, len, Qnil);
++	    break;
++	  }
++      }
++  }
+ 
+-  if (NILP (loadsearch_re_list))
+-    {
+-      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));
+-    }
++  if (suffix_p (filename, ".gz"))
++    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
+ 
+-  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)))
+-	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, 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));
++  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);
+ }
+@@ -5863,10 +5826,7 @@ The last directory of this list is assum
+ the system *.eln files, which are the files produced when building
+ Emacs.  */);
+ 
+-  /* Temporary value in use for bootstrap.  We can't do better as
+-     `invocation-directory' is still unset, will be fixed up during
+-     dump reload.  */
+-  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
++  Vnative_comp_eln_load_path = Qnil;
+ 
+   DEFVAR_LISP ("native-comp-enable-subr-trampolines",
+ 	       Vnative_comp_enable_subr_trampolines,
+Index: emacs-29.2/lisp/startup.el
+===================================================================
+--- emacs-29.2.orig/lisp/startup.el
++++ emacs-29.2/lisp/startup.el
+@@ -545,9 +545,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.
+@@ -558,22 +555,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 normal-top-level ()
+   "Emacs calls this function when it first starts up.
+ It sets `command-line-processed', processes the command-line,
+@@ -1362,12 +1347,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
+@@ -1502,12 +1481,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-29.2/src/Makefile.in
+===================================================================
+--- emacs-29.2.orig/src/Makefile.in
++++ emacs-29.2/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 = emacs-lisp
+ lisp = $(addprefix ${lispsource}/,${shortlisp})
+ 
+ ## Construct full set of libraries to be linked.
+Index: emacs-29.2/Makefile.in
+===================================================================
+--- emacs-29.2.orig/Makefile.in
++++ emacs-29.2/Makefile.in
+@@ -329,6 +329,7 @@ TRANSFORM = @program_transform_name@
+ 
+ # Prevent any settings in the user environment causing problems.
+ unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
++export EMACSNATIVELOADPATH = @abs_top_builddir@/native-lisp
+ 
+ # What emacs should be called when installed.
+ EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
+Index: emacs-29.2/lisp/loadup.el
+===================================================================
+--- emacs-29.2.orig/lisp/loadup.el
++++ emacs-29.2/lisp/loadup.el
+@@ -53,6 +53,13 @@
+ (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)
++     (equal dump-mode "pdump")
++     (setq
++      native-comp-eln-load-path
++      (cons (expand-file-name "../native-lisp" invocation-directory)
++            native-comp-eln-load-path)))
+ 
+ ;; Add subdirectories to the load-path for files that might get
+ ;; autoloaded when bootstrapping or running Emacs normally.
+Index: emacs-29.2/lisp/Makefile.in
+===================================================================
+--- emacs-29.2.orig/lisp/Makefile.in
++++ emacs-29.2/lisp/Makefile.in
+@@ -110,6 +110,7 @@ MAIN_FIRST = ./emacs-lisp/eieio.el ./ema
+ 
+ # Prevent any settings in the user environment causing problems.
+ unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
++export NATIVE_COMP_BOGUS_DIRS = emacs-lisp:international:language:progmodes:term:textmodes:vc
+ 
+ # The actual Emacs command run in the targets below.
+ emacs = '$(EMACS)' $(EMACSOPT)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
                     ` (5 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-minimal)[wrap-emacs-paths]: Also wrap
EMACSNATIVELOADPATH.
---
 gnu/packages/emacs.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..2cdc9b8bca 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -273,7 +273,11 @@ (define-public emacs-minimal
               (let* ((out (assoc-ref outputs "out"))
                      (lisp-dirs (find-files (string-append out "/share/emacs")
                                             "^lisp$"
-                                            #:directories? #t)))
+                                            #:directories? #t))
+                     (native-lisp-dirs (find-files
+                                        (string-append out "/lib/emacs")
+                                        "^native-lisp$"
+                                        #:directories? #t)))
                 (for-each
                  (lambda (prog)
                    (wrap-program prog
@@ -285,7 +289,11 @@ (define-public emacs-minimal
                              (list (search-input-file inputs "/bin/gzip")
                                    ;; for coreutils
                                    (search-input-file inputs "/bin/yes"))))
-                     `("EMACSLOADPATH" suffix ,lisp-dirs)))
+                     `("EMACSLOADPATH" suffix ,lisp-dirs)
+                     ;; Note: the interpretation order of EMACSNATIVELOADPATH
+                     ;; is reversed, so 'prefix functions just like 'suffix
+                     ;; for EMACSLOADPATH.
+                     `("EMACSNATIVELOADPATH" prefix ,native-lisp-dirs)))
                  (find-files (string-append out "/bin")
                              ;; Matches versioned and unversioned emacs binaries.
                              ;; We don't patch emacsclient, because it takes its

base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 4/7] gnu: emacs: Disable jit compilation.
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
@ 2024-02-13 18:30     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 2/7] gnu: emacs: Build trampolines.
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-02-13 18:30     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2cdc9b8bca..0292b1bd16 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -384,7 +384,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 7/7] gnu: emacs-magit: Fix native builds.
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 5/7] build-system: emacs: Compute relative file names.
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-02-13 18:30     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 6/7] gnu: emacs-org: Fix native builds.
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH v9 3/7] gnu: emacs: Don't hash file names in native compilation.
  2024-02-13 18:30   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-02-13 18:30     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: cox.katherine.e+guix, Suhail, andrew

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 16362 bytes --]

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---

Am Sonntag, dem 28.01.2024 um 16:17 +0000 schrieb Suhail:
> What surprised me was that not only was the "preloaded" directory
> special-cased, but so too was the last entry of "comp-eln-load-path"
> (which I imagine is referring to native-comp-eln-load-path).  Judging
> by your message, I'm guessing you're well aware of this.  I,
> unfortunately, have no additional insights or suggestions.
Welp, I managed to find a workaround.  The emacs produced by this patch
has its own native-lisp directory twice (once per wrapping, once per
bootstrap), but it ought to load your natively-compiled whatever fine.

Cheers

 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 322 ++++++++++++++++++
 3 files changed, 324 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 0292b1bd16..1caa2cbee0 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..8e9f9a8fd6
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,322 @@
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -4396,26 +4396,17 @@ 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.  */)
+   (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 +4414,54 @@ 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);
++  Lisp_Object tail = Vload_path;
++  Lisp_Object name_len = Flength (filename);
+ 
+-  if (suffix_p (filename, ".gz"))
+-    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
++  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;
++	}
++    }
+ 
+-  /* We create eln filenames with an hash in order to look-up these
+-     starting from the source filename, IOW have a relation
++  if (Ffile_name_absolute_p (filename))
++    filename = rel_name;
+ 
+-     /absolute/path/filename.el + content ->
+-     eln-cache/filename-path_hash-content_hash.eln.
++  Lisp_Object bogus_dirs =
++    Fgetenv_internal (build_string ("NATIVE_COMP_BOGUS_DIRS"), Qnil);
+ 
+-     '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 (bogus_dirs))
++  {
++    tail = CALL2I (split-string, bogus_dirs, build_string (":"));
++
++    FOR_EACH_TAIL_SAFE (tail)
++      {
++	Lisp_Object directory = Ffile_name_as_directory (XCAR (tail));
++	Lisp_Object len = Flength (directory);
++	if (XFIXNUM (name_len) < XFIXNUM (len))
++	  continue;
++	else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					   directory, make_fixnum (0), len,
++					   Qnil)))
++	  {
++	    filename = Fsubstring (filename, len, Qnil);
++	    break;
++	  }
++      }
++  }
+ 
+-  if (NILP (loadsearch_re_list))
+-    {
+-      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));
+-    }
++  if (suffix_p (filename, ".gz"))
++    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
+ 
+-  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)))
+-	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, 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));
++  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);
+ }
+@@ -5863,10 +5826,7 @@ The last directory of this list is assum
+ the system *.eln files, which are the files produced when building
+ Emacs.  */);
+ 
+-  /* Temporary value in use for bootstrap.  We can't do better as
+-     `invocation-directory' is still unset, will be fixed up during
+-     dump reload.  */
+-  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
++  Vnative_comp_eln_load_path = Qnil;
+ 
+   DEFVAR_LISP ("native-comp-enable-subr-trampolines",
+ 	       Vnative_comp_enable_subr_trampolines,
+Index: emacs-29.2/lisp/startup.el
+===================================================================
+--- emacs-29.2.orig/lisp/startup.el
++++ emacs-29.2/lisp/startup.el
+@@ -545,9 +545,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.
+@@ -558,22 +555,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 normal-top-level ()
+   "Emacs calls this function when it first starts up.
+ It sets `command-line-processed', processes the command-line,
+@@ -1362,12 +1347,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
+@@ -1502,12 +1481,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-29.2/src/Makefile.in
+===================================================================
+--- emacs-29.2.orig/src/Makefile.in
++++ emacs-29.2/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 = emacs-lisp
+ lisp = $(addprefix ${lispsource}/,${shortlisp})
+ 
+ ## Construct full set of libraries to be linked.
+Index: emacs-29.2/Makefile.in
+===================================================================
+--- emacs-29.2.orig/Makefile.in
++++ emacs-29.2/Makefile.in
+@@ -329,6 +329,7 @@ TRANSFORM = @program_transform_name@
+ 
+ # Prevent any settings in the user environment causing problems.
+ unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
++export EMACSNATIVELOADPATH = @abs_top_builddir@/native-lisp
+ 
+ # What emacs should be called when installed.
+ EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
+Index: emacs-29.2/lisp/loadup.el
+===================================================================
+--- emacs-29.2.orig/lisp/loadup.el
++++ emacs-29.2/lisp/loadup.el
+@@ -53,6 +53,13 @@
+ (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)
++     (equal dump-mode "pdump")
++     (setq
++      native-comp-eln-load-path
++      (cons (expand-file-name "../native-lisp" invocation-directory)
++            native-comp-eln-load-path)))
+ 
+ ;; Add subdirectories to the load-path for files that might get
+ ;; autoloaded when bootstrapping or running Emacs normally.
+Index: emacs-29.2/lisp/Makefile.in
+===================================================================
+--- emacs-29.2.orig/lisp/Makefile.in
++++ emacs-29.2/lisp/Makefile.in
+@@ -110,6 +110,7 @@ MAIN_FIRST = ./emacs-lisp/eieio.el ./ema
+ 
+ # Prevent any settings in the user environment causing problems.
+ unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
++export NATIVE_COMP_BOGUS_DIRS = emacs-lisp:international:language:progmodes:term:textmodes:vc
+ 
+ # The actual Emacs command run in the targets below.
+ emacs = '$(EMACS)' $(EMACSOPT)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 4/7] gnu: emacs: Disable jit compilation.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 3/7] gnu: emacs: Don't hash file names in native compilation.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 16208 bytes --]

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 329 ++++++++++++++++++
 3 files changed, 331 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 0292b1bd16..1caa2cbee0 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..bb6ab312c3
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,329 @@
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -4396,26 +4396,17 @@ 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.  */)
+   (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 +4414,71 @@ 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);
++  Lisp_Object tail = Vload_path;
++  Lisp_Object name_len = Flength (filename);
+ 
+-  if (suffix_p (filename, ".gz"))
+-    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
++  FOR_EACH_TAIL_SAFE (tail)
++    {
++      Lisp_Object directory = Ffile_name_as_directory (XCAR (tail));
++      Lisp_Object len = Flength (directory);
++      if (XFIXNUM (name_len) < XFIXNUM (len))
++	continue;
++      else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					 directory, make_fixnum (0), len,
++					 Qnil)))
++        {
++	    filename = Fsubstring (filename, len, Qnil);
++	    break;
++	}
++    }
+ 
+-  /* We create eln filenames with an hash in order to look-up these
+-     starting from the source filename, IOW have a relation
++  if (Ffile_name_absolute_p (filename))
++    filename = rel_name;
+ 
+-     /absolute/path/filename.el + content ->
+-     eln-cache/filename-path_hash-content_hash.eln.
++  /* 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);
++  bool preloaded = comp_file_preloaded_p;
++  if (!preloaded && !NILP (lisp_preloaded))
++    preloaded =
++      !NILP (Fmember (CALL1I (file-name-sans-extension, filename),
++		      Fmapcar (intern_c_string ("file-name-sans-extension"),
++			       CALL1I (split-string, lisp_preloaded))));
++
++  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 directory = Ffile_name_as_directory (XCAR (tail));
++	Lisp_Object len = Flength (directory);
++	if (XFIXNUM (name_len) < XFIXNUM (len))
++	  continue;
++	else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					   directory, make_fixnum (0), len,
++					   Qnil)))
++	  {
++	    filename = Fsubstring (filename, len, Qnil);
++	    break;
++	  }
++      }
++  }
+ 
+-     '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 (suffix_p (filename, ".gz"))
++    filename = Fsubstring (filename, Qnil, make_fixnum (-3));
+ 
+-  if (NILP (loadsearch_re_list))
+-    {
+-      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));
+-    }
++  if (preloaded)
++    filename = concat2 (build_string ("preloaded/"),
++			Ffile_name_nondirectory (filename));
+ 
+-  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)))
+-	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, 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));
++  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 +4492,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 +4533,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);
+ }
+@@ -5863,10 +5843,7 @@ The last directory of this list is assum
+ the system *.eln files, which are the files produced when building
+ Emacs.  */);
+ 
+-  /* Temporary value in use for bootstrap.  We can't do better as
+-     `invocation-directory' is still unset, will be fixed up during
+-     dump reload.  */
+-  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
++  Vnative_comp_eln_load_path = Qnil;
+ 
+   DEFVAR_LISP ("native-comp-enable-subr-trampolines",
+ 	       Vnative_comp_enable_subr_trampolines,
+Index: emacs-29.2/lisp/startup.el
+===================================================================
+--- emacs-29.2.orig/lisp/startup.el
++++ emacs-29.2/lisp/startup.el
+@@ -545,9 +545,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.
+@@ -558,22 +555,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 normal-top-level ()
+   "Emacs calls this function when it first starts up.
+ It sets `command-line-processed', processes the command-line,
+@@ -1362,12 +1347,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
+@@ -1502,12 +1481,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-29.2/lisp/loadup.el
+===================================================================
+--- emacs-29.2.orig/lisp/loadup.el
++++ emacs-29.2/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.
+@@ -557,7 +565,9 @@ lost after dumping")))
+                  (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)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 2/7] gnu: emacs: Build trampolines.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
                     ` (4 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 2cdc9b8bca..0292b1bd16 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -384,7 +384,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 5/7] build-system: emacs: Compute relative file names.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 7/7] gnu: emacs-magit: Fix native builds.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 6/7] gnu: emacs-org: Fix native builds.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
                     ` (5 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH.
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs.scm (emacs-minimal)[wrap-emacs-paths]: Also wrap
EMACSNATIVELOADPATH.
---
 gnu/packages/emacs.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..2cdc9b8bca 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -273,7 +273,11 @@ (define-public emacs-minimal
               (let* ((out (assoc-ref outputs "out"))
                      (lisp-dirs (find-files (string-append out "/share/emacs")
                                             "^lisp$"
-                                            #:directories? #t)))
+                                            #:directories? #t))
+                     (native-lisp-dirs (find-files
+                                        (string-append out "/lib/emacs")
+                                        "^native-lisp$"
+                                        #:directories? #t)))
                 (for-each
                  (lambda (prog)
                    (wrap-program prog
@@ -285,7 +289,11 @@ (define-public emacs-minimal
                              (list (search-input-file inputs "/bin/gzip")
                                    ;; for coreutils
                                    (search-input-file inputs "/bin/yes"))))
-                     `("EMACSLOADPATH" suffix ,lisp-dirs)))
+                     `("EMACSLOADPATH" suffix ,lisp-dirs)
+                     ;; Note: the interpretation order of EMACSNATIVELOADPATH
+                     ;; is reversed, so 'prefix functions just like 'suffix
+                     ;; for EMACSLOADPATH.
+                     `("EMACSNATIVELOADPATH" prefix ,native-lisp-dirs)))
                  (find-files (string-append out "/bin")
                              ;; Matches versioned and unversioned emacs binaries.
                              ;; We don't patch emacsclient, because it takes its
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 7/7] gnu: emacs-magit: Fix native builds.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-magit)[#:phases]: Also wrap ‘build’ in
a directory excursion.

Change-Id: I332325989a1bbaa95552c2cbf50f336f0075c1c4
---
 gnu/packages/emacs-xyz.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index e2aebe971e..a0ac8f5a57 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1590,7 +1590,11 @@ (define-public emacs-magit
             (replace 'install
               (lambda args
                 (with-directory-excursion "lisp"
-                  (apply (assoc-ref %standard-phases 'install) args)))))))
+                  (apply (assoc-ref %standard-phases 'install) args))))
+            (replace 'build
+              (lambda args
+                (with-directory-excursion "lisp"
+                  (apply (assoc-ref %standard-phases 'build) args)))))))
       (native-inputs
        (list texinfo))
       (inputs
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 2/7] gnu: emacs: Don't hash file names in native compilation.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
                     ` (4 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-24  6:18   ` [bug#67260] [PATCH emacs-team v11 3/7] gnu: emacs: Check integrity of native-compiled files Liliana Marie Prikler
  2024-03-04  7:13   ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Andrew Tropin via Guix-patches via
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 16992 bytes --]

* gnu/packages/patches/emacs-native-comp-fix-filenames.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-minimal)[source]: Use it here.

Change-Id: I2b7f6b45742a985760f0097bb53910f068e3d8e5
---
 gnu/local.mk                                  |   1 +
 gnu/packages/emacs.scm                        |   1 +
 .../emacs-native-comp-fix-filenames.patch     | 338 ++++++++++++++++++
 3 files changed, 340 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 3d1afd4555..7e6a0c5006 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1121,6 +1121,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %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-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 e4119ec21d..182de0204d 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -111,6 +111,7 @@ (define-public emacs-minimal
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-native-comp-driver-options.patch"
+                                       "emacs-native-comp-fix-filenames.patch"
                                        "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
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..169323f290
--- /dev/null
+++ b/gnu/packages/patches/emacs-native-comp-fix-filenames.patch
@@ -0,0 +1,338 @@
+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.
+
+In addition, this patch changes how native-comp-eln-load-path is
+constructed.  Upstream, an entry of the directory “../lisp” is added
+supposedly for bootstrap only, but this directory appears to find its
+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.
+
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -4396,26 +4396,17 @@ 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.  */)
+   (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 +4414,55 @@ 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.
+-
+-     '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))
+-    {
+-      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 tail = Vload_path;
++  Lisp_Object name_len = Flength (filename);
+ 
+-  Lisp_Object lds_re_tail = loadsearch_re_list;
+-  FOR_EACH_TAIL (lds_re_tail)
++  FOR_EACH_TAIL_SAFE (tail)
+     {
+-      Lisp_Object match_idx =
+-	Fstring_match (XCAR (lds_re_tail), filename, Qnil, Qnil);
+-      if (BASE_EQ (match_idx, make_fixnum (0)))
++      Lisp_Object directory = Ffile_name_as_directory (XCAR (tail));
++      Lisp_Object len = Flength (directory);
++      if (XFIXNUM (name_len) < XFIXNUM (len))
++	continue;
++      else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					 directory, make_fixnum (0), len,
++					 Qnil)))
+ 	{
+-	  filename =
+-	    Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil);
++	  filename = Fsubstring (filename, 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 (file_name_absolute_p (filename)) /* no match in load-path */
++    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 directory = Ffile_name_as_directory (XCAR (tail));
++	Lisp_Object len = Flength (directory);
++	if (XFIXNUM (name_len) < XFIXNUM (len))
++	  continue;
++	else if (EQ (Qt, Fcompare_strings (filename, make_fixnum (0), len,
++					   directory, make_fixnum (0), len,
++					   Qnil)))
++	  {
++	    filename = Fsubstring (filename, 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 +4476,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;
+@@ -4548,10 +4524,11 @@ the latter is supposed to be used by the
+   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),
+-			     Fmapcar (intern_c_string ("file-name-base"),
++	  && !NILP (Fmember (CALL1I (file-name-sans-extension, source_filename),
++			     Fmapcar (intern_c_string ("file-name-sans-extension"),
+ 				      CALL1I (split-string, lisp_preloaded))))))
+     base_dir = Fexpand_file_name (build_string ("preloaded"), base_dir);
+ 
+@@ -5863,10 +5840,7 @@ The last directory of this list is assum
+ the system *.eln files, which are the files produced when building
+ Emacs.  */);
+ 
+-  /* Temporary value in use for bootstrap.  We can't do better as
+-     `invocation-directory' is still unset, will be fixed up during
+-     dump reload.  */
+-  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
++  Vnative_comp_eln_load_path = Qnil;
+ 
+   DEFVAR_LISP ("native-comp-enable-subr-trampolines",
+ 	       Vnative_comp_enable_subr_trampolines,
+Index: emacs-29.2/lisp/startup.el
+===================================================================
+--- emacs-29.2.orig/lisp/startup.el
++++ emacs-29.2/lisp/startup.el
+@@ -545,9 +545,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.
+@@ -558,22 +555,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 normal-top-level ()
+   "Emacs calls this function when it first starts up.
+ It sets `command-line-processed', processes the command-line,
+@@ -1362,12 +1347,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
+@@ -1502,12 +1481,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-29.2/lisp/loadup.el
+===================================================================
+--- emacs-29.2.orig/lisp/loadup.el
++++ emacs-29.2/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.
+@@ -494,22 +502,20 @@ lost after dumping")))
+             (concat eln-dest-dir "native-lisp/" comp-native-version-dir "/"))
+       (maphash (lambda (_ 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)
+-                                         bin-dest-dir)
++                     (file-relative-name
++                      (expand-file-name
++                       (save-match-data
++                         (string-match native-lisp-needle file)
++                         (substring file (match-end 0)))
++                       eln-dest-dir)
++                      bin-dest-dir)
+                      ;; Relative filename from the built uninstalled binary.
+                      (file-relative-name file invocation-directory)))))
+ 	       comp-loaded-comp-units-h)))
+@@ -557,7 +563,9 @@ lost after dumping")))
+                  (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-29.2/src/Makefile.in
+===================================================================
+--- emacs-29.2.orig/src/Makefile.in
++++ emacs-29.2/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.
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 6/7] gnu: emacs-org: Fix native builds.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
                     ` (2 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 1/7] gnu: emacs: Build trampolines Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs-xyz.scm (emacs-org)[#:phases]: Wrap ‘build’ in a
directory excursion to the actual lisp directory.

Change-Id: Ifa10f9e91fe21cd4c34da11b68ddb77a03d847ca
---
 gnu/packages/emacs-xyz.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index fc3c9e00be..e2aebe971e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -16752,6 +16752,10 @@ (define-public emacs-org
               (substitute* "testing/lisp/test-org.el"
                 (("test-org/org-(encode-time|time-string-to-time) .*" all)
                  (string-append all "  (skip-unless nil)\n")))))
+          (replace 'build
+            (lambda args
+              (with-directory-excursion "lisp"
+                (apply (assoc-ref %standard-phases 'build) args))))
           (replace 'install
             (lambda _
               (let ((elpa (elpa-directory #$output))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 1/7] gnu: emacs: Build trampolines.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘build-trampolines’.

Change-Id: I33303bcbaf6cbda15867a5546e793c05d1f0e67b
---
 gnu/packages/emacs.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 5f27c551e0..e4119ec21d 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -376,7 +376,10 @@ (define-public emacs-no-x
                     (string-append
                      "-B" #$(this-package-input "libgccjit") "/lib/")
                     (string-append
-                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
+            (add-after 'build 'build-trampolines
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "trampolines" make-flags)))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 4/7] gnu: emacs: Disable jit compilation.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
                     ` (3 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 2/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

* 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 f0200ad27c..e6f2b699ac 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





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 5/7] build-system: emacs: Compute relative file names.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
@ 2024-02-13 18:30   ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 1/7] gnu: emacs: Build trampolines Liliana Marie Prikler
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-13 18:30 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

With the previous commit, relative file names are expanded relative to
ELN_DIR -- more or less.  To make use of this in emacs-build-system, we must
also pass relative file names.

* guix/build/emacs-build-system.scm (emacs-compile-directory): Compute the
relative file names of the files to compile.

Change-Id: I8983f80fb0fe1573e46748222403ba8873f1599f
---
 guix/build/emacs-utils.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8e12b5b6d4..eca42bf305 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -146,7 +146,9 @@ (define* (emacs-compile-directory dir)
                               (cadr native-comp-eln-load-path))))
             (if byte+native-compile
                 (native-compile file
-                                (comp-el-to-eln-filename file eln-dir))
+                                (comp-el-to-eln-filename
+                                 (file-relative-name file ,dir)
+                                 eln-dir))
                 (byte-compile-file file))
             ;; After native compilation, write the bytecode file.
             (unless (null byte-to-native-output-buffer-file)
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v9*] Think ahead when compiling
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (22 preceding siblings ...)
  2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
@ 2024-02-14  0:56 ` Suhail via Guix-patches via
  2024-02-14  8:41 ` [bug#67260] [PATCH emacs-team v9*] Test for AOT native-comp Suhail via Guix-patches via
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-02-14  0:56 UTC (permalink / raw)
  To: bug#67260

The latest patch series (titled v7, but really v9) shows some
improvement, however, there are still some issues.

Specifically, functions from preloaded library uniquify are now
correctly noted as being natively-compiled.  The functions that were
confirmed were uniquify-item-base and uniquify-item-p.

However, functions from certain other preloaded libraries are still
noted as being byte-compiled instead.  At the very least this set
includes backquote and eldoc.

#+begin_src sh
  emacs --batch --eval (message "%s" (take 1 (split-string (substring-no-properties (describe-function 'backquote-process)) "\n" t)))
#+end_src

#+RESULTS:
: Type q in help window to delete it
: (backquote-process is a byte-compiled Lisp function in `backquote.el'.)

#+begin_src sh
  emacs --batch --eval (message "%s" (take 1 (split-string (substring-no-properties (describe-function 'eldoc-mode)) "\n" t)))
#+end_src

#+RESULTS:
: Type q in help window to delete it
: (eldoc-mode is an interactive byte-compiled Lisp function in)


-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v9*] Test for AOT native-comp
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (23 preceding siblings ...)
  2024-02-14  0:56 ` [bug#67260] [PATCH emacs-team v9*] Think ahead when compiling Suhail via Guix-patches via
@ 2024-02-14  8:41 ` Suhail via Guix-patches via
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-02-14  8:41 UTC (permalink / raw)
  To: bug#67260

So I wrote some code to make it easier to report on the state of
native-comp for some of the packages previously mentioned (the *.eln
files for these packages reside under the "preloaded" directory in a
non-Guix distribution).  I'm including below both the contents of the
script as well as the results.

First the results.  Assuming that the file
test-native-comp-p--preloaded.el exists, evaluating the below:

#+begin_src sh :results replace
  emacs -Q --batch \
        -l path/to/test-native-comp-p--preloaded.el \
        --eval "(princ (report/compilation-status/run))"
#+end_src

With a non-Guix Emacs results in:

#+RESULTS:
: [97/97] passed. Success!

Whereas with the latest patch-series it results in 41 failing cases:

#+RESULTS:
#+begin_example
[56/97] passed.  41 failing cases below:

((backquote-process . byte-compiled)
 (byte-run-strip-symbol-positions . byte-compiled)
 (cconv-convert . byte-compiled)
 (use-default-char-width-table . byte-compiled)
 (cl-generic-p . byte-compiled)
 (cl-struct-define . byte-compiled)
 (x-setup-function-keys . byte-compiled)
 (debug-early . byte-compiled)
 (easy-menu-item-present-p . byte-compiled)
 (eldoc-mode . byte-compiled)
 (elisp-mode-syntax-propertize . byte-compiled)
 (fill-region . byte-compiled)
 (fontset-plain-name . byte-compiled)
 (indian-compose-regexp . byte-compiled)
 (msdos-setup-keyboard . byte-compiled)
 (iso-transl-set-language . byte-compiled)
 (forward-sexp . byte-compiled)
 (lisp-string-in-doc-position-p . byte-compiled)
 (macroexp-compiling-p . byte-compiled)
 (map-y-or-n-p . byte-compiled)
 (egyptian-shape-grouping . byte-compiled)
 (convert-define-charset-argument . byte-compiled)
 (coding-system-change-eol-conversion . byte-compiled)
 (store-substring . byte-compiled)
 (advice-function-mapc . byte-compiled)
 (oclosure-type . byte-compiled)
 (forward-page . byte-compiled)
 (sentence-end . byte-compiled)
 (prog-context-menu . byte-compiled)
 (regexp-opt . byte-compiled)
 (read-multiple-choice . byte-compiled)
 (seq-first . byte-compiled)
 (hack-read-symbol-shorthands . byte-compiled)
 (syntax-propertize-multiline . byte-compiled)
 (tabulated-list-put-tag . byte-compiled)
 (text-mode . byte-compiled)
 (timer-activate . byte-compiled)
 (tty-color-desc . byte-compiled)
 (ucs-normalize-hfs-nfd-comp-p . byte-compiled)
 (vc-mode . byte-compiled)
 (x-handle-no-bitmap-icon . byte-compiled))
#+end_example

The content of test-native-comp-p--preloaded.el are as follows:

#+begin_src elisp :eval never
  (require 'help-fns)
  (defun report/compilation-status (fun &optional feature)
    "Report on the compilation status of function FUN.
  Optionally load FEATURE before reporting on compilation status."
    (when feature
      (require feature))
    (let ((descstr (substring-no-properties
                    (with-output-to-string
                      (help-fns-function-description-header fun)))))
      (cons fun
            (cond
             ((string-search " native-compiled" descstr) 'native-compiled)
             ((string-search " byte-compiled" descstr) 'byte-compiled)
             (t descstr)))))

  ;; [[/usr/share/emacs/29.2/lisp]]
  (defvar report/compilation-status/cases/preloaded nil
    "Functions that ought to be natively-compiled.")
  (setq report/compilation-status/cases/preloaded
        '((abbrev-mode)
          (backquote-process)
          (mode-line-widen)
          (buffer-menu)
          ;; burmese
          (button-mode)
          (byte-run-strip-symbol-positions)
          (case-table-get-table)
          (cconv-convert)
          ;; cham
          (use-default-char-width-table)
          ;; chinese
          (cl-generic-p)
          (cl-struct-define)
          (x-setup-function-keys)
          (encode-composition-rule)
          ;; cp51932
          (custom-declare-face)
          (minibuffer-prompt-properties--setter) ;; cus-start.el
          (custom-add-choice)
          ;; cyrillic
          ;; czech
          (debug-early)
          (display-table-slot disp-table) ;; disp-table.eln exists
          (dnd-open-file)
          (dos-mode25 dos-fns) ;; dos-fns.eln exists
          ;; dos-vars
          (find-file-text dos-w32) ;; dos-w32.eln exists
          (dynamic-setting-handle-config-changed-event)
          (easy-menu-item-present-p)
          ;; ediff-hook
          (eldoc-mode)
          (electric-indent-mode)
          (elisp-mode-syntax-propertize)
          ;; english
          (getenv)
          (epa-file-find-file-hook)
          ;; ethiopic
          ;; eucjp-ms
          ;; european
          (face-list)
          (find-file-noselect)
          (fill-region)
          ;; float-sup
          (font-lock-change-mode)
          (font-lock-add-keywords)
          (fontset-plain-name)
          (format-read)
          (frame-edges)
          (fringe-mode)
          ;; georgian
          ;; greek
          ;; haiku-win
          ;; hebrew
          (help-quick)
          (image-type)
          (indent-region)
          (indian-compose-regexp)
          ;; indonesian
          (msdos-setup-keyboard term/internal) ;; internal.eln exists
          (isearch-abort)
          (iso-transl-set-language)
          ;; japanese
          (jit-lock-mode)
          (jka-compr-build-file-regexp)
          (keymap-global-set)
          ;; khmer
          ;; korean
          ;; lao
          (forward-sexp)
          (lisp-string-in-doc-position-p)
          (ls-lisp-set-options ls-lisp) ;; ls-lisp.eln exists
          (macroexp-compiling-p)
          (map-y-or-n-p)
          (menu-find-file-existing)
          (completion-boundaries)
          (egyptian-shape-grouping)
          (mouse-double-click-time)
          (convert-define-charset-argument)
          (coding-system-change-eol-conversion)
          ;; mule-conf.eln
          (store-substring mule-util) ;; mule-util.eln exists
          (mouse-wheel-change-button)
          (advice-function-mapc)
          (comment-string-strip)
          ;; (ns-handle-nxopen term/ns-win)
          (obarray-make)
          (oclosure-type)
          (forward-page)
          (sentence-end)
          (show-paren-function)
          ;; (msdos-face-setup term/pc-win)
          (pgtk-dnd-init-frame pgtk-dnd) ;; pgtk-dnd.eln exists
          ;; (pgtk-drag-n-drop term/pgtk-win)
          ;; philippine
          (prog-context-menu)
          (regexp-opt)
          (get-register)
          (query-replace-descr)
          (rfn-eshadow-setup-minibuffer)
          (read-multiple-choice)
          ;; romanian
          (scroll-bar-scale)
          (gui-select-text)
          (seq-first)
          (hack-read-symbol-shorthands)
          (next-error-find-buffer)
          ;; sinhala
          ;; slovak
          (exit-splash-screen)
          (buffer-local-boundp)
          (syntax-propertize-multiline)
          (tab-bar-mode)
          (tabulated-list-put-tag)
          ;; tai-viet
          (text-mode)
          ;; thai
          ;; tibetan
          (timer-activate)
          (tool-bar-mode)
          (tooltip-mode)
          (tty-color-desc)
          (ucs-normalize-hfs-nfd-comp-p ucs-normalize) ;; ucs-normalize.eln exists
          (uniquify-item-p)
          ;; utf-8-lang.eln
          (vc-mode)
          (emacs-version)
          ;; vietnamese
          ;; (w32-shell-name)
          ;; w32-vars.eln
          ;; (w32-handle-dropped-file 'term/w32-win)
          (define-widget)
          (window-right)
          (x-dnd-init-frame)
          (x-handle-no-bitmap-icon)))

  (defun report/compilation-status/run ()
    "Run all cases and report those that aren't native-compiled."
    (let* ((results (mapcar (lambda (args) (apply #'report/compilation-status args))
                            report/compilation-status/cases/preloaded))
           (failing (seq-filter (lambda (x) (not (eq (cdr x) 'native-compiled)))
                                results))
           (numtotal (seq-length results))
           (numfailing (seq-length failing))
           (numpassing (- numtotal numfailing)))
      (concat (format "[%s/%s] passed."
                      numpassing numtotal)
              (if failing
                  (concat (format "  %s failing cases below:\n\n" numfailing)
                          (pp-to-string failing))
                " Success!"))))
#+end_src

Hope this helps!

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (24 preceding siblings ...)
  2024-02-14  8:41 ` [bug#67260] [PATCH emacs-team v9*] Test for AOT native-comp Suhail via Guix-patches via
@ 2024-02-16 15:09 ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
                     ` (6 more replies)
  2024-02-17 14:49 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Suhail via Guix-patches via
                   ` (2 subsequent siblings)
  28 siblings, 7 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-16 15:09 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

Am Mittwoch, dem 14.02.2024 um 08:41 +0000 schrieb Suhail:
> So I wrote some code to make it easier to report on the state of
> native-comp for some of the packages previously mentioned (the *.eln
> files for these packages reside under the "preloaded" directory in a
> non-Guix distribution).  I'm including below both the contents of the
> script as well as the results.
> [...]
> With a non-Guix Emacs results in:
> 
> #+RESULTS:
> : [97/97] passed. Success!
> 
> Whereas with the latest patch-series it results in 41 failing cases:
> 
> #+RESULTS:
> #+begin_example
> [56/97] passed.  41 failing cases below:

With this series I get 94/97.  The remaining three don't appear to be
preloaded through the loadup script, so I have no idea how to catch them
or whether it's even worth doing so.

Liliana Marie Prikler (7):
  gnu: emacs: Wrap EMACSNATIVELOADPATH.
  gnu: emacs: Build trampolines.
  gnu: emacs: Don't hash file names in native compilation.
  gnu: emacs: Disable jit compilation.
  build-system: emacs: Compute relative file names.
  gnu: emacs-org: Fix native builds.
  gnu: emacs-magit: Fix native builds.

 gnu/local.mk                                  |   2 +
 gnu/packages/emacs-xyz.scm                    |  10 +-
 gnu/packages/emacs.scm                        |  21 +-
 .../emacs-disable-jit-compilation.patch       |  19 +
 .../emacs-native-comp-fix-filenames.patch     | 329 ++++++++++++++++++
 guix/build/emacs-utils.scm                    |   4 +-
 6 files changed, 379 insertions(+), 6 deletions(-)
 create mode 100644 gnu/packages/patches/emacs-disable-jit-compilation.patch
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch


base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (25 preceding siblings ...)
  2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
@ 2024-02-17 14:49 ` Suhail via Guix-patches via
  2024-02-17 15:15   ` Liliana Marie Prikler
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
  2024-03-01 17:35 ` Suhail via Guix-patches via
  28 siblings, 1 reply; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-02-17 14:49 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> With this series I get 94/97.

I was able to confirm that as well.

> The remaining three

Namely, the 'ucs-normalize, 'mule-util, and 'term/internal features.
For each of these the .eln files exist, but the version that gets loaded
in Guix is the byte-compiled one, unless some extra steps are taken.

> ... don't appear to be preloaded through the loadup script, so I have
> no idea how to catch them or whether it's even worth doing so.

I dug into this a little deeper.  It seems that by adjusting the
load-path one is able to load the natively-compiled variants instead of
the byte-compiled for these features.  Oddly, this adjustment doesn't
seem to be needed in non-Guix Emacs which may suggest the presence of a
bug.  I'm hoping you have some insight that explains this difference in
behaviour.

After modifying the previous test-native-comp-p--preloaded.el (in
hindsight, the preloaded part may be a misnomer) with the below patch I
got all the 97 cases passing.

#+begin_src diff
  diff -u ./test-native-comp-p--preloaded.el ./test-native-comp-p--preloaded.el
  --- ./test-native-comp-p--preloaded.el	2024-02-17 08:49:36.294930488 -0500
  +++ ./test-native-comp-p--preloaded.el	2024-02-17 08:38:45.102839041 -0500
  @@ -155,8 +155,50 @@
           (x-dnd-init-frame)
           (x-handle-no-bitmap-icon)))
 
  +(defun hack/tweak-load-path-in-guix ()
  +  "Tweak `load-path' to allow natively compiled versions to be loaded.
  +
  +If we ensure that the `load-path' entries for `term/internal',
  +`mule-util' and `ucs-normalize' exist and they occur before the
  +share/emacs/<emacs-version>/lisp entry then we are able to load
  +the natively compiled versions of these libraries.  Of those
  +three, the entry for `term/internal' is missing whereas the
  +others currently occur after the share/emacs/<emacs-version>/lisp
  +entry.  We remedy that here.
  +
  +Notably, in non-Guix Emacs this isn't needed.  I.e., the fact
  +that the share/emacs/<emacs-version>/lisp entry precedes the
  +entries for `mule-util' and `ucs-normalize' is okay as is the
  +fact that the entry for `term/internal' is missing."
  +  (when (getenv "GUIX_ENVIRONMENT")
  +    (require 'find-func)
  +    ;; first we'll add the missing entry for `term/internal'
  +    (add-to-list 'load-path
  +                 (directory-file-name
  +                  (file-name-directory
  +                   (find-library-name (symbol-name 'term/internal))))
  +                 ;; NOTE: we don't need to append; doing so simply to confirm that
  +                 ;; it's only the relative position wrt the
  +                 ;; share/emacs/<emacs-version>/lisp entry that matters.
  +                 t)
  +    ;; then we'll ensure that the entry for share/emacs/<emacs-version>/lisp is at
  +    ;; the end
  +    (let* ((sitelisppath (format "/share/emacs/%s/lisp"
  +                                 emacs-version))
  +           (pathsuffix (seq-filter
  +                        #'(lambda (x)
  +                            (string-suffix-p sitelisppath x))
  +                        load-path))
  +           (pathprefix (seq-filter
  +                        #'(lambda (x)
  +                            (not
  +                             (string-suffix-p sitelisppath x)))
  +                        load-path)))
  +      (setq load-path (append pathprefix pathsuffix)))))
  +
   (defun report/compilation-status/run ()
     "Run all cases and report those that aren't native-compiled."
  +  (hack/tweak-load-path-in-guix)
     (let* ((results (mapcar (lambda (args) (apply #'report/compilation-status args))
                             report/compilation-status/cases/preloaded))
            (failing (seq-filter (lambda (x) (not (eq (cdr x) 'native-compiled)))
  @@ -169,5 +211,5 @@
               (if failing
                   (concat (format "  %s failing cases below:\n\n" numfailing)
                           (pp-to-string failing))
  -              " Success!"))))
  +              " Success!\n"))))
   ;; guix/hacking/reviews/emacs-aot/test-native-comp-p/preloaded ends here

  Diff finished.  Sat Feb 17 08:50:04 2024
#+end_src

I'm also attaching, for reference, the updated
test-native-comp-p--preloaded.el in its entirety.


-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2024-02-17 14:49 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Suhail via Guix-patches via
@ 2024-02-17 15:15   ` Liliana Marie Prikler
  2024-02-18  0:56     ` Suhail via Guix-patches via
  0 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-17 15:15 UTC (permalink / raw)
  To: Suhail; +Cc: cox.katherine.e+guix, 67260, andrew

Am Samstag, dem 17.02.2024 um 14:49 +0000 schrieb Suhail:
> Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> > ... don't appear to be preloaded through the loadup script, so I
> > have no idea how to catch them or whether it's even worth doing so.
> 
> I dug into this a little deeper.  It seems that by adjusting the
> load-path one is able to load the natively-compiled variants instead
> of the byte-compiled for these features.  Oddly, this adjustment
> doesn't seem to be needed in non-Guix Emacs which may suggest the
> presence of a bug.  I'm hoping you have some insight that explains
> this difference in behaviour.
We adjust our load paths with environment variables.  I don't think our
choice of putting Emacs itself last is wrong here.

> After modifying the previous test-native-comp-p--preloaded.el (in
> hindsight, the preloaded part may be a misnomer) with the below patch
> I got all the 97 cases passing.
> 
> #+begin_src diff
>   diff -u ./test-native-comp-p--preloaded.el ./test-native-comp-p--
> preloaded.el
>   --- ./test-native-comp-p--preloaded.el        2024-02-17
> 08:49:36.294930488 -0500
>   +++ ./test-native-comp-p--preloaded.el        2024-02-17
> 08:38:45.102839041 -0500
>   @@ -155,8 +155,50 @@
>            (x-dnd-init-frame)
>            (x-handle-no-bitmap-icon)))
>  
>   +(defun hack/tweak-load-path-in-guix ()
>   +  "Tweak `load-path' to allow natively compiled versions to be
> loaded.
>   +
>   +If we ensure that the `load-path' entries for `term/internal',
>   +`mule-util' and `ucs-normalize' exist and they occur before the
>   +share/emacs/<emacs-version>/lisp entry then we are able to load
>   +the natively compiled versions of these libraries.  Of those
>   +three, the entry for `term/internal' is missing whereas the
>   +others currently occur after the share/emacs/<emacs-version>/lisp
>   +entry.  We remedy that here.
>   +
>   +Notably, in non-Guix Emacs this isn't needed.  I.e., the fact
>   +that the share/emacs/<emacs-version>/lisp entry precedes the
>   +entries for `mule-util' and `ucs-normalize' is okay as is the
>   +fact that the entry for `term/internal' is missing."
>   +  (when (getenv "GUIX_ENVIRONMENT")
>   +    (require 'find-func)
>   +    ;; first we'll add the missing entry for `term/internal'
>   +    (add-to-list 'load-path
>   +                 (directory-file-name
>   +                  (file-name-directory
>   +                   (find-library-name (symbol-name
> 'term/internal))))
>   +                 ;; NOTE: we don't need to append; doing so simply
> to confirm that
>   +                 ;; it's only the relative position wrt the
>   +                 ;; share/emacs/<emacs-version>/lisp entry that
> matters.
>   +                 t)
>   +    ;; then we'll ensure that the entry for share/emacs/<emacs-
> version>/lisp is at
>   +    ;; the end
>   +    (let* ((sitelisppath (format "/share/emacs/%s/lisp"
>   +                                 emacs-version))
>   +           (pathsuffix (seq-filter
>   +                        #'(lambda (x)
>   +                            (string-suffix-p sitelisppath x))
>   +                        load-path))
>   +           (pathprefix (seq-filter
>   +                        #'(lambda (x)
>   +                            (not
>   +                             (string-suffix-p sitelisppath x)))
>   +                        load-path)))
>   +      (setq load-path (append pathprefix pathsuffix)))))
>   +
>    (defun report/compilation-status/run ()
>      "Run all cases and report those that aren't native-compiled."
>   +  (hack/tweak-load-path-in-guix)
>      (let* ((results (mapcar (lambda (args) (apply
> #'report/compilation-status args))
>                              report/compilation-
> status/cases/preloaded))
>             (failing (seq-filter (lambda (x) (not (eq (cdr x)
> 'native-compiled)))
>   @@ -169,5 +211,5 @@
>                (if failing
>                    (concat (format "  %s failing cases below:\n\n"
> numfailing)
>                            (pp-to-string failing))
>   -              " Success!"))))
>   +              " Success!\n"))))
>    ;; guix/hacking/reviews/emacs-aot/test-native-comp-p/preloaded
> ends here
> 
>   Diff finished.  Sat Feb 17 08:50:04 2024
> #+end_src
This won't work for the common use case of running Emacs from the
store.  Can you do some more research as to how this confusion comes to
be?

Cheers


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2024-02-17 15:15   ` Liliana Marie Prikler
@ 2024-02-18  0:56     ` Suhail via Guix-patches via
  2024-02-18  9:19       ` Liliana Marie Prikler
  0 siblings, 1 reply; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-02-18  0:56 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

"Liliana Marie Prikler" <liliana.prikler@gmail.com> writes:

> I don't think our choice of putting Emacs itself last is wrong here.

I'm not sure I understand.  Just to be clear (please ignore in case this
was already clear), in non-Guix Emacs the situation is as follows:

1. The directory where 'mule-util and 'ucs-normalize are located
   ("/usr/share/emacs/29.2/lisp/international") occurs in the load-path.
   And this entry occurs in the load-path AFTER
   "/usr/share/emacs/29.2/lisp".

2. The directory where 'term/internal is located
   ("/usr/share/emacs/29.2/lisp/international") does NOT occur in the
   load-path (and thus trivially doesn't occur before the
   "share/emacs/29.2/lisp" entry).

After installing the v10 patch series, both 1 and 2 hold in Guix Emacs
as well.  However, Guix Emacs's behaviour when locating/loading
natively-compiled versions of the above three features differs from the
behaviour in non-Guix Emacs.  Specifically, 1 and 2 above seem to pose a
problem for only Guix Emacs and after remedying 1 and 2 above, as in the
test script, the tests pass.

All this to say, if by "putting Emacs itself last" you meant the change
I made to the test script to make the tests pass, then while it may not
be wrong, it also isn't correct either (seeing how it's not needed in
non-Guix Emacs).  My goal in sharing the patch was not to suggest a fix,
but rather to possibly highlight something correlated with the cause of
the problem we're observing.

> Can you do some more research as to how this confusion comes to be?

Since I have less familiarity with the internals of how Emacs locates
natively-compiled features and loads them, I'm not sure where to begin.
Do you have some concrete suggestions?

What (I believe) we know:

- Not all the .eln entries in the "preloaded" native-comp-eln-load-path
  directory in Emacs are actually loaded by default.  This doesn't
  directly concern the issue, but it's to clarify that my use of the
  term "preloaded" in this thread is regarding the former and not the
  latter.

- The issue of
  whether-natively-compiled-variants-are-loaded-or-not-depends-on-order-in-load-path
  doesn't seem to affect packages that aren't built-in.  Specifically,
  if the load-entry for a not-built-in package is put after the
  "share/emacs/29.2/lisp" entry, Guix Emacs is still able to load the
  natively-compiled variant.

- It is unclear why other packages such 'log-edit, 'find-func
  etc. (built-in, but not loaded by default, having their load-entry
  after the "share/emacs/29.2/lisp" entry) aren't affected.

-- 
Suhail

This email is not an offer capable of acceptance, does not evidence an
intention to enter into an agreement, has no operative effect until a
definitive agreement is signed in writing by both parties, and that no
party should act in reliance on the email or any representations of the
sender until a definitive agreement is signed in writing by both
parties.





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2024-02-18  0:56     ` Suhail via Guix-patches via
@ 2024-02-18  9:19       ` Liliana Marie Prikler
  2024-02-19 21:42         ` Suhail via Guix-patches via
  0 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-18  9:19 UTC (permalink / raw)
  To: Suhail; +Cc: cox.katherine.e+guix, 67260, andrew

Am Sonntag, dem 18.02.2024 um 00:56 +0000 schrieb Suhail:
> "Liliana Marie Prikler" <liliana.prikler@gmail.com> writes:
> 
> > I don't think our choice of putting Emacs itself last is wrong
> > here.
> 
> I'm not sure I understand.  Just to be clear (please ignore in case
> this was already clear), in non-Guix Emacs the situation is as
> follows:
> 
> 1. The directory where 'mule-util and 'ucs-normalize are located
>    ("/usr/share/emacs/29.2/lisp/international") occurs in the load-
> path.
>    And this entry occurs in the load-path AFTER
>    "/usr/share/emacs/29.2/lisp".
> 
> 2. The directory where 'term/internal is located
>    ("/usr/share/emacs/29.2/lisp/international") does NOT occur in the
>    load-path (and thus trivially doesn't occur before the
>    "share/emacs/29.2/lisp" entry).
Directory (2) is the same as directory (1).  I think you meant
$prefix/share/emacs/$emacs_version/lisp/term?  

> After installing the v10 patch series, both 1 and 2 hold in Guix
> Emacs as well.  However, Guix Emacs's behaviour when locating/loading
> natively-compiled versions of the above three features differs from
> the behaviour in non-Guix Emacs.  Specifically, 1 and 2 above seem to
> pose a problem for only Guix Emacs and after remedying 1 and 2 above,
> as in the test script, the tests pass.
From my understanding (1) poses a problem because it messes up the way
our patch computes relative file names.  We could fix that with the
newly introduced NATIVE_COMP_BOGUS_DIRS… hopefully.

> All this to say, if by "putting Emacs itself last" you meant the
> change I made to the test script to make the tests pass, then while
> it may not be wrong, it also isn't correct either (seeing how it's
> not needed in non-Guix Emacs).  
The last (first) directory in EMACSLOADPATH (EMACSNATIVELOADPATH) is
$prefix/share/emacs/$emacs_version/lisp ($prefix/lib/emacs/…) on Guix
System.

> My goal in sharing the patch was not to suggest a fix, but rather to
> possibly highlight something correlated with the cause of the problem
> we're observing.
> 
> > Can you do some more research as to how this confusion comes to be?
> 
> Since I have less familiarity with the internals of how Emacs locates
> natively-compiled features and loads them, I'm not sure where to
> begin.  Do you have some concrete suggestions?


> What (I believe) we know:
> 
> - Not all the .eln entries in the "preloaded" 
>   native-comp-eln-load-path directory in Emacs are actually loaded by
>   default.  This doesn't directly concern the issue, but it's to
>   clarify that my use of the term "preloaded" in this thread is
>   regarding the former and not the latter.
Well, it does concern the issue in that locating such files becomes
even harder.  We need some place to put them and complicating these
things for preloaded packages (for no real reason, might I add) is not
fun.

> - The issue of whether natively compiled variants are loaded or
>   depending on load-path order doesn't seem to affect packages that
>   aren't built-in.  Specifically, if the load-entry for a
>   not-built-in package is put after the "share/emacs/29.2/lisp"
>   entry, Guix Emacs is still able to load the natively-compiled
>   variant.
Well, obviously not.  Those are found under their packages and are
probably still within a flat directory hierarchy.

> - It is unclear why other packages such 'log-edit, 'find-func
>   etc. (built-in, but not loaded by default, having their load-entry
>   after the "share/emacs/29.2/lisp" entry) aren't affected.
Update your script to account for them and we shall find out.

Cheers




^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2024-02-18  9:19       ` Liliana Marie Prikler
@ 2024-02-19 21:42         ` Suhail via Guix-patches via
  2024-02-20 17:51           ` Liliana Marie Prikler
  0 siblings, 1 reply; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-02-19 21:42 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

"Liliana Marie Prikler" <liliana.prikler@gmail.com> writes:

> Am Sonntag, dem 18.02.2024 um 00:56 +0000 schrieb Suhail:
>> 1. The directory where 'mule-util and 'ucs-normalize are located
>>    ("/usr/share/emacs/29.2/lisp/international") occurs in the load-
>> path.
>>    And this entry occurs in the load-path AFTER
>>    "/usr/share/emacs/29.2/lisp".
>>
>> 2. The directory where 'term/internal is located
>>    ("/usr/share/emacs/29.2/lisp/international") does NOT occur in the
>>    load-path (and thus trivially doesn't occur before the
>>    "share/emacs/29.2/lisp" entry).
> Directory (2) is the same as directory (1).  I think you meant
> $prefix/share/emacs/$emacs_version/lisp/term?

I did; thank you for catching that.

>> - It is unclear why other packages such 'log-edit, 'find-func
>>   etc. (built-in, but not loaded by default, having their load-entry
>>   after the "share/emacs/29.2/lisp" entry) aren't affected.
> Update your script to account for them and we shall find out.

See the updated test script below.  The above are accounted for in the
third test case.

The result of invoking the test script using the following invocation:

#+begin_src sh :results replace
  emacs -Q --batch \
        -l path/to/test-native-comp-p.el \
        -f ert-run-tests-batch-and-exit 2>&1
#+end_src

On non-Guix Emacs results in:

#+begin_example
  Running 5 tests (2024-02-19 16:35:27-0500, selector ‘t’)
     passed  1/5  01-natively-compiled-features-passing-as-of-v10 (0.000035 sec)
     passed  2/5  02-natively-compiled-features-failing-as-of-v10 (0.000016 sec)
     passed  3/5  03-some-features-in-later-load-path-entries-are-still-natively-compiled (0.000012 sec)
     passed  4/5  04-load-path-order-should-not-determine-natively-compiled-status (0.000015 sec)
     passed  5/5  05-there-exists-load-path-order-where-all-tests-pass (0.000010 sec)

  Ran 5 tests, 5 results as expected, 0 unexpected (2024-02-19 16:35:27-0500, 0.000206 sec)
#+end_example

And with v10 patch series on Guix Emacs results in:

#+begin_example
  Running 5 tests (2024-02-19 21:36:32+0000, selector `t')
     passed  1/5  01-natively-compiled-features-passing-as-of-v10 (0.000066 sec)
     failed  2/5  02-natively-compiled-features-failing-as-of-v10 (0.000034 sec)
     passed  3/5  03-some-features-in-later-load-path-entries-are-still-natively-compiled (0.000013 sec)
     failed  4/5  04-load-path-order-should-not-determine-natively-compiled-status (0.000034 sec)
     passed  5/5  05-there-exists-load-path-order-where-all-tests-pass (0.000014 sec)

  Ran 5 tests, 5 results as expected, 0 unexpected (2024-02-19 21:36:32+0000, 0.000322 sec)
  2 expected failures
#+end_example

The test script (test-native-comp-p.el):

#+begin_src elisp :eval never
  ;;; Code:
  (require 'ert)
  (setq ert-quiet nil
        ert-batch-print-level 10
        ert-batch-print-length 10
        ert-batch-backtrace-line-length t)

  ;;; utils/
  (eval-and-compile
    (require 'help-fns)
    (defmacro utils/report-compilation-status (fun &optional feature)
      "Report on the compilation status of function FUN.
  Optionally load FEATURE before reporting on compilation status."
      `(progn
         (eval-when-compile
           (when ',feature
             (require ',feature)))
         (let ((descstr (substring-no-properties
                         (with-output-to-string
                           (help-fns-function-description-header ',fun)))))
           (cons ',fun
                 (cond
                  ((string-search " native-compiled" descstr) 'native-compiled)
                  ;; ((string-search " autoloaded" descstr) descstr)
                  ((string-search " byte-compiled" descstr) 'byte-compiled)
                  (t descstr))))))

    (defun utils/report-compilation-status/apply (fun &optional feature)
      "Invoke `utils/report-compilation-status' with FUN and FEATURE."
      (eval `(utils/report-compilation-status ,fun ,feature)))

    (require 'find-func)
    (defun utils/find-library-dir (feature)
      "Output directory where FEATURE resides."
      (directory-file-name
       (file-name-directory
        (find-library-name (symbol-name feature)))))

    (defun utils/report-failing-cases (cases)
      "From CASES, report failing tests.
  Test failure are those where `utils/report-compilation-status' doesn't
  report natively-compiled.  CASES is a list where each element are
  ARGUMENTS for `utils/report-compilation-status'."
      (let ((results (mapcar (lambda (args)
                               (apply #'utils/report-compilation-status/apply args))
                             cases)))
        (seq-filter (lambda (x) (not (eq (cdr x) 'native-compiled)))
                    results))))

  ;;; hack/
  (eval-and-compile
    (defun hack/new-load-path-that-can-make-v10-test-failures-pass ()
      "Return a list that can be used as the `load-path'.

  The returned list is assured to have the entry for
  share/emacs/<emacs-version>/lisp occur after the entry for
  lisp/international (corresponding to the `mule-util' and
  `ucs-normalize' failing test cases) and the entry for lisp/term
   (corresponding to the `term/internal' failing test case).

  If the `load-path' is set to the returned value, all tests pass
  in v10.  Notably, in non-Guix Emacs this isn't needed.  I.e., the
  fact that the share/emacs/<emacs-version>/lisp entry precedes the
  entries for `mule-util' and `ucs-normalize' is okay as is the
  fact that the entry for `term/internal' is missing."
      (eval-when-compile
        (require 'find-func))
      ;; we'll ensure that the entry for share/emacs/<emacs-version>/lisp comes
      ;; after the lisp/international and lisp/term entries
      (let* ((new-load-path load-path)
             ;; add the missing entry for `term/internal'
             (_ (add-to-list 'new-load-path
                             (utils/find-library-dir 'term/internal)
                             ;; NOTE: we don't need to append; doing so simply to confirm that
                             ;; it's only the relative position wrt the
                             ;; share/emacs/<emacs-version>/lisp entry that matters.
                             t))
             (sitelisppath (format "/share/emacs/%s/lisp"
                                   emacs-version))
             (pathsuffix (seq-filter
                          (lambda (x)
                            (string-suffix-p sitelisppath x))
                          new-load-path))
             (pathprefix (seq-filter
                          (lambda (x)
                            (not
                             (string-suffix-p sitelisppath x)))
                          new-load-path)))
        (append pathprefix pathsuffix))))

  ;;; cases/
  ;; [[/usr/share/emacs/29.2/lisp]]
  (eval-when-compile
    (defvar cases/eln-in-preloaded-dir nil
      "Functions that ought to be natively-compiled.")
    (setq cases/eln-in-preloaded-dir
          '((abbrev-mode)
            (backquote-process)
            (mode-line-widen)
            (buffer-menu)
            ;; burmese
            (button-mode)
            (byte-run-strip-symbol-positions)
            (case-table-get-table)
            (cconv-convert)
            ;; cham
            (use-default-char-width-table)
            ;; chinese
            (cl-generic-p)
            (cl-struct-define)
            (x-setup-function-keys)
            (encode-composition-rule)
            ;; cp51932
            (custom-declare-face)
            (minibuffer-prompt-properties--setter) ;; cus-start.el
            (custom-add-choice)
            ;; cyrillic
            ;; czech
            (debug-early)
            (display-table-slot disp-table) ;; disp-table.eln exists
            (dnd-open-file)
            (dos-mode25 dos-fns)    ;; dos-fns.eln exists
            ;; dos-vars
            (find-file-text dos-w32) ;; dos-w32.eln exists
            (dynamic-setting-handle-config-changed-event)
            (easy-menu-item-present-p)
            ;; ediff-hook
            (eldoc-mode)
            (electric-indent-mode)
            (elisp-mode-syntax-propertize)
            ;; english
            (getenv)
            (epa-file-find-file-hook)
            ;; ethiopic
            ;; eucjp-ms
            ;; european
            (face-list)
            (find-file-noselect)
            (fill-region)
            ;; float-sup
            (font-lock-change-mode)
            (font-lock-add-keywords)
            (fontset-plain-name)
            (format-read)
            (frame-edges)
            (fringe-mode)
            ;; georgian
            ;; greek
            ;; haiku-win
            ;; hebrew
            (help-quick)
            (image-type)
            (indent-region)
            (indian-compose-regexp)
            ;; indonesian
            (msdos-setup-keyboard term/internal) ;; internal.eln exists
            (isearch-abort)
            (iso-transl-set-language)
            ;; japanese
            (jit-lock-mode)
            (jka-compr-build-file-regexp)
            (keymap-global-set)
            ;; khmer
            ;; korean
            ;; lao
            (forward-sexp)
            (lisp-string-in-doc-position-p)
            (ls-lisp-set-options ls-lisp) ;; ls-lisp.eln exists
            (macroexp-compiling-p)
            (map-y-or-n-p)
            (menu-find-file-existing)
            (completion-boundaries)
            (egyptian-shape-grouping)
            (mouse-double-click-time)
            (convert-define-charset-argument)
            (coding-system-change-eol-conversion)
            ;; mule-conf.eln
            (store-substring mule-util) ;; mule-util.eln exists
            (mouse-wheel-change-button)
            (advice-function-mapc)
            (comment-string-strip)
            ;; (ns-handle-nxopen term/ns-win)
            (obarray-make)
            (oclosure-type)
            (forward-page)
            (sentence-end)
            (show-paren-function)
            ;; (msdos-face-setup term/pc-win)
            (pgtk-dnd-init-frame pgtk-dnd) ;; pgtk-dnd.eln exists
            ;; (pgtk-drag-n-drop term/pgtk-win)
            ;; philippine
            (prog-context-menu)
            (regexp-opt)
            (get-register)
            (query-replace-descr)
            (rfn-eshadow-setup-minibuffer)
            (read-multiple-choice)
            ;; romanian
            (scroll-bar-scale)
            (gui-select-text)
            (seq-first)
            (hack-read-symbol-shorthands)
            (next-error-find-buffer)
            ;; sinhala
            ;; slovak
            (exit-splash-screen)
            (buffer-local-boundp)
            (syntax-propertize-multiline)
            (tab-bar-mode)
            (tabulated-list-put-tag)
            ;; tai-viet
            (text-mode)
            ;; thai
            ;; tibetan
            (timer-activate)
            (tool-bar-mode)
            (tooltip-mode)
            (tty-color-desc)
            (ucs-normalize-hfs-nfd-comp-p ucs-normalize) ;; ucs-normalize.eln exists
            (uniquify-item-p)
            ;; utf-8-lang.eln
            (vc-mode)
            (emacs-version)
            ;; vietnamese
            ;; (w32-shell-name)
            ;; w32-vars.eln
            ;; (w32-handle-dropped-file 'term/w32-win)
            (define-widget)
            (window-right)
            (x-dnd-init-frame)
            (x-handle-no-bitmap-icon))))

  ;;; ERT tests
  (ert-deftest 01-natively-compiled-features-passing-as-of-v10 ()
    "The 94 cases which pass for v10 patch series.
  These cases are taken from .eln files that are located in the preloaded
  directory for non-Guix Emacs."
    (eval-when-compile
      (let ((cases (seq-filter (lambda (x)
                                 (not (memq (cadr x) '(mule-util term/internal ucs-normalize))))
                               cases/eln-in-preloaded-dir)))
        (should-not (utils/report-failing-cases cases)))))

  (ert-deftest 02-natively-compiled-features-failing-as-of-v10 ()
    "The 3 cases which fail for v10 patch series on Guix Emacs.
  These cases are taken from .eln files that are located in the preloaded
  directory for non-Guix Emacs."
    :expected-result (if (getenv "GUIX_ENVIRONMENT")
                         :failed
                       :passed)
    (should-not
     (eval-when-compile
       (let ((cases (seq-filter (lambda (x)
                                  (memq (cadr x) '(mule-util term/internal ucs-normalize)))
                                cases/eln-in-preloaded-dir)))
         (utils/report-failing-cases cases)))))

  (ert-deftest 03-some-features-in-later-load-path-entries-are-still-natively-compiled ()
    "These cases pass as of v10 of the patch.
  These cases share the fact that their directory entries occur in
  the `load-path' after the $prefix/share/emacs/$emacs_version/lisp
  entry.  This is something these cases have in common with the
  three cases that are known to fail, however, unlike them these
  succeed (i.e., natively-compiled variants are loaded)."
    (eval-when-compile
      (let* ((cases '((cl-position cl-seq)
                      (find-library-name find-func)
                      (log-edit log-edit)))
             (failing (utils/report-failing-cases cases))
             (features-loadpath-entries (mapcar #'utils/find-library-dir
                                                (mapcar #'cadr cases)))
             (features-entry-pos (mapcar (lambda (x)
                                           (cl-position
                                            (utils/find-library-dir (cadr x))
                                            load-path :test #'equal))
                                         cases))
             (share-emacs-lisp-entry-pos (cl-position "/share/emacs/29.2/lisp"
                                                      load-path
                                                      :test #'string-suffix-p)))
        (should-not failing)
        (should-not (seq-filter (lambda (x) (< x share-emacs-lisp-entry-pos))
                                features-entry-pos)))))

  (ert-deftest 04-load-path-order-should-not-determine-natively-compiled-status ()
    "This seems like an invariant that would be useful to have.
  It is unclear if this is guaranteed by upstream Emacs, but
  observations seem consistent with it."
    :expected-result (if (getenv "GUIX_ENVIRONMENT")
                         :failed
                       :passed)
    (eval-when-compile
      (defvar original-load-path load-path))
    (let ((failures-prior-to-load-path-shuffle
           (eval-when-compile
             (utils/report-failing-cases cases/eln-in-preloaded-dir)))
          (failures-post-load-path-shuffle
           (eval-when-compile
             (progn
               (setq load-path
                     (hack/new-load-path-that-can-make-v10-test-failures-pass))
               (dolist (item cases/eln-in-preloaded-dir)
                 (when (cadr item)
                   (unload-feature (cadr item))))
               (utils/report-failing-cases cases/eln-in-preloaded-dir)))))
      (should (equal failures-prior-to-load-path-shuffle
                     failures-post-load-path-shuffle))))

  (ert-deftest 05-there-exists-load-path-order-where-all-tests-pass ()
    "Proof witness that the v10 failing cases relate to load-path ordering."
    (should-not (eval-when-compile
                  (when (and (boundp 'original-load-path) original-load-path)
                    (setq load-path original-load-path)
                    (dolist (item cases/eln-in-preloaded-dir)
                      (when (cadr item)
                        (unload-feature (cadr item)))))
                  (defvar original-load-path load-path)
                  (setq load-path
                        (hack/new-load-path-that-can-make-v10-test-failures-pass))
                  (utils/report-failing-cases cases/eln-in-preloaded-dir))))

  ;;; test-native-comp-p.el ends here
#+end_src

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2024-02-19 21:42         ` Suhail via Guix-patches via
@ 2024-02-20 17:51           ` Liliana Marie Prikler
  2024-02-20 18:41             ` Suhail via Guix-patches via
  0 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-20 17:51 UTC (permalink / raw)
  To: Suhail; +Cc: cox.katherine.e+guix, 67260, andrew

Am Montag, dem 19.02.2024 um 21:42 +0000 schrieb Suhail:
> "Liliana Marie Prikler" <liliana.prikler@gmail.com> writes:
> 
> > Am Sonntag, dem 18.02.2024 um 00:56 +0000 schrieb Suhail:
> > > 1. The directory where 'mule-util and 'ucs-normalize are located
> > >    ("/usr/share/emacs/29.2/lisp/international") occurs in the
> > > load-
> > > path.
> > >    And this entry occurs in the load-path AFTER
> > >    "/usr/share/emacs/29.2/lisp".
> > > 
> > > 2. The directory where 'term/internal is located
> > >    ("/usr/share/emacs/29.2/lisp/international") does NOT occur in
> > > the
> > >    load-path (and thus trivially doesn't occur before the
> > >    "share/emacs/29.2/lisp" entry).
> > Directory (2) is the same as directory (1).  I think you meant
> > $prefix/share/emacs/$emacs_version/lisp/term?
> 
> I did; thank you for catching that.
> 
> > > - It is unclear why other packages such 'log-edit, 'find-func
> > >   etc. (built-in, but not loaded by default, having their load-
> > > entry
> > >   after the "share/emacs/29.2/lisp" entry) aren't affected.
> > Update your script to account for them and we shall find out.
> 
> See the updated test script below.  The above are accounted for in
> the third test case.
We still only have 97 tests squashed to 5 cases IIUC.  There's some
1000 files in the native-lisp directory.  What I was actually hoping
for is more or less one test per feature.

> The result of invoking the test script using the following
> invocation:
> 
> #+begin_src sh :results replace
>   emacs -Q --batch \
>         -l path/to/test-native-comp-p.el \
>         -f ert-run-tests-batch-and-exit 2>&1
> #+end_src
> 
> On non-Guix Emacs results in:
> 
> #+begin_example
>   Running 5 tests (2024-02-19 16:35:27-0500, selector ‘t’)
>      passed  1/5  01-natively-compiled-features-passing-as-of-v10
> (0.000035 sec)
>      passed  2/5  02-natively-compiled-features-failing-as-of-v10
> (0.000016 sec)
>      passed  3/5  03-some-features-in-later-load-path-entries-are-
> still-natively-compiled (0.000012 sec)
>      passed  4/5  04-load-path-order-should-not-determine-natively-
> compiled-status (0.000015 sec)
>      passed  5/5  05-there-exists-load-path-order-where-all-tests-
> pass (0.000010 sec)
> 
>   Ran 5 tests, 5 results as expected, 0 unexpected (2024-02-19
> 16:35:27-0500, 0.000206 sec)
> #+end_example
> 
> And with v10 patch series on Guix Emacs results in:
> 
> #+begin_example
>   Running 5 tests (2024-02-19 21:36:32+0000, selector `t')
>      passed  1/5  01-natively-compiled-features-passing-as-of-v10
> (0.000066 sec)
>      failed  2/5  02-natively-compiled-features-failing-as-of-v10
> (0.000034 sec)
>      passed  3/5  03-some-features-in-later-load-path-entries-are-
> still-natively-compiled (0.000013 sec)
>      failed  4/5  04-load-path-order-should-not-determine-natively-
> compiled-status (0.000034 sec)
>      passed  5/5  05-there-exists-load-path-order-where-all-tests-
> pass (0.000014 sec)
> 
>   Ran 5 tests, 5 results as expected, 0 unexpected (2024-02-19
> 21:36:32+0000, 0.000322 sec)
>   2 expected failures
> #+end_example
> 
> The test script (test-native-comp-p.el):
> 
> #+begin_src elisp :eval never
>   ;;; Code:
>   (require 'ert)
>   (setq ert-quiet nil
>         ert-batch-print-level 10
>         ert-batch-print-length 10
>         ert-batch-backtrace-line-length t)
> 
>   ;;; utils/
>   (eval-and-compile
>     (require 'help-fns)
>     (defmacro utils/report-compilation-status (fun &optional feature)
>       "Report on the compilation status of function FUN.
>   Optionally load FEATURE before reporting on compilation status."
>       `(progn
>          (eval-when-compile
>            (when ',feature
>              (require ',feature)))
>          (let ((descstr (substring-no-properties
>                          (with-output-to-string
>                            (help-fns-function-description-header
> ',fun)))))
>            (cons ',fun
>                  (cond
>                   ((string-search " native-compiled" descstr)
> 'native-compiled)
>                   ;; ((string-search " autoloaded" descstr) descstr)
>                   ((string-search " byte-compiled" descstr) 'byte-
> compiled)
>                   (t descstr))))))
> 
>     (defun utils/report-compilation-status/apply (fun &optional
> feature)
>       "Invoke `utils/report-compilation-status' with FUN and
> FEATURE."
>       (eval `(utils/report-compilation-status ,fun ,feature)))
> 
>     (require 'find-func)
>     (defun utils/find-library-dir (feature)
>       "Output directory where FEATURE resides."
>       (directory-file-name
>        (file-name-directory
>         (find-library-name (symbol-name feature)))))
> 
>     (defun utils/report-failing-cases (cases)
>       "From CASES, report failing tests.
>   Test failure are those where `utils/report-compilation-status'
> doesn't
>   report natively-compiled.  CASES is a list where each element are
>   ARGUMENTS for `utils/report-compilation-status'."
>       (let ((results (mapcar (lambda (args)
>                                (apply #'utils/report-compilation-
> status/apply args))
>                              cases)))
>         (seq-filter (lambda (x) (not (eq (cdr x) 'native-compiled)))
>                     results))))
> 
>   ;;; hack/
>   (eval-and-compile
>     (defun hack/new-load-path-that-can-make-v10-test-failures-pass ()
>       "Return a list that can be used as the `load-path'.
> 
>   The returned list is assured to have the entry for
>   share/emacs/<emacs-version>/lisp occur after the entry for
>   lisp/international (corresponding to the `mule-util' and
>   `ucs-normalize' failing test cases) and the entry for lisp/term
>    (corresponding to the `term/internal' failing test case).
> 
>   If the `load-path' is set to the returned value, all tests pass
>   in v10.  Notably, in non-Guix Emacs this isn't needed.  I.e., the
>   fact that the share/emacs/<emacs-version>/lisp entry precedes the
>   entries for `mule-util' and `ucs-normalize' is okay as is the
>   fact that the entry for `term/internal' is missing."
>       (eval-when-compile
>         (require 'find-func))
>       ;; we'll ensure that the entry for share/emacs/<emacs-
> version>/lisp comes
>       ;; after the lisp/international and lisp/term entries
>       (let* ((new-load-path load-path)
>              ;; add the missing entry for `term/internal'
>              (_ (add-to-list 'new-load-path
>                              (utils/find-library-dir 'term/internal)
>                              ;; NOTE: we don't need to append; doing
> so simply to confirm that
>                              ;; it's only the relative position wrt
> the
>                              ;; share/emacs/<emacs-version>/lisp
> entry that matters.
>                              t))
>              (sitelisppath (format "/share/emacs/%s/lisp"
>                                    emacs-version))
>              (pathsuffix (seq-filter
>                           (lambda (x)
>                             (string-suffix-p sitelisppath x))
>                           new-load-path))
>              (pathprefix (seq-filter
>                           (lambda (x)
>                             (not
>                              (string-suffix-p sitelisppath x)))
>                           new-load-path)))
>         (append pathprefix pathsuffix))))
> 
>   ;;; cases/
>   ;; [[/usr/share/emacs/29.2/lisp]]
>   (eval-when-compile
>     (defvar cases/eln-in-preloaded-dir nil
>       "Functions that ought to be natively-compiled.")
>     (setq cases/eln-in-preloaded-dir
>           '((abbrev-mode)
>             (backquote-process)
>             (mode-line-widen)
>             (buffer-menu)
>             ;; burmese
>             (button-mode)
>             (byte-run-strip-symbol-positions)
>             (case-table-get-table)
>             (cconv-convert)
>             ;; cham
>             (use-default-char-width-table)
>             ;; chinese
>             (cl-generic-p)
>             (cl-struct-define)
>             (x-setup-function-keys)
>             (encode-composition-rule)
>             ;; cp51932
>             (custom-declare-face)
>             (minibuffer-prompt-properties--setter) ;; cus-start.el
>             (custom-add-choice)
>             ;; cyrillic
>             ;; czech
>             (debug-early)
>             (display-table-slot disp-table) ;; disp-table.eln exists
>             (dnd-open-file)
>             (dos-mode25 dos-fns)    ;; dos-fns.eln exists
>             ;; dos-vars
>             (find-file-text dos-w32) ;; dos-w32.eln exists
>             (dynamic-setting-handle-config-changed-event)
>             (easy-menu-item-present-p)
>             ;; ediff-hook
>             (eldoc-mode)
>             (electric-indent-mode)
>             (elisp-mode-syntax-propertize)
>             ;; english
>             (getenv)
>             (epa-file-find-file-hook)
>             ;; ethiopic
>             ;; eucjp-ms
>             ;; european
>             (face-list)
>             (find-file-noselect)
>             (fill-region)
>             ;; float-sup
>             (font-lock-change-mode)
>             (font-lock-add-keywords)
>             (fontset-plain-name)
>             (format-read)
>             (frame-edges)
>             (fringe-mode)
>             ;; georgian
>             ;; greek
>             ;; haiku-win
>             ;; hebrew
>             (help-quick)
>             (image-type)
>             (indent-region)
>             (indian-compose-regexp)
>             ;; indonesian
>             (msdos-setup-keyboard term/internal) ;; internal.eln
> exists
>             (isearch-abort)
>             (iso-transl-set-language)
>             ;; japanese
>             (jit-lock-mode)
>             (jka-compr-build-file-regexp)
>             (keymap-global-set)
>             ;; khmer
>             ;; korean
>             ;; lao
>             (forward-sexp)
>             (lisp-string-in-doc-position-p)
>             (ls-lisp-set-options ls-lisp) ;; ls-lisp.eln exists
>             (macroexp-compiling-p)
>             (map-y-or-n-p)
>             (menu-find-file-existing)
>             (completion-boundaries)
>             (egyptian-shape-grouping)
>             (mouse-double-click-time)
>             (convert-define-charset-argument)
>             (coding-system-change-eol-conversion)
>             ;; mule-conf.eln
>             (store-substring mule-util) ;; mule-util.eln exists
>             (mouse-wheel-change-button)
>             (advice-function-mapc)
>             (comment-string-strip)
>             ;; (ns-handle-nxopen term/ns-win)
>             (obarray-make)
>             (oclosure-type)
>             (forward-page)
>             (sentence-end)
>             (show-paren-function)
>             ;; (msdos-face-setup term/pc-win)
>             (pgtk-dnd-init-frame pgtk-dnd) ;; pgtk-dnd.eln exists
>             ;; (pgtk-drag-n-drop term/pgtk-win)
>             ;; philippine
>             (prog-context-menu)
>             (regexp-opt)
>             (get-register)
>             (query-replace-descr)
>             (rfn-eshadow-setup-minibuffer)
>             (read-multiple-choice)
>             ;; romanian
>             (scroll-bar-scale)
>             (gui-select-text)
>             (seq-first)
>             (hack-read-symbol-shorthands)
>             (next-error-find-buffer)
>             ;; sinhala
>             ;; slovak
>             (exit-splash-screen)
>             (buffer-local-boundp)
>             (syntax-propertize-multiline)
>             (tab-bar-mode)
>             (tabulated-list-put-tag)
>             ;; tai-viet
>             (text-mode)
>             ;; thai
>             ;; tibetan
>             (timer-activate)
>             (tool-bar-mode)
>             (tooltip-mode)
>             (tty-color-desc)
>             (ucs-normalize-hfs-nfd-comp-p ucs-normalize) ;; ucs-
> normalize.eln exists
>             (uniquify-item-p)
>             ;; utf-8-lang.eln
>             (vc-mode)
>             (emacs-version)
>             ;; vietnamese
>             ;; (w32-shell-name)
>             ;; w32-vars.eln
>             ;; (w32-handle-dropped-file 'term/w32-win)
>             (define-widget)
>             (window-right)
>             (x-dnd-init-frame)
>             (x-handle-no-bitmap-icon))))
> 
>   ;;; ERT tests
>   (ert-deftest 01-natively-compiled-features-passing-as-of-v10 ()
>     "The 94 cases which pass for v10 patch series.
>   These cases are taken from .eln files that are located in the
> preloaded
>   directory for non-Guix Emacs."
>     (eval-when-compile
>       (let ((cases (seq-filter (lambda (x)
>                                  (not (memq (cadr x) '(mule-util
> term/internal ucs-normalize))))
>                                cases/eln-in-preloaded-dir)))
>         (should-not (utils/report-failing-cases cases)))))
> 
>   (ert-deftest 02-natively-compiled-features-failing-as-of-v10 ()
>     "The 3 cases which fail for v10 patch series on Guix Emacs.
>   These cases are taken from .eln files that are located in the
> preloaded
>   directory for non-Guix Emacs."
>     :expected-result (if (getenv "GUIX_ENVIRONMENT")
That is not a good way of checking whether it's Guix' emacs or not.  I
propose doing a per-file deftest instead.
>                          :failed
>                        :passed)
>     (should-not
>      (eval-when-compile
>        (let ((cases (seq-filter (lambda (x)
>                                   (memq (cadr x) '(mule-util
> term/internal ucs-normalize)))
>                                 cases/eln-in-preloaded-dir)))
>          (utils/report-failing-cases cases)))))
> 
>   (ert-deftest 03-some-features-in-later-load-path-entries-are-still-
> natively-compiled ()
>     "These cases pass as of v10 of the patch.
>   These cases share the fact that their directory entries occur in
>   the `load-path' after the $prefix/share/emacs/$emacs_version/lisp
>   entry.  This is something these cases have in common with the
>   three cases that are known to fail, however, unlike them these
>   succeed (i.e., natively-compiled variants are loaded)."
>     (eval-when-compile
>       (let* ((cases '((cl-position cl-seq)
>                       (find-library-name find-func)
>                       (log-edit log-edit)))
>              (failing (utils/report-failing-cases cases))
>              (features-loadpath-entries (mapcar #'utils/find-library-
> dir
>                                                 (mapcar #'cadr
> cases)))
>              (features-entry-pos (mapcar (lambda (x)
>                                            (cl-position
>                                             (utils/find-library-dir
> (cadr x))
>                                             load-path :test #'equal))
>                                          cases))
>              (share-emacs-lisp-entry-pos (cl-position
> "/share/emacs/29.2/lisp"
>                                                       load-path
>                                                       :test #'string-
> suffix-p)))
>         (should-not failing)
>         (should-not (seq-filter (lambda (x) (< x share-emacs-lisp-
> entry-pos))
>                                 features-entry-pos)))))
> 
>   (ert-deftest 04-load-path-order-should-not-determine-natively-
> compiled-status ()
>     "This seems like an invariant that would be useful to have.
>   It is unclear if this is guaranteed by upstream Emacs, but
>   observations seem consistent with it."
>     :expected-result (if (getenv "GUIX_ENVIRONMENT")
>                          :failed
>                        :passed)
>     (eval-when-compile
>       (defvar original-load-path load-path))
>     (let ((failures-prior-to-load-path-shuffle
>            (eval-when-compile
>              (utils/report-failing-cases cases/eln-in-preloaded-
> dir)))
>           (failures-post-load-path-shuffle
>            (eval-when-compile
>              (progn
>                (setq load-path
>                      (hack/new-load-path-that-can-make-v10-test-
> failures-pass))
>                (dolist (item cases/eln-in-preloaded-dir)
>                  (when (cadr item)
>                    (unload-feature (cadr item))))
>                (utils/report-failing-cases cases/eln-in-preloaded-
> dir)))))
>       (should (equal failures-prior-to-load-path-shuffle
>                      failures-post-load-path-shuffle))))
> 
>   (ert-deftest 05-there-exists-load-path-order-where-all-tests-pass
> ()
>     "Proof witness that the v10 failing cases relate to load-path
> ordering."
>     (should-not (eval-when-compile
>                   (when (and (boundp 'original-load-path) original-
> load-path)
>                     (setq load-path original-load-path)
>                     (dolist (item cases/eln-in-preloaded-dir)
>                       (when (cadr item)
>                         (unload-feature (cadr item)))))
>                   (defvar original-load-path load-path)
>                   (setq load-path
>                         (hack/new-load-path-that-can-make-v10-test-
> failures-pass))
>                   (utils/report-failing-cases cases/eln-in-preloaded-
> dir))))
> 
>   ;;; test-native-comp-p.el ends here
> #+end_src
Could you do a MIME attachment next time?  I think I know the heart of
the issue now, but I still need to code up a solution.

Cheers


^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things
  2024-02-20 17:51           ` Liliana Marie Prikler
@ 2024-02-20 18:41             ` Suhail via Guix-patches via
  0 siblings, 0 replies; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-02-20 18:41 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

"Liliana Marie Prikler" <liliana.prikler@gmail.com> writes:

> We still only have 97 tests squashed to 5 cases IIUC.

Yes.

> There's some 1000 files in the native-lisp directory.  What I was
> actually hoping for is more or less one test per feature.

Yes, I agree that that would be useful, but doing so was (is) more than
what I was (am) able to do in the time I was (am) able to commit (at
present).

I believe it would be valuable to have such an exhaustive test included
as part of the patch submission to prevent future regressions.

> That is not a good way of checking whether it's Guix' emacs or not.

What would be a better way?  Matching against the --prefix value in the
output of emacs-build-description function?

> I propose doing a per-file deftest instead.

I don't understand the connection between a per-file deftest and the
manner in which guix-emacs-or-not is tested, but otherwise agree on the
utility of per-feature deftests.

> Could you do a MIME attachment next time?

Sure.  For now, for what it's worth and in case it helps, please see
attached a copy of the same file as before.


-- 
Suhail

[-- Attachment #2: test-native-comp-p.el --]
[-- Type: text/x-emacs-lisp, Size: 12953 bytes --]

;;; Code:
(require 'ert)
(setq ert-quiet nil
      ert-batch-print-level 10
      ert-batch-print-length 10
      ert-batch-backtrace-line-length t)

;;; utils/
(eval-and-compile
  (require 'help-fns)
  (defmacro utils/report-compilation-status (fun &optional feature)
    "Report on the compilation status of function FUN.
Optionally load FEATURE before reporting on compilation status."
    `(progn
       (eval-when-compile
         (when ',feature
           (require ',feature)))
       (let ((descstr (substring-no-properties
                       (with-output-to-string
                         (help-fns-function-description-header ',fun)))))
         (cons ',fun
               (cond
                ((string-search " native-compiled" descstr) 'native-compiled)
                ;; ((string-search " autoloaded" descstr) descstr)
                ((string-search " byte-compiled" descstr) 'byte-compiled)
                (t descstr))))))

  (defun utils/report-compilation-status/apply (fun &optional feature)
    "Invoke `utils/report-compilation-status' with FUN and FEATURE."
    (eval `(utils/report-compilation-status ,fun ,feature)))

  (require 'find-func)
  (defun utils/find-library-dir (feature)
    "Output directory where FEATURE resides."
    (directory-file-name
     (file-name-directory
      (find-library-name (symbol-name feature)))))

  (defun utils/report-failing-cases (cases)
    "From CASES, report failing tests.
Test failure are those where `utils/report-compilation-status' doesn't
report natively-compiled.  CASES is a list where each element are
ARGUMENTS for `utils/report-compilation-status'."
    (let ((results (mapcar (lambda (args)
                             (apply #'utils/report-compilation-status/apply args))
                           cases)))
      (seq-filter (lambda (x) (not (eq (cdr x) 'native-compiled)))
                  results))))

;;; hack/
(eval-and-compile
  (defun hack/new-load-path-that-can-make-v10-test-failures-pass ()
    "Return a list that can be used as the `load-path'.

The returned list is assured to have the entry for
share/emacs/<emacs-version>/lisp occur after the entry for
lisp/international (corresponding to the `mule-util' and
`ucs-normalize' failing test cases) and the entry for lisp/term
 (corresponding to the `term/internal' failing test case).

If the `load-path' is set to the returned value, all tests pass
in v10.  Notably, in non-Guix Emacs this isn't needed.  I.e., the
fact that the share/emacs/<emacs-version>/lisp entry precedes the
entries for `mule-util' and `ucs-normalize' is okay as is the
fact that the entry for `term/internal' is missing."
    (eval-when-compile
      (require 'find-func))
    ;; we'll ensure that the entry for share/emacs/<emacs-version>/lisp comes
    ;; after the lisp/international and lisp/term entries
    (let* ((new-load-path load-path)
           ;; add the missing entry for `term/internal'
           (_ (add-to-list 'new-load-path
                           (utils/find-library-dir 'term/internal)
                           ;; NOTE: we don't need to append; doing so simply to confirm that
                           ;; it's only the relative position wrt the
                           ;; share/emacs/<emacs-version>/lisp entry that matters.
                           t))
           (sitelisppath (format "/share/emacs/%s/lisp"
                                 emacs-version))
           (pathsuffix (seq-filter
                        (lambda (x)
                          (string-suffix-p sitelisppath x))
                        new-load-path))
           (pathprefix (seq-filter
                        (lambda (x)
                          (not
                           (string-suffix-p sitelisppath x)))
                        new-load-path)))
      (append pathprefix pathsuffix))))

;;; cases/
;; [[/usr/share/emacs/29.2/lisp]]
(eval-when-compile
  (defvar cases/eln-in-preloaded-dir nil
    "Functions that ought to be natively-compiled.")
  (setq cases/eln-in-preloaded-dir
        '((abbrev-mode)
          (backquote-process)
          (mode-line-widen)
          (buffer-menu)
          ;; burmese
          (button-mode)
          (byte-run-strip-symbol-positions)
          (case-table-get-table)
          (cconv-convert)
          ;; cham
          (use-default-char-width-table)
          ;; chinese
          (cl-generic-p)
          (cl-struct-define)
          (x-setup-function-keys)
          (encode-composition-rule)
          ;; cp51932
          (custom-declare-face)
          (minibuffer-prompt-properties--setter) ;; cus-start.el
          (custom-add-choice)
          ;; cyrillic
          ;; czech
          (debug-early)
          (display-table-slot disp-table) ;; disp-table.eln exists
          (dnd-open-file)
          (dos-mode25 dos-fns)    ;; dos-fns.eln exists
          ;; dos-vars
          (find-file-text dos-w32) ;; dos-w32.eln exists
          (dynamic-setting-handle-config-changed-event)
          (easy-menu-item-present-p)
          ;; ediff-hook
          (eldoc-mode)
          (electric-indent-mode)
          (elisp-mode-syntax-propertize)
          ;; english
          (getenv)
          (epa-file-find-file-hook)
          ;; ethiopic
          ;; eucjp-ms
          ;; european
          (face-list)
          (find-file-noselect)
          (fill-region)
          ;; float-sup
          (font-lock-change-mode)
          (font-lock-add-keywords)
          (fontset-plain-name)
          (format-read)
          (frame-edges)
          (fringe-mode)
          ;; georgian
          ;; greek
          ;; haiku-win
          ;; hebrew
          (help-quick)
          (image-type)
          (indent-region)
          (indian-compose-regexp)
          ;; indonesian
          (msdos-setup-keyboard term/internal) ;; internal.eln exists
          (isearch-abort)
          (iso-transl-set-language)
          ;; japanese
          (jit-lock-mode)
          (jka-compr-build-file-regexp)
          (keymap-global-set)
          ;; khmer
          ;; korean
          ;; lao
          (forward-sexp)
          (lisp-string-in-doc-position-p)
          (ls-lisp-set-options ls-lisp) ;; ls-lisp.eln exists
          (macroexp-compiling-p)
          (map-y-or-n-p)
          (menu-find-file-existing)
          (completion-boundaries)
          (egyptian-shape-grouping)
          (mouse-double-click-time)
          (convert-define-charset-argument)
          (coding-system-change-eol-conversion)
          ;; mule-conf.eln
          (store-substring mule-util) ;; mule-util.eln exists
          (mouse-wheel-change-button)
          (advice-function-mapc)
          (comment-string-strip)
          ;; (ns-handle-nxopen term/ns-win)
          (obarray-make)
          (oclosure-type)
          (forward-page)
          (sentence-end)
          (show-paren-function)
          ;; (msdos-face-setup term/pc-win)
          (pgtk-dnd-init-frame pgtk-dnd) ;; pgtk-dnd.eln exists
          ;; (pgtk-drag-n-drop term/pgtk-win)
          ;; philippine
          (prog-context-menu)
          (regexp-opt)
          (get-register)
          (query-replace-descr)
          (rfn-eshadow-setup-minibuffer)
          (read-multiple-choice)
          ;; romanian
          (scroll-bar-scale)
          (gui-select-text)
          (seq-first)
          (hack-read-symbol-shorthands)
          (next-error-find-buffer)
          ;; sinhala
          ;; slovak
          (exit-splash-screen)
          (buffer-local-boundp)
          (syntax-propertize-multiline)
          (tab-bar-mode)
          (tabulated-list-put-tag)
          ;; tai-viet
          (text-mode)
          ;; thai
          ;; tibetan
          (timer-activate)
          (tool-bar-mode)
          (tooltip-mode)
          (tty-color-desc)
          (ucs-normalize-hfs-nfd-comp-p ucs-normalize) ;; ucs-normalize.eln exists
          (uniquify-item-p)
          ;; utf-8-lang.eln
          (vc-mode)
          (emacs-version)
          ;; vietnamese
          ;; (w32-shell-name)
          ;; w32-vars.eln
          ;; (w32-handle-dropped-file 'term/w32-win)
          (define-widget)
          (window-right)
          (x-dnd-init-frame)
          (x-handle-no-bitmap-icon))))

;;; ERT tests
(ert-deftest 01-natively-compiled-features-passing-as-of-v10 ()
  "The 94 cases which pass for v10 patch series.
These cases are taken from .eln files that are located in the preloaded
directory for non-Guix Emacs."
  (eval-when-compile
    (let ((cases (seq-filter (lambda (x)
                               (not (memq (cadr x) '(mule-util term/internal ucs-normalize))))
                             cases/eln-in-preloaded-dir)))
      (should-not (utils/report-failing-cases cases)))))

(ert-deftest 02-natively-compiled-features-failing-as-of-v10 ()
  "The 3 cases which fail for v10 patch series on Guix Emacs.
These cases are taken from .eln files that are located in the preloaded
directory for non-Guix Emacs."
  :expected-result (if (getenv "GUIX_ENVIRONMENT")
                       :failed
                     :passed)
  (should-not
   (eval-when-compile
     (let ((cases (seq-filter (lambda (x)
                                (memq (cadr x) '(mule-util term/internal ucs-normalize)))
                              cases/eln-in-preloaded-dir)))
       (utils/report-failing-cases cases)))))

(ert-deftest 03-some-features-in-later-load-path-entries-are-still-natively-compiled ()
  "These cases pass as of v10 of the patch.
These cases share the fact that their directory entries occur in
the `load-path' after the $prefix/share/emacs/$emacs_version/lisp
entry.  This is something these cases have in common with the
three cases that are known to fail, however, unlike them these
succeed (i.e., natively-compiled variants are loaded)."
  (eval-when-compile
    (let* ((cases '((cl-position cl-seq)
                    (find-library-name find-func)
                    (log-edit log-edit)))
           (failing (utils/report-failing-cases cases))
           (features-loadpath-entries (mapcar #'utils/find-library-dir
                                              (mapcar #'cadr cases)))
           (features-entry-pos (mapcar (lambda (x)
                                         (cl-position
                                          (utils/find-library-dir (cadr x))
                                          load-path :test #'equal))
                                       cases))
           (share-emacs-lisp-entry-pos (cl-position "/share/emacs/29.2/lisp"
                                                    load-path
                                                    :test #'string-suffix-p)))
      (should-not failing)
      (should-not (seq-filter (lambda (x) (< x share-emacs-lisp-entry-pos))
                              features-entry-pos)))))

(ert-deftest 04-load-path-order-should-not-determine-natively-compiled-status ()
  "This seems like an invariant that would be useful to have.
It is unclear if this is guaranteed by upstream Emacs, but
observations seem consistent with it."
  :expected-result (if (getenv "GUIX_ENVIRONMENT")
                       :failed
                     :passed)
  (eval-when-compile
    (defvar original-load-path load-path))
  (let ((failures-prior-to-load-path-shuffle
         (eval-when-compile
           (utils/report-failing-cases cases/eln-in-preloaded-dir)))
        (failures-post-load-path-shuffle
         (eval-when-compile
           (progn
             (setq load-path
                   (hack/new-load-path-that-can-make-v10-test-failures-pass))
             (dolist (item cases/eln-in-preloaded-dir)
               (when (cadr item)
                 (unload-feature (cadr item))))
             (utils/report-failing-cases cases/eln-in-preloaded-dir)))))
    (should (equal failures-prior-to-load-path-shuffle
                   failures-post-load-path-shuffle))))

(ert-deftest 05-there-exists-load-path-order-where-all-tests-pass ()
  "Proof witness that the v10 failing cases relate to load-path ordering."
  (should-not (eval-when-compile
                (when (and (boundp 'original-load-path) original-load-path)
                  (setq load-path original-load-path)
                  (dolist (item cases/eln-in-preloaded-dir)
                    (when (cadr item)
                      (unload-feature (cadr item)))))
                (defvar original-load-path load-path)
                (setq load-path
                      (hack/new-load-path-that-can-make-v10-test-failures-pass))
                (utils/report-failing-cases cases/eln-in-preloaded-dir))))

;;; test-native-comp-p.el ends here

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 3/7] gnu: emacs: Check integrity of native-compiled files.
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
                     ` (5 preceding siblings ...)
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 2/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
@ 2024-02-24  6:18   ` Liliana Marie Prikler
  2024-03-04  7:13   ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Andrew Tropin via Guix-patches via
  7 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-24  6:18 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

In the previous commit, we've added a patch that potentially messes with
how built-in (especially preloaded) Lisp libraries are loaded.  Thus, we
might want to assert that these files still load fine, as reported when
querying the builtin documentation of functions provided by them.

* gnu/packages/aux-files/emacs/comp-integrity.el: New file.
* gnu/Makefile.am (dist_noinst_DATA): Register it here.
* gnu/packages/emacs.scm (emacs-no-x)[#:phases]: Add ‘validate-comp-integrity’.
---
 Makefile.am                                   |   1 +
 .../aux-files/emacs/comp-integrity.el         | 126 ++++++++++++++++++
 gnu/packages/emacs.scm                        |  13 +-
 3 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/aux-files/emacs/comp-integrity.el

diff --git a/Makefile.am b/Makefile.am
index d3b9532c7a..6837c4c87c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -421,6 +421,7 @@ dist_noinst_DATA =				\
 # Auxiliary files for packages.
 AUX_FILES =						\
   gnu/packages/aux-files/chromium/master-preferences.json		\
+  gnu/packages/aux-files/emacs/comp-integrity.el		\
   gnu/packages/aux-files/emacs/guix-emacs.el		\
   gnu/packages/aux-files/findclass.php			\
   gnu/packages/aux-files/guix.vim			\
diff --git a/gnu/packages/aux-files/emacs/comp-integrity.el b/gnu/packages/aux-files/emacs/comp-integrity.el
new file mode 100644
index 0000000000..ed6a348fed
--- /dev/null
+++ b/gnu/packages/aux-files/emacs/comp-integrity.el
@@ -0,0 +1,126 @@
+(require 'ert)
+
+(eval-when-compile
+  (require 'help-fns)
+
+  (defmacro expect-help (fun result &optional feature)
+    `(progn
+       (eval-when-compile (when ',feature
+                            (require ',feature)))
+
+       (ert-deftest ,(intern (concat "expect-" (symbol-name fun)
+                                     "-" (symbol-name result)))
+           ()
+           (should
+            (eq ',result
+                (let ((desc (substring-no-properties
+                             (with-output-to-string
+                               (help-fns-function-description-header ',fun)))))
+                  (cond ((string-search "native-compiled" desc) 'native)
+                        ((string-search "byte-compiled" desc) 'byte)
+                        ((string-search "built-in" desc) 'built-in)
+                        (t nil))))))))
+
+  (defmacro expect-native (fun &optional feature)
+    `(progn (expect-help ,fun native ,feature)))
+
+  (defmacro expect-builtin (fun &optional feature)
+    `(progn (expect-help ,fun built-in ,feature))))
+
+(expect-native abbrev-mode)
+(expect-native backquote-process)
+(expect-native mode-line-widen)
+(expect-native buffer-menu)
+(expect-native button-mode)
+(expect-native byte-run-strip-symbol-positions)
+(expect-native case-table-get-table)
+(expect-native cconv-convert)
+(expect-native use-default-char-width-table)
+(expect-native cl-generic-p)
+(expect-native cl-struct-define)
+(expect-native x-setup-function-keys)
+(expect-native encode-composition-rule)
+(expect-native custom-declare-face)
+(expect-native minibuffer-prompt-properties--setter)
+(expect-native custom-add-choice)
+(expect-native debug-early)
+(expect-native display-table-slot disp-table)
+(expect-native dnd-open-file)
+(expect-native dos-mode25 dos-fns)
+(expect-native find-file-text dos-w32)
+(expect-native dynamic-setting-handle-config-changed-event)
+(expect-native easy-menu-item-present-p)
+(expect-native eldoc-mode)
+(expect-native electric-indent-mode)
+(expect-native elisp-mode-syntax-propertize)
+(expect-native getenv)
+(expect-native epa-file-find-file-hook)
+(expect-native face-list)
+(expect-native find-file-noselect)
+(expect-native fill-region)
+(expect-native font-lock-change-mode)
+(expect-native font-lock-add-keywords)
+(expect-native fontset-plain-name)
+(expect-native format-read)
+(expect-native frame-edges)
+(expect-native fringe-mode)
+(expect-native help-quick)
+(expect-native image-type)
+(expect-native indent-region)
+(expect-native indian-compose-regexp)
+(expect-native msdos-setup-keyboard term/internal)
+(expect-native isearch-abort)
+(expect-native iso-transl-set-language)
+(expect-native jit-lock-mode)
+(expect-native jka-compr-build-file-regexp)
+(expect-native keymap-global-set)
+(expect-native forward-sexp)
+(expect-native lisp-string-in-doc-position-p)
+(expect-native ls-lisp-set-options ls-lisp)
+(expect-native macroexp-compiling-p)
+(expect-native map-y-or-n-p)
+(expect-native menu-find-file-existing)
+(expect-native completion-boundaries)
+(expect-native egyptian-shape-grouping)
+(expect-native mouse-double-click-time)
+(expect-native convert-define-charset-argument)
+(expect-native coding-system-change-eol-conversion)
+(expect-native store-substring mule-util)
+(expect-native mouse-wheel-change-button)
+(expect-native advice-function-mapc)
+(expect-native comment-string-strip)
+(expect-native obarray-make)
+(expect-native oclosure-type)
+(expect-native forward-page)
+(expect-native sentence-end)
+(expect-native show-paren-function)
+(expect-native pgtk-dnd-init-frame pgtk-dnd)
+(expect-native prog-context-menu)
+(expect-native regexp-opt)
+(expect-native get-register)
+(expect-native query-replace-descr)
+(expect-native rfn-eshadow-setup-minibuffer)
+(expect-native read-multiple-choice)
+(expect-native scroll-bar-scale)
+(expect-native gui-select-text)
+(expect-native seq-first)
+(expect-native hack-read-symbol-shorthands)
+(expect-native next-error-find-buffer)
+(expect-native exit-splash-screen)
+(expect-native buffer-local-boundp)
+(expect-native syntax-propertize-multiline)
+(expect-native tab-bar-mode)
+(expect-native tabulated-list-put-tag)
+(expect-native text-mode)
+(expect-native timer-activate)
+(expect-native tool-bar-mode)
+(expect-native tooltip-mode)
+(expect-native tty-color-desc)
+(expect-native ucs-normalize-hfs-nfd-comp-p ucs-normalize)
+(expect-native uniquify-item-p)
+(expect-native vc-mode)
+(expect-native emacs-version)
+(expect-native define-widget)
+(expect-native window-right)
+(expect-native x-dnd-init-frame)
+(expect-native x-handle-no-bitmap-icon)
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 182de0204d..f0200ad27c 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -380,7 +380,18 @@ (define-public emacs-no-x
                      "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
             (add-after 'build 'build-trampolines
               (lambda* (#:key make-flags #:allow-other-keys)
-                (apply invoke "make" "trampolines" make-flags)))))))
+                (apply invoke "make" "trampolines" make-flags)))
+            (add-after 'validate-runpath 'validate-comp-integrity
+              (lambda* (#:key outputs #:allow-other-keys)
+                (if #$(%current-target-system)
+                    (display "Cannot validate native-comp on cross builds.\n")
+                    (invoke
+                     (string-append (assoc-ref outputs "out") "/bin/emacs")
+                     "--batch"
+                     "--load"
+                     #$(local-file
+                        (search-auxiliary-file "emacs/comp-integrity.el"))
+                     "-f" "ert-run-tests-batch-and-exit"))))))))
     (inputs
      (modify-inputs (package-inputs emacs-minimal)
        (prepend gnutls
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (26 preceding siblings ...)
  2024-02-17 14:49 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Suhail via Guix-patches via
@ 2024-02-24  8:04 ` Liliana Marie Prikler
  2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
                     ` (7 more replies)
  2024-03-01 17:35 ` Suhail via Guix-patches via
  28 siblings, 8 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-02-24  8:04 UTC (permalink / raw)
  To: 67260; +Cc: Suhail, andrew, cox.katherine.e+guix, liliana.prikler

After a week of debugging the internals of how Emacs compiles, loads,
and dumps (!) its .eln-files, I finally came up with the perfectly
cursed mix that enables us to actually load *and* graft our natively
compiled packages with ease.

In unrelated news, I feel like I should wear a witch hat for faster
development cycles.

Liliana Marie Prikler (7):
  gnu: emacs: Build trampolines.
  gnu: emacs: Don't hash file names in native compilation.
  gnu: emacs: Check integrity of native-compiled files.
  gnu: emacs: Disable jit compilation.
  build-system: emacs: Compute relative file names.
  gnu: emacs-org: Fix native builds.
  gnu: emacs-magit: Fix native builds.

 Makefile.am                                   |   1 +
 gnu/local.mk                                  |   2 +
 .../aux-files/emacs/comp-integrity.el         | 126 +++++++
 gnu/packages/emacs-xyz.scm                    |  10 +-
 gnu/packages/emacs.scm                        |  20 +-
 .../emacs-disable-jit-compilation.patch       |  19 +
 .../emacs-native-comp-fix-filenames.patch     | 338 ++++++++++++++++++
 guix/build/emacs-utils.scm                    |   4 +-
 8 files changed, 516 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/aux-files/emacs/comp-integrity.el
 create mode 100644 gnu/packages/patches/emacs-disable-jit-compilation.patch
 create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch


base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
-- 
2.41.0





^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
                   ` (27 preceding siblings ...)
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
@ 2024-03-01 17:35 ` Suhail via Guix-patches via
  2024-03-01 19:40   ` bug#67260: " Liliana Marie Prikler
  28 siblings, 1 reply; 96+ messages in thread
From: Suhail via Guix-patches via @ 2024-03-01 17:35 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: cox.katherine.e+guix, 67260, Suhail, andrew

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> I finally came up with the perfectly cursed mix that enables us to
> actually load *and* graft our natively compiled packages with ease.

I can confirm that all the features being checked show up as natively
compiled as default - yay!

However, there seems to be some brittleness in whether or not
natively-compiled versions can be located.  Specifically, by reordering
the entries of the load-path, unloading previously loaded features, and
then reloading them some features will be reported as being
byte-compiled instead of natively-compiled.  Is my expectation that
reordering entries in the load-path shouldn't affect the
natively-compiled status misplaced?

From the previously shared test script, cases 01, 02, 03 pass now.
However, case
04-load-path-order-should-not-determine-natively-compiled-status still
fails.  Where in v10 it failed because 3 features previously reported as
being byte-compiled became natively-compiled, now it fails because the
same 3 features go from being natively-compiled to byte-compiled after
reordering load-path.  The features in question are the same ones that
were problematic in v10:

- term/internal
- mule-util
- ucs-normalize

My opinion: v11 seems to be an improvement over v10.  While I don't
believe that v11 is free of *all* bugs, I don't believe that that should
be a necessary pre-requisite before merging in.  I believe it would be
beneficial to merge v11 into emacs-team soon(ish) and for the emacs-team
branch to be merged into master soon thereafter.  A separate bug issue
can be created to track the peculiar dependence of the
native-compilation status on the ordering of entries in load-path.

Thoughts?

-- 
Suhail





^ permalink raw reply	[flat|nested] 96+ messages in thread

* bug#67260: [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2024-03-01 17:35 ` Suhail via Guix-patches via
@ 2024-03-01 19:40   ` Liliana Marie Prikler
  2024-03-07  8:55     ` [bug#67260] " Andrew Tropin via Guix-patches via
  0 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-03-01 19:40 UTC (permalink / raw)
  To: Suhail; +Cc: cox.katherine.e+guix, 67260-done, andrew

Am Freitag, dem 01.03.2024 um 17:35 +0000 schrieb Suhail:
> Is my expectation that reordering entries in the load-path shouldn't
> affect the natively-compiled status misplaced?
Yes.  We take the first prefix match and compute the file names from
there.  This is consistent with emacs matching the first file it finds
on the load-path.  You can't do much better, because your load path may
only be partially specified at compile time and later expanded with
normal-top-level-add-to-load-path.

> Where in v10 it failed because 3 features previously reported as
> being byte-compiled became natively-compiled, now it fails because
> the same 3 features go from being natively-compiled to byte-compiled
> after reordering load-path.
The expectation that load-path order does not matter is imho quite
unfounded.  Note that we do ship the actually important test cases with
v11.

> A separate bug issue can be created to track the peculiar dependence
> of the native-compilation status on the ordering of entries in load-
> path.
Well, to me it's not peculiar as I wrote the code, but I'm not sure how
familiar you are with Emacs' internals.  If you feel up for it, go for
it, but I'd rather tackle other problems related to our emacs
ecosystem.

Anyway, as you said, I'm pushing this now so that we can do a double
merge dance (i.e. master → emacs-team, then request the other way)
starting early tomorrow.

Cheers




^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
                     ` (6 preceding siblings ...)
  2024-02-24  6:18   ` [bug#67260] [PATCH emacs-team v11 3/7] gnu: emacs: Check integrity of native-compiled files Liliana Marie Prikler
@ 2024-03-04  7:13   ` Andrew Tropin via Guix-patches via
  2024-03-04 19:59     ` Liliana Marie Prikler
  7 siblings, 1 reply; 96+ messages in thread
From: Andrew Tropin via Guix-patches via @ 2024-03-04  7:13 UTC (permalink / raw)
  To: Liliana Marie Prikler, 67260
  Cc: cox.katherine.e+guix, liliana.prikler, Suhail

[-- Attachment #1: Type: text/plain, Size: 5818 bytes --]

On 2024-02-24 09:04, Liliana Marie Prikler wrote:

> After a week of debugging the internals of how Emacs compiles, loads,
> and dumps (!) its .eln-files, I finally came up with the perfectly
> cursed mix that enables us to actually load *and* graft our natively
> compiled packages with ease.
>
> In unrelated news, I feel like I should wear a witch hat for faster
> development cycles.
>
> Liliana Marie Prikler (7):
>   gnu: emacs: Build trampolines.
>   gnu: emacs: Don't hash file names in native compilation.
>   gnu: emacs: Check integrity of native-compiled files.
>   gnu: emacs: Disable jit compilation.
>   build-system: emacs: Compute relative file names.
>   gnu: emacs-org: Fix native builds.
>   gnu: emacs-magit: Fix native builds.
>
>  Makefile.am                                   |   1 +
>  gnu/local.mk                                  |   2 +
>  .../aux-files/emacs/comp-integrity.el         | 126 +++++++
>  gnu/packages/emacs-xyz.scm                    |  10 +-
>  gnu/packages/emacs.scm                        |  20 +-
>  .../emacs-disable-jit-compilation.patch       |  19 +
>  .../emacs-native-comp-fix-filenames.patch     | 338 ++++++++++++++++++
>  guix/build/emacs-utils.scm                    |   4 +-
>  8 files changed, 516 insertions(+), 4 deletions(-)
>  create mode 100644 gnu/packages/aux-files/emacs/comp-integrity.el
>  create mode 100644 gnu/packages/patches/emacs-disable-jit-compilation.patch
>  create mode 100644 gnu/packages/patches/emacs-native-comp-fix-filenames.patch
>
>
> base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660

For usual emacs it seems to work, (require 'magit) with clean eln cache
doesn't trigger any builds. For emacs-pgtk it fails to build emacs:

guix time-machine --url='https://git.guix-patches.cbaines.net/git/guix-patches' --branch=issue-67260 --disable-authentication -- shell emacs-pgtk emacs-magit --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q

--8<---------------cut here---------------start------------->8---
   passed  94/97  expect-window-right-native (0.002412 sec)
Test expect-x-dnd-init-frame-native backtrace:
  signal(void-function (x-dnd-init-frame))
  apply(signal (void-function (x-dnd-init-frame)))
  (setq value-477 (apply fn-475 args-476))
  (unwind-protect (setq value-477 (apply fn-475 args-476)) (setq form-
  (if (unwind-protect (setq value-477 (apply fn-475 args-476)) (setq f
  (let (form-description-479) (if (unwind-protect (setq value-477 (app
  (let ((value-477 'ert-form-evaluation-aborted-478)) (let (form-descr
  (let* ((fn-475 #'eq) (args-476 (condition-case err (let ((signal-hoo
  (lambda nil (let* ((fn-475 #'eq) (args-476 (condition-case err (let 
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name expect-x-dnd-init-frame-native :docum
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-map
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3
  command-line()
  normal-top-level()
Test expect-x-dnd-init-frame-native condition:
    (void-function x-dnd-init-frame)
   FAILED  95/97  expect-x-dnd-init-frame-native (0.000082 sec) at ../../../gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el:1
Test expect-x-handle-no-bitmap-icon-native backtrace:
  signal(void-function (x-handle-no-bitmap-icon))
  apply(signal (void-function (x-handle-no-bitmap-icon)))
  (setq value-482 (apply fn-480 args-481))
  (unwind-protect (setq value-482 (apply fn-480 args-481)) (setq form-
  (if (unwind-protect (setq value-482 (apply fn-480 args-481)) (setq f
  (let (form-description-484) (if (unwind-protect (setq value-482 (app
  (let ((value-482 'ert-form-evaluation-aborted-483)) (let (form-descr
  (let* ((fn-480 #'eq) (args-481 (condition-case err (let ((signal-hoo
  (lambda nil (let* ((fn-480 #'eq) (args-481 (condition-case err (let 
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name expect-x-handle-no-bitmap-icon-native
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-map
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3
  command-line()
  normal-top-level()
Test expect-x-handle-no-bitmap-icon-native condition:
    (void-function x-handle-no-bitmap-icon)
   FAILED  96/97  expect-x-handle-no-bitmap-icon-native (0.000111 sec) at ../../../gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el:1
   passed  97/97  expect-x-setup-function-keys-native (0.004165 sec)

Ran 97 tests, 95 results as expected, 2 unexpected (2024-03-02 05:46:28+0000, 0.361428 sec)

2 unexpected results:
   FAILED  expect-x-dnd-init-frame-native
   FAILED  expect-x-handle-no-bitmap-icon-native

error: in phase 'validate-comp-integrity': uncaught exception:
%exception #<&invoke-error program: "/gnu/store/m01icx06dw1vs1krcj4jbmw71nv430dp-emacs-pgtk-29.2/bin/emacs" arguments: ("--batch" "--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el" "-f" "ert-run-tests-batch-and-exit") exit-status: 1 term-signal: #f stop-signal: #f> 
phase `validate-comp-integrity' failed after 0.5 seconds
command "/gnu/store/m01icx06dw1vs1krcj4jbmw71nv430dp-emacs-pgtk-29.2/bin/emacs" "--batch" "--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el" "-f" "ert-run-tests-batch-and-exit" failed with status 1
--8<---------------cut here---------------end--------------->8---

Thank you very much for working on it!

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2024-03-04  7:13   ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Andrew Tropin via Guix-patches via
@ 2024-03-04 19:59     ` Liliana Marie Prikler
  0 siblings, 0 replies; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-03-04 19:59 UTC (permalink / raw)
  To: Andrew Tropin, 67260; +Cc: cox.katherine.e+guix, Suhail

[-- Attachment #1: Type: text/plain, Size: 6529 bytes --]

Am Montag, dem 04.03.2024 um 10:13 +0300 schrieb Andrew Tropin:
> On 2024-02-24 09:04, Liliana Marie Prikler wrote:
> 
> > After a week of debugging the internals of how Emacs compiles,
> > loads,
> > and dumps (!) its .eln-files, I finally came up with the perfectly
> > cursed mix that enables us to actually load *and* graft our
> > natively
> > compiled packages with ease.
> > 
> > In unrelated news, I feel like I should wear a witch hat for faster
> > development cycles.
> > 
> > Liliana Marie Prikler (7):
> >   gnu: emacs: Build trampolines.
> >   gnu: emacs: Don't hash file names in native compilation.
> >   gnu: emacs: Check integrity of native-compiled files.
> >   gnu: emacs: Disable jit compilation.
> >   build-system: emacs: Compute relative file names.
> >   gnu: emacs-org: Fix native builds.
> >   gnu: emacs-magit: Fix native builds.
> > 
> >  Makefile.am                                   |   1 +
> >  gnu/local.mk                                  |   2 +
> >  .../aux-files/emacs/comp-integrity.el         | 126 +++++++
> >  gnu/packages/emacs-xyz.scm                    |  10 +-
> >  gnu/packages/emacs.scm                        |  20 +-
> >  .../emacs-disable-jit-compilation.patch       |  19 +
> >  .../emacs-native-comp-fix-filenames.patch     | 338
> > ++++++++++++++++++
> >  guix/build/emacs-utils.scm                    |   4 +-
> >  8 files changed, 516 insertions(+), 4 deletions(-)
> >  create mode 100644 gnu/packages/aux-files/emacs/comp-integrity.el
> >  create mode 100644 gnu/packages/patches/emacs-disable-jit-
> > compilation.patch
> >  create mode 100644 gnu/packages/patches/emacs-native-comp-fix-
> > filenames.patch
> > 
> > 
> > base-commit: aae61f54ff6acf5cc0e0355dc85babf29f625660
> 
> For usual emacs it seems to work, (require 'magit) with clean eln
> cache
> doesn't trigger any builds. For emacs-pgtk it fails to build emacs:
> 
> guix time-machine --
> url='https://git.guix-patches.cbaines.net/git/guix-patches' --
> branch=issue-67260 --disable-authentication -- shell emacs-pgtk
> emacs-magit --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q
> 
> --8<---------------cut here---------------start------------->8---
>    passed  94/97  expect-window-right-native (0.002412 sec)
> Test expect-x-dnd-init-frame-native backtrace:
>   signal(void-function (x-dnd-init-frame))
>   apply(signal (void-function (x-dnd-init-frame)))
>   (setq value-477 (apply fn-475 args-476))
>   (unwind-protect (setq value-477 (apply fn-475 args-476)) (setq
> form-
>   (if (unwind-protect (setq value-477 (apply fn-475 args-476)) (setq
> f
>   (let (form-description-479) (if (unwind-protect (setq value-477
> (app
>   (let ((value-477 'ert-form-evaluation-aborted-478)) (let (form-
> descr
>   (let* ((fn-475 #'eq) (args-476 (condition-case err (let ((signal-
> hoo
>   (lambda nil (let* ((fn-475 #'eq) (args-476 (condition-case err (let
>   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-
> test
>   ert-run-test(#s(ert-test :name expect-x-dnd-init-frame-native
> :docum
>   ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-
> map
>   ert-run-tests(t #f(compiled-function (event-type &rest event-args)
> #
>   ert-run-tests-batch(nil)
>   ert-run-tests-batch-and-exit()
>   command-line-1(("--load"
> "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3
>   command-line()
>   normal-top-level()
> Test expect-x-dnd-init-frame-native condition:
>     (void-function x-dnd-init-frame)
>    FAILED  95/97  expect-x-dnd-init-frame-native (0.000082 sec) at
> ../../../gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-
> integrity.el:1
> Test expect-x-handle-no-bitmap-icon-native backtrace:
>   signal(void-function (x-handle-no-bitmap-icon))
>   apply(signal (void-function (x-handle-no-bitmap-icon)))
>   (setq value-482 (apply fn-480 args-481))
>   (unwind-protect (setq value-482 (apply fn-480 args-481)) (setq
> form-
>   (if (unwind-protect (setq value-482 (apply fn-480 args-481)) (setq
> f
>   (let (form-description-484) (if (unwind-protect (setq value-482
> (app
>   (let ((value-482 'ert-form-evaluation-aborted-483)) (let (form-
> descr
>   (let* ((fn-480 #'eq) (args-481 (condition-case err (let ((signal-
> hoo
>   (lambda nil (let* ((fn-480 #'eq) (args-481 (condition-case err (let
>   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-
> test
>   ert-run-test(#s(ert-test :name expect-x-handle-no-bitmap-icon-
> native
>   ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-
> map
>   ert-run-tests(t #f(compiled-function (event-type &rest event-args)
> #
>   ert-run-tests-batch(nil)
>   ert-run-tests-batch-and-exit()
>   command-line-1(("--load"
> "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3
>   command-line()
>   normal-top-level()
> Test expect-x-handle-no-bitmap-icon-native condition:
>     (void-function x-handle-no-bitmap-icon)
>    FAILED  96/97  expect-x-handle-no-bitmap-icon-native (0.000111
> sec) at ../../../gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-
> integrity.el:1
>    passed  97/97  expect-x-setup-function-keys-native (0.004165 sec)
> 
> Ran 97 tests, 95 results as expected, 2 unexpected (2024-03-02
> 05:46:28+0000, 0.361428 sec)
> 
> 2 unexpected results:
>    FAILED  expect-x-dnd-init-frame-native
>    FAILED  expect-x-handle-no-bitmap-icon-native
> 
> error: in phase 'validate-comp-integrity': uncaught exception:
> %exception #<&invoke-error program:
> "/gnu/store/m01icx06dw1vs1krcj4jbmw71nv430dp-emacs-pgtk-
> 29.2/bin/emacs" arguments: ("--batch" "--load"
> "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el" "-f"
> "ert-run-tests-batch-and-exit") exit-status: 1 term-signal: #f stop-
> signal: #f> 
> phase `validate-comp-integrity' failed after 0.5 seconds
> command "/gnu/store/m01icx06dw1vs1krcj4jbmw71nv430dp-emacs-pgtk-
> 29.2/bin/emacs" "--batch" "--load"
> "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el" "-f"
> "ert-run-tests-batch-and-exit" failed with status 1
> --8<---------------cut here---------------end--------------->8---
> 
> Thank you very much for working on it!
Try the attached patch and let me know if there's other failing
Emacsen.

Cheers

[-- Attachment #2: 0001-aux-files-comp-integrity-Adjust-for-emacs-pgtk.patch --]
[-- Type: text/x-patch, Size: 1341 bytes --]

From 19fc252ab7e86ad1443a8d16f68467c61bf23179 Mon Sep 17 00:00:00 2001
Message-ID: <19fc252ab7e86ad1443a8d16f68467c61bf23179.1709582330.git.liliana.prikler@gmail.com>
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
Date: Mon, 4 Mar 2024 20:54:49 +0100
Subject: [PATCH] aux-files: comp-integrity: Adjust for emacs-pgtk.

* gnu/packages/aux-files/emacs/comp-integrity.el (x-dnd-init-frame): Require
x-dnd.
(x-handle-no-bitmap-icon): Only test this if it's bound.
---
 gnu/packages/aux-files/emacs/comp-integrity.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/aux-files/emacs/comp-integrity.el b/gnu/packages/aux-files/emacs/comp-integrity.el
index 9692d9bf97..191e2ddb98 100644
--- a/gnu/packages/aux-files/emacs/comp-integrity.el
+++ b/gnu/packages/aux-files/emacs/comp-integrity.el
@@ -125,5 +125,6 @@
 (expect-native emacs-version)
 (expect-native define-widget)
 (expect-native window-right)
-(expect-native x-dnd-init-frame)
-(expect-native x-handle-no-bitmap-icon)
+(expect-native x-dnd-init-frame x-dnd)
+(and (boundp 'x-handle-no-bitmap-icon)
+     (expect-native x-handle-no-bitmap-icon))

base-commit: 3d4fc910f73220f47e5f2459853333a7c83c5d1d
prerequisite-patch-id: 96ae24a3419fccea142d2726b11ff20e798bfbd0
prerequisite-patch-id: e908853224bffffa285088dc6e31abaf12c12e02
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2024-03-01 19:40   ` bug#67260: " Liliana Marie Prikler
@ 2024-03-07  8:55     ` Andrew Tropin via Guix-patches via
  2024-03-07 17:52       ` Liliana Marie Prikler
  0 siblings, 1 reply; 96+ messages in thread
From: Andrew Tropin via Guix-patches via @ 2024-03-07  8:55 UTC (permalink / raw)
  To: Liliana Marie Prikler, Suhail; +Cc: cox.katherine.e+guix, 67260-done

[-- Attachment #1: Type: text/plain, Size: 5497 bytes --]

On 2024-03-01 20:40, Liliana Marie Prikler wrote:

> Am Freitag, dem 01.03.2024 um 17:35 +0000 schrieb Suhail:
>> Is my expectation that reordering entries in the load-path shouldn't
>> affect the natively-compiled status misplaced?
> Yes.  We take the first prefix match and compute the file names from
> there.  This is consistent with emacs matching the first file it finds
> on the load-path.  You can't do much better, because your load path may
> only be partially specified at compile time and later expanded with
> normal-top-level-add-to-load-path.
>
>> Where in v10 it failed because 3 features previously reported as
>> being byte-compiled became natively-compiled, now it fails because
>> the same 3 features go from being natively-compiled to byte-compiled
>> after reordering load-path.
> The expectation that load-path order does not matter is imho quite
> unfounded.  Note that we do ship the actually important test cases with
> v11.
>
>> A separate bug issue can be created to track the peculiar dependence
>> of the native-compilation status on the ordering of entries in load-
>> path.
> Well, to me it's not peculiar as I wrote the code, but I'm not sure how
> familiar you are with Emacs' internals.  If you feel up for it, go for
> it, but I'd rather tackle other problems related to our emacs
> ecosystem.
>
> Anyway, as you said, I'm pushing this now so that we can do a double
> merge dance (i.e. master → emacs-team, then request the other way)
> starting early tomorrow.

Hi Liliana! 

guix time-machine --branch=emacs-team -- shell emacs-pgtk emacs-magit --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q

fails with:

--8<---------------cut here---------------start------------->8---
   passed  94/97  expect-window-right-native (0.002334 sec)
Test expect-x-dnd-init-frame-native backtrace:
  signal(void-function (x-dnd-init-frame))
  apply(signal (void-function (x-dnd-init-frame)))
  (setq value-477 (apply fn-475 args-476))
  (unwind-protect (setq value-477 (apply fn-475 args-476)) (setq form-
  (if (unwind-protect (setq value-477 (apply fn-475 args-476)) (setq f
  (let (form-description-479) (if (unwind-protect (setq value-477 (app
  (let ((value-477 'ert-form-evaluation-aborted-478)) (let (form-descr
  (let* ((fn-475 #'eq) (args-476 (condition-case err (let ((signal-hoo
  (lambda nil (let* ((fn-475 #'eq) (args-476 (condition-case err (let 
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name expect-x-dnd-init-frame-native :docum
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-map
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3
  command-line()
  normal-top-level()
Test expect-x-dnd-init-frame-native condition:
    (void-function x-dnd-init-frame)
   FAILED  95/97  expect-x-dnd-init-frame-native (0.000067 sec) at ../../../gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el:1
Test expect-x-handle-no-bitmap-icon-native backtrace:
  signal(void-function (x-handle-no-bitmap-icon))
  apply(signal (void-function (x-handle-no-bitmap-icon)))
  (setq value-482 (apply fn-480 args-481))
  (unwind-protect (setq value-482 (apply fn-480 args-481)) (setq form-
  (if (unwind-protect (setq value-482 (apply fn-480 args-481)) (setq f
  (let (form-description-484) (if (unwind-protect (setq value-482 (app
  (let ((value-482 'ert-form-evaluation-aborted-483)) (let (form-descr
  (let* ((fn-480 #'eq) (args-481 (condition-case err (let ((signal-hoo
  (lambda nil (let* ((fn-480 #'eq) (args-481 (condition-case err (let 
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name expect-x-handle-no-bitmap-icon-native
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-map
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3
  command-line()
  normal-top-level()
Test expect-x-handle-no-bitmap-icon-native condition:
    (void-function x-handle-no-bitmap-icon)
   FAILED  96/97  expect-x-handle-no-bitmap-icon-native (0.000103 sec) at ../../../gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el:1
   passed  97/97  expect-x-setup-function-keys-native (0.002261 sec)

Ran 97 tests, 95 results as expected, 2 unexpected (2024-03-07 08:50:40+0000, 0.327688 sec)

2 unexpected results:
   FAILED  expect-x-dnd-init-frame-native
   FAILED  expect-x-handle-no-bitmap-icon-native

error: in phase 'validate-comp-integrity': uncaught exception:
%exception #<&invoke-error program: "/gnu/store/lkqd9kx4nb4y6dw58bn8gqhid6q51i30-emacs-pgtk-29.2/bin/emacs" arguments: ("--batch" "--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el" "-f" "ert-run-tests-batch-and-exit") exit-status: 1 term-signal: #f stop-signal: #f> 
phase `validate-comp-integrity' failed after 0.5 seconds
command "/gnu/store/lkqd9kx4nb4y6dw58bn8gqhid6q51i30-emacs-pgtk-29.2/bin/emacs" "--batch" "--load" "/gnu/store/ql9y5r4ydz4dl8jjf2b2bz9fqhxmbm3x-comp-integrity.el" "-f" "ert-run-tests-batch-and-exit" failed with status 1
--8<---------------cut here---------------end--------------->8---

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2024-03-07  8:55     ` [bug#67260] " Andrew Tropin via Guix-patches via
@ 2024-03-07 17:52       ` Liliana Marie Prikler
  2024-03-08  9:20         ` Andrew Tropin via Guix-patches via
  0 siblings, 1 reply; 96+ messages in thread
From: Liliana Marie Prikler @ 2024-03-07 17:52 UTC (permalink / raw)
  To: Andrew Tropin, Suhail; +Cc: cox.katherine.e+guix, 67260-done

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

Am Donnerstag, dem 07.03.2024 um 11:55 +0300 schrieb Andrew Tropin:
> Hi Liliana! 
> 
> guix time-machine --branch=emacs-team -- shell emacs-pgtk emacs-magit
> --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q
> 
> fails with:
> 
> --8<---------------cut here---------------start------------->8---
> [...]
> --8<---------------cut here---------------end--------------->8---
I already sent you a patch for that.  Attaching it again.



[-- Attachment #2: 0001-aux-files-comp-integrity-Adjust-for-emacs-pgtk.patch --]
[-- Type: text/x-patch, Size: 1341 bytes --]

From 19fc252ab7e86ad1443a8d16f68467c61bf23179 Mon Sep 17 00:00:00 2001
Message-ID: <19fc252ab7e86ad1443a8d16f68467c61bf23179.1709582330.git.liliana.prikler@gmail.com>
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
Date: Mon, 4 Mar 2024 20:54:49 +0100
Subject: [PATCH] aux-files: comp-integrity: Adjust for emacs-pgtk.

* gnu/packages/aux-files/emacs/comp-integrity.el (x-dnd-init-frame): Require
x-dnd.
(x-handle-no-bitmap-icon): Only test this if it's bound.
---
 gnu/packages/aux-files/emacs/comp-integrity.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/aux-files/emacs/comp-integrity.el b/gnu/packages/aux-files/emacs/comp-integrity.el
index 9692d9bf97..191e2ddb98 100644
--- a/gnu/packages/aux-files/emacs/comp-integrity.el
+++ b/gnu/packages/aux-files/emacs/comp-integrity.el
@@ -125,5 +125,6 @@
 (expect-native emacs-version)
 (expect-native define-widget)
 (expect-native window-right)
-(expect-native x-dnd-init-frame)
-(expect-native x-handle-no-bitmap-icon)
+(expect-native x-dnd-init-frame x-dnd)
+(and (boundp 'x-handle-no-bitmap-icon)
+     (expect-native x-handle-no-bitmap-icon))

base-commit: 3d4fc910f73220f47e5f2459853333a7c83c5d1d
prerequisite-patch-id: 96ae24a3419fccea142d2726b11ff20e798bfbd0
prerequisite-patch-id: e908853224bffffa285088dc6e31abaf12c12e02
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 96+ messages in thread

* [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio!
  2024-03-07 17:52       ` Liliana Marie Prikler
@ 2024-03-08  9:20         ` Andrew Tropin via Guix-patches via
  0 siblings, 0 replies; 96+ messages in thread
From: Andrew Tropin via Guix-patches via @ 2024-03-08  9:20 UTC (permalink / raw)
  To: Liliana Marie Prikler, Suhail; +Cc: cox.katherine.e+guix, 67260-done

[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]

On 2024-03-07 18:52, Liliana Marie Prikler wrote:

> Am Donnerstag, dem 07.03.2024 um 11:55 +0300 schrieb Andrew Tropin:
>> Hi Liliana! 
>> 
>> guix time-machine --branch=emacs-team -- shell emacs-pgtk emacs-magit
>> --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q
>> 
>> fails with:
>> 
>> --8<---------------cut here---------------start------------->8---
>> [...]
>> --8<---------------cut here---------------end--------------->8---
> I already sent you a patch for that.  Attaching it again.
>
>
> From 19fc252ab7e86ad1443a8d16f68467c61bf23179 Mon Sep 17 00:00:00 2001
> Message-ID: <19fc252ab7e86ad1443a8d16f68467c61bf23179.1709582330.git.liliana.prikler@gmail.com>
> From: Liliana Marie Prikler <liliana.prikler@gmail.com>
> Date: Mon, 4 Mar 2024 20:54:49 +0100
> Subject: [PATCH] aux-files: comp-integrity: Adjust for emacs-pgtk.
>
> * gnu/packages/aux-files/emacs/comp-integrity.el (x-dnd-init-frame): Require
> x-dnd.
> (x-handle-no-bitmap-icon): Only test this if it's bound.
> ---
>  gnu/packages/aux-files/emacs/comp-integrity.el | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/packages/aux-files/emacs/comp-integrity.el b/gnu/packages/aux-files/emacs/comp-integrity.el
> index 9692d9bf97..191e2ddb98 100644
> --- a/gnu/packages/aux-files/emacs/comp-integrity.el
> +++ b/gnu/packages/aux-files/emacs/comp-integrity.el
> @@ -125,5 +125,6 @@
>  (expect-native emacs-version)
>  (expect-native define-widget)
>  (expect-native window-right)
> -(expect-native x-dnd-init-frame)
> -(expect-native x-handle-no-bitmap-icon)
> +(expect-native x-dnd-init-frame x-dnd)
> +(and (boundp 'x-handle-no-bitmap-icon)
> +     (expect-native x-handle-no-bitmap-icon))
>
> base-commit: 3d4fc910f73220f47e5f2459853333a7c83c5d1d
> prerequisite-patch-id: 96ae24a3419fccea142d2726b11ff20e798bfbd0
> prerequisite-patch-id: e908853224bffffa285088dc6e31abaf12c12e02

Yep, with this patch it seems to build correctly.

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 96+ messages in thread

end of thread, other threads:[~2024-03-08  9:21 UTC | newest]

Thread overview: 96+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-18 13:42 [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Liliana Marie Prikler
2023-11-18 13:38 ` [bug#67260] [PATCH emacs-team 2/2] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2023-11-18 15:44 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Andrew Tropin
2023-11-18 15:51   ` Liliana Marie Prikler
2023-11-22 12:09 ` Mekeor Melire
2023-11-22 17:39   ` Liliana Marie Prikler
2023-11-25 11:13 ` [bug#67260] [PATCH emacs-team v3 1/3] gnu: emacs: Build trampolines Liliana Marie Prikler
2023-11-25 11:13   ` [bug#67260] [PATCH emacs-team v3 3/3] build-system: emacs: Compute relative file names Liliana Marie Prikler
2023-11-25 11:13   ` [bug#67260] [PATCH emacs-team v3 2/3] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-01-18  5:55 ` [bug#67260] [PATCH emacs-team 0/2] Think ahead when compiling Suhail via Guix-patches via
2024-01-21 12:12 ` [bug#67260] [PATCH v5 1/6] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v5 2/6] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v5 5/6] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v5 3/6] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v5 4/6] gnu: emacs-org: Fix native builds Liliana Marie Prikler
2024-01-21 14:09   ` [bug#67260] [PATCH v5 6/6] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-01-22  4:16 ` Suhail via Guix-patches via
2024-01-22  4:36 ` Suhail via Guix-patches via
2024-01-22 20:21 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v6 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v6 5/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v6 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v6 4/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v6 6/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-01-21 14:09   ` [bug#67260] [PATCH v6 7/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-01-22 20:21 ` [bug#67260] [PATCH v7 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-01-21 14:09   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-01-22 20:21 ` [bug#67260] [PATCH v8 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v8 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v8 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v8 6/7] gnu: emacs-org: " Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v8 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-01-21 12:12   ` [bug#67260] [PATCH v8 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-01-21 14:09   ` [bug#67260] [PATCH v8 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-01-25 23:53 ` [bug#67260] [PATCH v6 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Suhail via Guix-patches via
2024-01-26  7:49 ` Suhail via Guix-patches via
2024-01-26  8:20 ` Suhail via Guix-patches via
2024-01-26 22:45 ` Suhail via Guix-patches via
2024-01-27 15:36 ` Suhail via Guix-patches via
2024-01-27 16:24 ` Suhail via Guix-patches via
2024-01-27 17:15 ` Suhail via Guix-patches via
2024-01-27 19:39 ` Suhail via Guix-patches via
2024-01-28  0:13 ` Suhail via Guix-patches via
2024-01-28  0:18 ` Suhail via Guix-patches via
2024-01-28 16:17 ` Suhail via Guix-patches via
2024-02-13 18:30 ` [bug#67260] [PATCH v7 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v7 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v7 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v7 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v7 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v7 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v7 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-02-13 18:30     ` [bug#67260] [PATCH v9 " Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH v9 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
2024-02-14  0:56 ` [bug#67260] [PATCH emacs-team v9*] Think ahead when compiling Suhail via Guix-patches via
2024-02-14  8:41 ` [bug#67260] [PATCH emacs-team v9*] Test for AOT native-comp Suhail via Guix-patches via
2024-02-16 15:09 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 1/7] gnu: emacs: Wrap EMACSNATIVELOADPATH Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 3/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 2/7] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v10 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
2024-02-17 14:49 ` [bug#67260] [PATCH emacs-team v10 0/7] Preload most of the things Suhail via Guix-patches via
2024-02-17 15:15   ` Liliana Marie Prikler
2024-02-18  0:56     ` Suhail via Guix-patches via
2024-02-18  9:19       ` Liliana Marie Prikler
2024-02-19 21:42         ` Suhail via Guix-patches via
2024-02-20 17:51           ` Liliana Marie Prikler
2024-02-20 18:41             ` Suhail via Guix-patches via
2024-02-24  8:04 ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 7/7] gnu: emacs-magit: Fix native builds Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 5/7] build-system: emacs: Compute relative file names Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 1/7] gnu: emacs: Build trampolines Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 6/7] gnu: emacs-org: Fix native builds Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 4/7] gnu: emacs: Disable jit compilation Liliana Marie Prikler
2024-02-13 18:30   ` [bug#67260] [PATCH emacs-team v11 2/7] gnu: emacs: Don't hash file names in native compilation Liliana Marie Prikler
2024-02-24  6:18   ` [bug#67260] [PATCH emacs-team v11 3/7] gnu: emacs: Check integrity of native-compiled files Liliana Marie Prikler
2024-03-04  7:13   ` [bug#67260] [PATCH emacs-team v11 0/7] You thought it was term/internal.el, but it was me, Dio! Andrew Tropin via Guix-patches via
2024-03-04 19:59     ` Liliana Marie Prikler
2024-03-01 17:35 ` Suhail via Guix-patches via
2024-03-01 19:40   ` bug#67260: " Liliana Marie Prikler
2024-03-07  8:55     ` [bug#67260] " Andrew Tropin via Guix-patches via
2024-03-07 17:52       ` Liliana Marie Prikler
2024-03-08  9:20         ` Andrew Tropin via Guix-patches via

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).