(address . bug-gnu-emacs@gnu.org)
Hello,
While investigating a few bugs affecting Debian's and Ubuntu's Emacs
packages (for example,
upon a problem that's affecting native compilation on Emacs 28.1+,
currently reproducible with git master as well.
I haven't been able to fully understand why the problem is happening,
but when there are two primitive functions (that would become
trampolines) being used sequentially, Emacs doesn't generate the
corresponding .eln file for the second function.
I spent some time investigating the problem and came up with a "minimal"
reproducer:
Toggle snippet (32 lines)
(require 'cl-lib)
(defmacro foo--flet (funcs &rest body)
"Like `cl-flet' but with dynamic function scope."
(declare (indent 1))
(let* ((names (mapcar #'car funcs))
(lambdas (mapcar #'cdr funcs))
(gensyms (cl-loop for name in names
collect (make-symbol (symbol-name name)))))
`(let ,(cl-loop for name in names
for gensym in gensyms
collect `(,gensym (symbol-function ',name)))
(unwind-protect
(progn
,@(cl-loop for name in names
for lambda in lambdas
for body = `(lambda ,@lambda)
collect `(setf (symbol-function ',name) ,body))
,@body)
,@(cl-loop for name in names
for gensym in gensyms
collect `(setf (symbol-function ',name) ,gensym))))))
(defun bar (file)
(and (file-exists-p file) (file-readable-p file)))
(defun test ()
(foo--flet ((file-exists-p (file) t)
(file-readable-p (file) nil))
(message "%s" (bar "/home/sergio/.lesshst"))))
When I run it using the following Emacs:
Toggle snippet (4 lines)
GNU Emacs 30.0.50
Development version 68cc286c0495 on master branch; build date 2023-02-28.
here is the output I see:
Toggle snippet (20 lines)
$ emacs -batch -Q -l t.el -f test -L .
Error: native-lisp-load-failed ("file does not exists" "/home/sergio/.emacs.d/eln-cache/30.0.50-23de7b18/subr--trampoline-66696c652d7265616461626c652d70_file_readable_p_0.eln")
debug-early-backtrace()
debug-early(error (native-lisp-load-failed "file does not exists" "/home/sergio/.emacs.d/eln-cache/30.0.50-23de7b18/subr--trampoline-66696c652d7265616461626c652d70_file_readable_p_0.eln"))
native-elisp-load("/home/sergio/.emacs.d/eln-cache/30.0.50-23de7b18/subr--trampoline-66696c652d7265616461626c652d70_file_readable_p_0.eln")
comp-trampoline-search(file-readable-p)
comp-subr-trampoline-install(file-readable-p)
fset(file-readable-p (lambda (file) nil))
(progn (fset 'file-exists-p #'(lambda (file) t)) (fset 'file-readable-p #'(lambda (file) nil)) (message "%s" (bar "/home/sergio/.lesshst")))
(unwind-protect (progn (fset 'file-exists-p #'(lambda (file) t)) (fset 'file-readable-p #'(lambda (file) nil)) (message "%s" (bar "/home/sergio/.lesshst"))) (fset 'file-exists-p file-exist
s-p) (fset 'file-readable-p file-readable-p))
(let ((file-exists-p (symbol-function 'file-exists-p)) (file-readable-p (symbol-function 'file-readable-p))) (unwind-protect (progn (fset 'file-exists-p #'(lambda (file) t)) (fset 'file-re
adable-p #'(lambda (file) nil)) (message "%s" (bar "/home/sergio/.lesshst"))) (fset 'file-exists-p file-exists-p) (fset 'file-readable-p file-readable-p)))
test()
command-line-1(("-l" "t.el" "-f" "test" "-L" "."))
command-line()
normal-top-level()
Native elisp load failed: "file does not exists", "/home/sergio/.emacs.d/eln-cache/30.0.50-23de7b18/subr--trampoline-66696c652d7265616461626c652d70_file_readable_p_0.eln"
Do note that this is already affecting a few packages, like buttercup
emacs-web-server, for example.
Please let me know if you need more information regarding the problem.
Thank you,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEI3pUsQKHKL8A7zH00Ot2KGX8XjYFAmP+mMYACgkQ0Ot2KGX8
XjYBlA//bA7gohJluKWD2juNgSPG1lFFSf+I4OlX5uAkd9HG9p1sWA3LRrTV4WGZ
Hv8oGKLaXHrwJqueWYAH/oRJZ2fgpEBLnRCbXh2JJu5zVTt0E8ICi+qrm0Zcu1MV
1lfLTAI4AfInIQ6u9sEP/lBrnaMxjqpWtMvcKaV30Do/4yWyd5iB52FZzbRs7cG+
s+7Ybmi1bnZfLm1nudtmwxIKJCOd/zTA4qE3iTdrsr1x7v50KDK8wwT0aGciLMHE
U0q+8gGnJkeLyp/MPkYKAL1ht/Na6TtFMWIHz2A3Gnds0F56OgddsbqiOE6hdQ70
xIRh2A81jn9WoYDXe794SktxEsrpAJ6qgjSwi2KnvuNLW7NaaPLPnlQvxqu6dGMS
fRkyB3THswGWMT0yiTFNJINxohc2P6X82l3Qqwsxaoi/5LU198BweWRH3cegPD9R
Dhwtj177ESGJ3bOE2/mMhLfL+WYLyCZUXy2xEnhszDMQ/NqbsdcyrYjDi61XW9h3
wsChJGSNzzPnEmxbMKeyEcGYbut3tzpTD2/Drml+9xqYj74KspHxoRKZJGr8BEmY
VVjjHVrGwUmfesfKNBUIWqhGVH6wHiUebDhsRdHkHsjHC+yEJFwcUBDavQVFrHU/
dynas2kFF2meE7L3qvzPPOOykBrGLhyXHqcQi9mMSk37WPp1CQk=
=Edby
-----END PGP SIGNATURE-----