Subject: bug#53675: closed (Re: bug#53675: lisp/startup.el; startup--require-comp-safely async compile breaks if comp is required in init)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 02 Feb 2022 09:13:02 +0000

Your bug report

#53675: lisp/startup.el; startup--require-comp-safely async compile breaks if comp is required in init

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
53675: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=53675
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#53675: lisp/startup.el; startup--require-comp-safely async compile breaks if comp is required in init
From: Andrea Corallo <[email-masked]>
To: Tom Gillespie <[email-masked]>
Cc: Arash Esbati <[email-masked]>, [email-masked]
Date: Wed, 02 Feb 2022 09:12:05 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Tom Gillespie <[email-masked]> writes:

>> All right pushed as 665ec8946d.
>
> Fixed for me as well. Thanks!
> Tom

Thanks all for checking, closing.

  Andrea

Subject: lisp/startup.el; startup--require-comp-safely async compile breaks if comp is required in init
From: Tom Gillespie <[email-masked]>
To: Emacs Bug Report <[email-masked]>, Andrea Corallo <[email-masked]>
Date: Mon, 31 Jan 2022 20:13:22 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

async compilation no longer runs on startup if comp
is required during loading of user init files

The issue is from 536a57b72ce11b1bb8d1b34b339424fea6ccbcce
Fix potential native compiler circular dependencies during load

If for whatever reason during the loading of a user init file
the feature 'comp is loaded (e.g. because they have a call to
(use-package queue) in init.el), then startup will not honor
delayed native compilations. Known causes are cases where
(require 'comp) is called directly in an init file, or where
any comp autoload is reached e.g. if a builtin such as
macroexpand is advised during init re: bug#47049.

This took a very long time to debug because the autoloads
make it impossible to grep for the source of the issue.

The underlying issues is that startup--require-comp-safely
assumes that it is guaranteed to be called for the first
time in an state where 'comp has not already been required.
This is not the case since all user init files are loaded
before startup--require-comp-safely is called.

As far as I can tell the issue can be fixed by removing the
unless (featurep 'comp) check. I'm not sure what side effects
removing the check might cause, however it does restore the
expected behavior. The patched version is:

(defun startup--require-comp-safely ()
  "Require the native compiler avoiding circular dependencies."
  ;; Require comp with `comp--loadable' set to nil to break
  ;; circularity.
  (let ((comp--loadable nil))
    (require 'comp))
  (native--compile-async comp--delayed-sources nil 'late)
  (setq comp--delayed-sources nil))