Subject: Re: bug#78818: 31.0.50; Missing lexical-binding cookies when compiling trampolines

From: Daniel Mendler <[email-masked]>
Date: Sat, 05 Jul 2025 10:02:42 +0200

I will check if the issue still occurs when I recompile Emacs the next
time. Andreas fix looks correct, since it adds the missing cookie. From
my side the issue can be closed. Thanks!

Eli Zaretskii <[email-masked]> writes:
> Ping!  Daniel, could you please respond?
>
>> From: Andrea Corallo <[email-masked]>
>> Cc: Daniel Mendler <[email-masked]>,  [email-masked]
>> Date: Mon, 23 Jun 2025 16:09:13 -0400
>> 
>> Andrea Corallo <[email-masked]> writes:
>> 
>> > Eli Zaretskii <[email-masked]> writes:
>> >
>> >>> From: Daniel Mendler <[email-masked]>
>> >>> Cc: [email-masked], Andrea Corallo <[email-masked]>
>> >>> Date: Wed, 18 Jun 2025 13:52:42 +0200
>> >>>
>> >>> Eli Zaretskii <[email-masked]> writes:
>> >>>
>> >>> >> Date: Tue, 17 Jun 2025 20:38:20 +0200
>> >>> >> From:  Daniel Mendler via "Bug reports for GNU Emacs,
>> >>> >>  the Swiss army knife of text editors" <[email-masked]>
>> >>> >>
>> >>> >> In the *Native-compile-Log* I see the following messages on a newly
>> >>> >> compiled Emacs 31 from the current Emacs master branch:
>> >>> >>
>> >>> >> Warning (files): Missing ‘lexical-binding’ cookie in "/tmp/emacs-int-comp-subr--trampoline-72756e2d686f6f6b73_run_hooks_0-ZQkOM2.el".
>> >>> >> You can add one with ‘M-x elisp-enable-lexical-binding RET’.
>> >>> >> See ‘(elisp)Selecting Lisp Dialect’ and ‘(elisp)Converting to Lexical Binding’
>> >>> >> for more information.
>> >>> >> Compiling $HOME/.config/emacs/eln-cache/31.0.50-45ab2aa9/subr--trampoline-72756e2d686f6f6b73_run_hooks_0.eln...
>> >>> >
>> >>> > Please show a recipe to reproduce this problem starting from "emacs -Q".
>> >>> > Or at least figure out and tell here compilation of what ELisp file
>> >>> > triggered this message (it sounds like it's part of your init
>> >>> > configuration?).  I started "emacs -Q", but didn't see any such
>> >>> > messages that I could use as a starting point for investigation.
>> >>> >
>> >>> > Or, if I'm missing something, could you suggest how to investigate
>> >>> > this given the information you provided above?
>> >>>
>> >>> The trampoline .el file is generated by `comp--final' in comp.el. I
>> >>> found this by grepping for `emacs-int-comp'. The generated Elisp file
>> >>> doesn't include a `lexical-binding' cookie, which seems to trigger the
>> >>> warning. As far as I understand the trampolines are generated if native
>> >>> subrs are advised in the configuration.
>> >>
>> >> Thanks.  We insert the lexical-binding cookie in
>> >> comp--run-async-workers, but maybe trampoline compilation doesn't use
>> >> that?
>> >>
>> >> Andrea, any suggestions?
>> >
>> > Yep, I'm testing this I think it should work:
>> >
>> > modified   lisp/emacs-lisp/comp.el
>> > @@ -3363,7 +3363,7 @@ comp--final
>> >                           nil ".el"))
>> >               (default-directory invocation-directory))
>> >          (with-temp-file temp-file
>> > -          (insert ";; -*-coding: utf-8-emacs-unix; -*-\n")
>> > +          (insert ";; -*- coding: utf-8-emacs-unix; lexical-binding: t -*-\n")
>> >            (mapc (lambda (e)
>> >                    (insert (prin1-to-string e)))
>> >                  expr))
>> 
>> Ok I think it works so I've installed it on master as baf0c822026.
>> 
>> Daniel could you double check it works for your case?
>> 
>> Thanks
>> 
>>   Andrea
>>