Subject: Re: bug#45854: 28.0.50; [feature/native-comp] autoload behavior different in the presence of errors

From: Mauricio Collares <[email-masked]>
Date: Thu, 14 Jan 2021 09:01:18 -0300

This might be slightly off-topic (in the sense that the previous message
stands alone and is not corrected by this one) but I have a related
question to ask about the actual error I was hitting. To reproduce the
error, one can use git-commitx.el and elpa2nix.el from the previous
email and the following transientx.el file:

;;; transientx.el --- x -*- lexical-binding: t; -*-

;; Package-Requires: ((emacs "25.1"))
;; Package-Version: 0

(require 'cl-lib)
(require 'eieio)

(defclass transient-suffix () ())
(cl-defmethod transient--init-suffix-key ((obj transient-suffix)))

(advice-add 'top-level :before 'identity)

(provide 'transientx)

;;; transientx.el ends here

That is, the "provide" line is uncommented but there's now an advice-add
call. Running the following commands causes a problem similar to the one
in the previous message:

$ --batch -Q -l ~/elpa2nix.el -f elpa2nix-install-package /home/collares/transientx.el 
$ --batch -Q --eval "(setq comp-eln-load-path '())" -l ~/elpa2nix.el -f elpa2nix-install-package /home/collares/git-commitx.el 

git-commitx.el:6:1: Error: Cannot find suitable directory for output in ‘comp-eln-load-path’
Done (Total of 0 files compiled, 1 failed, 2 skipped)
Debugger entered--Lisp error: (error "transient--init-suffix-key is already defined as s...")
  error("%s is already defined as something else than a gen..." transient--init-suffix-key)
  cl-generic-ensure-function(transient--init-suffix-key)

Apparently, advice-add caused native compilation to happen, and that
failed because comp-eln-load-path was empty. This error plays a role
similar to the lack of "(provide 'transientx)" in the previous email,
leading to the second error which does not happen in trunk.

In this email, however, I would like to address the first error. My
question is: Is it possible to disable the native compilation caused by
advice-add in the above example? In Nix we run batch-native-compile
separately after installing the package, and comp-eln-load-path is not
set up until that point, so an option to disable all native compilation
for a single batch session would be helpful. I tried setting
comp-deferred-compilation and comp-enable-subr-trampolines to nil but
still got the "Cannot find suitable directory for output in
‘comp-eln-load-path’" error with an empty comp-eln-load-path.

Best,
Mauricio