Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 735148 - elisp-common.eclass: support for native-compile
Summary: elisp-common.eclass: support for native-compile
Status: IN_PROGRESS
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: GNU Emacs project
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2020-08-02 02:23 UTC by Tom Gillespie
Modified: 2023-11-27 17:15 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Gillespie 2020-08-02 02:23:30 UTC
With native comp support in the pipeline for emacs, there is a need to be able to run batch-native-compile in addition to/instead of running batch-byte-compile when calling elisp-compile if emacs was built with native compile support enabled.

I think the things that need to be implemented in the eclass are to check whether emacs was built with native compiler support enabled and if it was to call batch-native-compile instead of calling batch-byte-compile.

In principle batch-native-compile should also create the .elc files, but I can't test that to be 100% sure right now due to a bug in the development branch of emacs.

This is mostly a prospective bug since it still takes quite some doing to get emacs compiling with native comp and sys-devel/gcc[jit] still has some outstanding issues https://bugs.gentoo.org/569608 and https://bugs.gentoo.org/583010. For the record I build from https://github.com/tgbugs/tgbugs-overlay/blob/master/app-editors/emacs/emacs-28.0.9999-r1.ebuild with the following package environment settings.

#+begin_src bash :tangle /su:localhost:/etc/portage/env/emacs-native-comp :tangle no
EGIT_OVERRIDE_REPO_EMACS="https://github.com/emacs-mirror/emacs.git"
EGIT_OVERRIDE_BRANCH_EMACS="feature/native-comp"
#+end_src

#+begin_src bash :tangle /su:localhost:/etc/portage/package.env/app-editors :tangle no
=app-editors/emacs-28.0.9999-r1 emacs-native-comp
#+end_src


Reproducible: Always
Comment 1 Tom Gillespie 2020-08-02 20:09:01 UTC
Update on the approach. batch-native-compile does not produce elc files, so rather than replacing the call to batch-byte-compile is should just be called afterward if native comp is enabled.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-04-12 06:23:16 UTC
Ping. This will land in emacs master soon.
Comment 3 Ulrich Müller gentoo-dev 2021-04-12 10:42:35 UTC
Yes, I am well aware. No action until then.
Comment 4 Ulrich Müller gentoo-dev 2021-04-25 22:43:19 UTC
feature/native-compile was merged to master in commit 289000e.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-04-26 22:16:30 UTC
(In reply to Ulrich Müller from comment #3)
> Yes, I am well aware. No action until then.

I shouldn’t have doubted you :)
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-18 19:11:20 UTC
ping
Comment 7 Ulrich Müller gentoo-dev 2022-10-28 18:13:19 UTC
(In reply to Sam James from comment #6)
> ping

I tend to close this as wontfix. IIUC every rebuild of Emacs would invalidate the installed *.eln files.
Comment 8 Tom Gillespie 2022-10-28 18:51:04 UTC
I think the fact that *.eln files need to be rebuilt along with emacs would be an indication that we would want the eclass to do this so that all system package eln files wouldn't be built per user but shared by the system.

I realize this would require a rebuild of all system installed elisp packages when building a new emacs release, but I think that is actually what we want?

As a note, the many changes in the bytecode have also made the bytecode backward incompatible requiring a rebuild if a user accidentally builds the elc files with the newest version of emacs on their system.
Comment 9 Ulrich Müller gentoo-dev 2022-10-29 07:21:02 UTC
(In reply to Tom Gillespie from comment #8)
> I think the fact that *.eln files need to be rebuilt along with emacs would
> be an indication that we would want the eclass to do this so that all system
> package eln files wouldn't be built per user but shared by the system.
> 
> I realize this would require a rebuild of all system installed elisp
> packages when building a new emacs release, but I think that is actually
> what we want?

The problem is that it introduces a dependency on a specific build of Emacs, and there's no package manager support for this. It becomes even worse for binary packages.
Comment 10 Ulrich Müller gentoo-dev 2023-08-26 06:56:48 UTC
The compiler ABI hash (comp-abi-hash, also last part of comp-native-version-dir) is computed from the following values:
- ABI_VERSION (currently "5")
- emacs-version
- system-configuration (i.e. the GNU triplet)
- system-configuration-options (contains all arguments passed to configure, plus the environment variables CFLAGS, CPPFLAGS and LDFLAGS; see emacs_config_options in configure.ac)
- comp-subr-list (i.e. the list of all internal functions)

So, at least a simple reinstallation of Emacs will _not_ change the hash. It will change however if a USE flag is changed (because that will affect configure options), if CFLAGS etc. are changed, and for every revision bump.


(In reply to Ulrich Müller from comment #9)
> The problem is that it introduces a dependency on a specific build of Emacs,
> and there's no package manager support for this. It becomes even worse for
> binary packages.

From discussion in #gentoo-lisp:

What we could do is to install the *.eln files not as part of the package's installation image, but write them to a system-wide cache under /var/cache. This could be done e.g. in pkg_preinst() or pkg_postinst().

Cleanup of stale cache entries could then be done in pkg_postrm() of the package, and also in pkg_postrm() of app-editors/emacs. We could also consider adding some of the functionality to emacs-updater or some other tool.