GNU bug report logs - #75812
29.2.50; Support native-compiling package-install from batch Emacs

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Fri, 24 Jan 2025 17:55:02 UTC

Severity: wishlist

Tags: confirmed

Found in version 29.2.50

Full log


Message #15 received at 75812 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: app-emacs-dev <at> janestreet.com, 75812 <at> debbugs.gnu.org
Subject: Re: bug#75812: 29.2.50; Support native-compiling package-install
 from batch Emacs
Date: Fri, 24 Jan 2025 17:35:50 -0500
Stefan Kangas <stefankangas <at> gmail.com> writes:
> Spencer Baugh <sbaugh <at> janestreet.com> writes:
>
>> Currently, setting package-native-compile to t will make package-install
>> asynchronously native-compile the package.  This works great for
>> interactive usage.
>>
>> However, this is unsuitable for a batch Emacs running package-install.
>> "emacs -batch --eval (package-install something)" will exit once the
>> package is installed, but before the asynchronous native compilation
>> completes; the native compilation will just be abandoned.  So,
>> currently, there's no straightforward way to native compile a package
>> from a batch Emacs.
>>
>> Running package-install from a batch Emacs is useful as a way to update
>> or pre-install packages in scripts, without requiring user interaction.
>> This is widely used by package managers like Nix or dpkg to install
>> Emacs packages as OS packages.  In my specific case, it's used to
>> install and byte-compile common packages into site-lisp.  In all these
>> cases, it would be nice to be able to native-compile the package at
>> installation time and include the .eln files in the package directory.
>>
>> A straightforward solution would be for package-install-file to support
>> synchronously native-compiling the installed package, such that after
>> package-install finishes running, the native compilation is complete.
>> Perhaps with a new value of package-native-compile?
>
> Sounds good to me, thanks.  We'll take patches implementing this.

I'm happy to implement this, I'm just a bit lost about where to start.
I tried the obvious "iterate over *.el files in the package directory,
calling native-compile", but that failed on various files in various
packages.

There's a lot of code in package--compile and byte-recompile-directory,
which does a bunch of stuff like ignoring certain files.  I guess I need
that code.  Ultimately, package--compile calls byte-compile-file, so if
I could get byte-compile-file to also emit native-compiled files, that
would work.  Is there a way to do that?

byte+native-compile looks like a relevant variable, but is that the
right direction to head in?




This bug report was last modified 47 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.