Subject: [bug#67260] [PATCH v4 1/5] gnu: emacs: Build trampolines.

From: Liliana Marie Prikler <[email-masked]>
Date: Wed, 27 Dec 2023 21:03:15 +0100

Am Mittwoch, dem 27.12.2023 um 21:27 +0300 schrieb Andrew Tropin:
> On 2023-12-27 17:40, Liliana Marie Prikler wrote:
> 
> > Am Mittwoch, dem 27.12.2023 um 14:00 +0300 schrieb Andrew Tropin:
> > > On 2023-11-25 12:13, Liliana Marie Prikler wrote:
> > > 
> > > > * 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
> > > 
> > > Applied the patch series v4 to emacs-team branch, removed all eln
> > > files
> > > in ~/.cache/emacs and ~/.config/emacs, executed
> > > 
> > > --8<---------------cut here---------------start------------->8---
> > > ./pre-inst-env guix shell emacs-pgtk emacs-magit \
> > > --pure -E '.*GTK.*|.*XDG.*|.*DISPLAY.*' -- emacs -Q
> > > # M-S-: (require 'magit) RET
> > > --8<---------------cut here---------------end--------------->8---
> > You're missing --with-input=emacs-minimal=emacs.  You are not
> > natively compiling emacs-magit atm.
> 
> Right, thank you!
Turns out you also need to do this with emacs-no-x due to emacs-libgit.

Friendly reminder that we don't have build system/packaging utilities
to easily replace emacs versions yet, so magit might not have been the
wisest choice to showcase here.

More worryingly, it appears you're recompiling Emacs itself here.  This
should not be happening.  However, it turns out that your eln-cache is
always first on the native load path and thus already compiled files
won't be found.¹  Try adding 
  --eval='(setq native-comp-jit-compilation nil)'
and see whether you can load natively compiled procedures and have them
show as natively compiled.

Cheers

¹ Maybe there's a smarter way to locate them files?  Did I go wrong in
one of my patches?