all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Robert Weiner <rsw@gnu.org>
Cc: rswgnu@gmail.com, Andrea Corallo <akrl@sdf.com>, 55305@debbugs.gnu.org
Subject: bug#55305: 28.0.50: With async nativecomp, package manager fails to load hyperbole-autoloads.el before compilation
Date: Sun, 15 May 2022 11:59:05 -0400	[thread overview]
Message-ID: <jwvee0ug7up.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CA+OMD9iDR6rsiAWUEHWKvsOMTB+RsBviuh-2LmK8hQp-FpVuxw@mail.gmail.com> (Robert Weiner's message of "Sat, 7 May 2022 16:05:17 -0400")

First, sorry for not chiming in earlier (I don't subscribe to the
emacs-bugs list, so I only see those bugs that are explicitly forwarded
to me).

Robert Weiner [2022-05-07 16:05:17] wrote:
> Tested under Emacs 28.1 and a recent tip of the Emacs git repo for Emacs
> 29 with asynchronous native compilation enabled:
>
> M-x package-install RET hyperbole RET

Hmm... I tried to reproduce it here, with `emacs -Q` this gives me
(during the normal compilation), among a bunch of lesser warnings:

    Compiling file ~/.emacs.d/elpa/hyperbole-8.0.0/test/kexport-tests.el at Sun May 15 11:01:59 2022
    kexport-tests.el:20:2: Error: Cannot open load file: Aucun fichier ou dossier de ce type, el-mock

I also noticed the following warning in *Messages*:

    hibtypes:0: Warning: Not registering prefix "pa".  Affects: ("parse-label-and-file" "pathname" "pathname-line-and-column" "patch-msg")

which points at some namespace uncleanliness in your code.
Oh, and:

    Warning: Eager macro-expansion skipped due to cycle:
      … => (load "hbut.el") => (macroexpand-all …) => (macroexpand (eval-and-compile …)) => (load "hbdata.el") => (load "hgnus.el") => (load "hvar.el") => (load "hsettings.el") => (load "hui-em-but.el") => (load "hbut.el")
    Waiting for git... [2 times]

You might wan to try and fix this one.

> fails to load the hyperbole-autoloads.el file before the
> async native compiler and byte compiler produce these errors since
> the autoloaded var:append function is not defined:

Indeed.

> Warning (comp): ~/.emacs.d/elpa/hyperbole-8.0.0/hui-em-but.el: Error:
> Symbol's function definition is void var:append Disable showing Disable
> logging

It took a bit of while to get there (many other things to
native-compile before this, apparently), but yes, I'm able to
reproduce it.

Looking at `comp-run-async-workers` in `comp.el`, I see that the async
compilation basically does:

    emacs -q -l <temp-file>

where <temp-file>'s content is basically the `expr` below:

         do (let* ((expr `((require 'comp)
                           ,(when (boundp 'backtrace-line-length)
                              `(setf backtrace-line-length ,backtrace-line-length))
                           (setf comp-file-preloaded-p ,comp-file-preloaded-p
                                 native-compile-target-directory ,native-compile-target-directory
                                 native-comp-speed ,native-comp-speed
                                 native-comp-debug ,native-comp-debug
                                 native-comp-verbose ,native-comp-verbose
                                 comp-libgccjit-reproducer ,comp-libgccjit-reproducer
                                 comp-async-compilation t
                                 native-comp-eln-load-path ',native-comp-eln-load-path
                                 native-comp-compiler-options
                                 ',native-comp-compiler-options
                                 native-comp-driver-options
                                 ',native-comp-driver-options
                                 load-path ',load-path
                                 warning-fill-column most-positive-fixnum)
                           ,native-comp-async-env-modifier-form
                           (message "Compiling %s..." ,source-file)
                           (comp--native-compile ,source-file ,(and load t))))

so the sync compilation is careful to preserve the current load-path
via:

                                 load-path ',load-path

which is why many of the files can be compiled correctly but it doesn't
load the packages's autoloads like a normal session does.

I suspect we should add a call to `package-activate-all` somewhere
in the above code (and probably preserve `package-directory-list` and
`package-user-dir` as well).

I just tried to re-trigger the problem after applying the patch below
[which also make this part of the code obey our 80-column convention,
while at it] and it appears to be fixed (e.g. `hui-em-but.el` was
successfully compiled).
Andrea, any comment?


        Stefan


diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 237de52884b..aa49607462c 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -3926,22 +3926,27 @@ comp-run-async-workers
                   (file-newer-than-file-p
                    source-file (comp-el-to-eln-filename source-file)))
          do (let* ((expr `((require 'comp)
-                           ,(when (boundp 'backtrace-line-length)
-                              `(setf backtrace-line-length ,backtrace-line-length))
-                           (setf comp-file-preloaded-p ,comp-file-preloaded-p
-                                 native-compile-target-directory ,native-compile-target-directory
-                                 native-comp-speed ,native-comp-speed
-                                 native-comp-debug ,native-comp-debug
-                                 native-comp-verbose ,native-comp-verbose
-                                 comp-libgccjit-reproducer ,comp-libgccjit-reproducer
-                                 comp-async-compilation t
-                                 native-comp-eln-load-path ',native-comp-eln-load-path
-                                 native-comp-compiler-options
-                                 ',native-comp-compiler-options
-                                 native-comp-driver-options
-                                 ',native-comp-driver-options
-                                 load-path ',load-path
-                                 warning-fill-column most-positive-fixnum)
+                           (setq comp-async-compilation t)
+                           (setq warning-fill-column most-positive-fixnum)
+                           ,(let ((set (list 'setq)))
+                              (dolist (var '(comp-file-preloaded-p
+                                             native-compile-target-directory
+                                             native-comp-speed
+                                             native-comp-debug
+                                             native-comp-verbose
+                                             comp-libgccjit-reproducer
+                                             native-comp-eln-load-path
+                                             native-comp-compiler-options
+                                             native-comp-driver-options
+                                             load-path
+                                             backtrace-line-length
+                                             package-user-dir
+                                             package-directory-list))
+                                (when (boundp var)
+                                  (push var set)
+                                  (push `',(symbol-value var) set)))
+                              (nreverse set))
+                           (package-activate-all)
                            ,native-comp-async-env-modifier-form
                            (message "Compiling %s..." ,source-file)
                            (comp--native-compile ,source-file ,(and load t))))
@@ -3994,7 +3999,7 @@ comp-run-async-workers
     (run-hooks 'native-comp-async-all-done-hook)
     (with-current-buffer (get-buffer-create comp-async-buffer-name)
       (save-excursion
-        (let ((buffer-read-only nil))
+        (let ((inhibit-read-only t))
           (goto-char (point-max))
           (insert "Compilation finished.\n"))))
     ;; `comp-deferred-pending-h' should be empty at this stage.






  parent reply	other threads:[~2022-05-15 15:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07 20:05 bug#55305: 28.0.50: With async nativecomp, package manager fails to load hyperbole-autoloads.el before compilation Robert Weiner
2022-05-08  5:09 ` Eli Zaretskii
2022-05-12  5:14   ` Robert Weiner
2022-05-12  5:51     ` Eli Zaretskii
2022-05-12  6:21       ` Robert Weiner
2022-05-12  7:22         ` Eli Zaretskii
2022-05-14 14:47           ` Robert Weiner
2022-05-14 15:05             ` Eli Zaretskii
2022-05-14 22:40               ` Robert Weiner
2022-05-15  5:15                 ` Eli Zaretskii
2022-05-15 15:59 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-05-15 16:17   ` Eli Zaretskii
2022-05-15 16:22     ` Eli Zaretskii
2022-05-15 16:47       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-15 17:01         ` Eli Zaretskii
2022-05-15 17:15           ` Eli Zaretskii
2022-05-15 20:12           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-16  2:31             ` Eli Zaretskii
2022-05-16 16:40               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-16 16:57                 ` Eli Zaretskii
2022-05-16 17:17                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-15 20:39           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-16  2:33             ` Eli Zaretskii
2022-05-16  9:34   ` Andrea Corallo
2022-05-16 16:42     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-16 16:59       ` Eli Zaretskii
2022-05-16 22:27         ` Robert Weiner
2022-05-17  2:27           ` Eli Zaretskii
2023-06-07 21:36             ` Andrea Corallo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvee0ug7up.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=55305@debbugs.gnu.org \
    --cc=akrl@sdf.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=rsw@gnu.org \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.