Subject: Re: bug#61880: Native compilation fails to generate trampolines on certain scenarios

From: Sergio Durigan Junior <[email-masked]>
Date: Thu, 02 Mar 2023 18:54:33 -0500

On Thursday, March 02 2023, Eli Zaretskii wrote:

>> From: Sergio Durigan Junior <[email-masked]>
>> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
>> Date: Wed, 01 Mar 2023 18:14:01 -0500
>> 
>> > Fact is, Emacs can't be robust against the redefinition of all
>> > primitives (actually never was), the programmer that redefines
>> > primitives should be ready to understand the underlying Emacs machinery,
>> > and with native compilation this machinery changed a bit.
>> 
>> I understand where you're coming from, but it's also important to note
>> that this behaviour was accepted without problems until the native
>> compilation feature came about, so it is understandable that we are
>> getting a lot of confusing people wondering why their tests started
>> failing now.  I believe there should be more emphasis in the
>> documentation that this problem can creep in, especially for those who
>> are relying on redefinitions for testing purposes.
>> 
>> > So two options:
>> >
>> > * The redefinition of `file-exists-p' is tipically done for test
>> >   purposes only, we accept that and for this case we suggest to run
>> >   these specific tests setting `native-comp-enable-subr-trampolines' to
>> >   nil
>> 
>> This is what I'm currently doing in Debian/Ubuntu, and will start
>> suggesting upstream maintainers to do the same.
>
> I can come up with documentation of this subtlety, including a list of
> primitives whose redefinition could trigger these issues, if this is
> an acceptable solution.

Yes, this would be a great first step.  I wonder if there's some warning
Emacs can print when it detects that a primitive is being redefined and
native compilation is enabled.  On the one hand, Emacs would be a bit
more verbose than perhaps desirable; on the other, I think this scenario
is particular enough that having a warning is OK-ish.

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
https://sergiodj.net/