From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#44676: [PATCH] Support native compilation of packages on install Date: Mon, 16 Nov 2020 15:12:31 +0000 Message-ID: References: Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4944"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 44676@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 16 16:13:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kegBu-0001C1-GU for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Nov 2020 16:13:14 +0100 Original-Received: from localhost ([::1]:39460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kegBt-0008Sr-IG for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Nov 2020 10:13:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kegBj-0008ST-3P for bug-gnu-emacs@gnu.org; Mon, 16 Nov 2020 10:13:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45209) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kegBi-0004wT-B6 for bug-gnu-emacs@gnu.org; Mon, 16 Nov 2020 10:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kegBi-0006Oy-69 for bug-gnu-emacs@gnu.org; Mon, 16 Nov 2020 10:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Nov 2020 15:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44676 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 44676-submit@debbugs.gnu.org id=B44676.160553955624572 (code B ref 44676); Mon, 16 Nov 2020 15:13:02 +0000 Original-Received: (at 44676) by debbugs.gnu.org; 16 Nov 2020 15:12:36 +0000 Original-Received: from localhost ([127.0.0.1]:56755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kegBH-0006OG-I6 for submit@debbugs.gnu.org; Mon, 16 Nov 2020 10:12:35 -0500 Original-Received: from mx.sdf.org ([205.166.94.24]:64037) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kegBF-0006O7-5E for 44676@debbugs.gnu.org; Mon, 16 Nov 2020 10:12:34 -0500 Original-Received: from mab (ma.sdf.org [205.166.94.33]) by mx.sdf.org (8.15.2/8.14.5) with ESMTP id 0AGFCVhA008538; Mon, 16 Nov 2020 15:12:32 GMT In-Reply-To: (Stefan Kangas's message of "Sun, 15 Nov 2020 18:38:20 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193432 Archived-At: Stefan Kangas writes: Hi Stefan, thanks for the patch > Severity: wishlist > > Please find attach a patch to add support to package.el for native > compilation of packages on installation. > > I've done some minimal testing and it seems to do the job. > > (This is intended for the native-comp branch.) > > From 9a0da21a6989b20f593ec2b27a48eb4ef90561b7 Mon Sep 17 00:00:00 2001 > From: Stefan Kangas > Date: Mon, 16 Nov 2020 03:28:39 +0100 > Subject: [PATCH] Support native compilation of packages on install > > * lisp/emacs-lisp/package.el (package-unpack) > (package--native-compile): Native compile packages on install, if the > feature is available. > --- > lisp/emacs-lisp/package.el | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el > index a381ca01f3..54b42db181 100644 > --- a/lisp/emacs-lisp/package.el > +++ b/lisp/emacs-lisp/package.el > @@ -968,6 +968,7 @@ package-unpack > ;; E.g. for multi-package installs, we should first install all packages > ;; and then compile them. > (package--compile new-desc) > + (package--native-compile new-desc) > ;; After compilation, load again any files loaded by > ;; `activate-1', so that we use the byte-compiled definitions. > (package--load-files-for-activation new-desc :reload))) > @@ -1052,6 +1053,12 @@ package--compile > (load-path load-path)) > (byte-recompile-directory (package-desc-dir pkg-desc) 0 t))) > > +(defun package--native-compile (pkg-desc) > + (when (and (featurep 'nativecomp) > + (native-comp-available-p)) > + (let ((warning-minimum-level :error)) > + (native-compile-async (package-desc-dir pkg-desc) t 'late)))) Late load assume the current bytecode is already loaded when the native load will happen. This because late load is designed to be issued when some bytecode file is loaded and no native code alternative is found. We should probably issue the async compilation here without late load and in case the bytecode is being loaded before native compilation was done just patch the kind of load stored into `comp-files-queue'. ATM if the stored load property and new one are not matching we complain (See comp.el:3528). So yeah non 100% straight forward :) That said I think we should have a customize to decided if we want package to eager command native compilation. I may never used some of the installed files and prefer the current solution for that, or maybe I may just like to have the compilation happening in a more diluted fashion and on demand (my personal taste). Thanks Andrea