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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 04 Mar 2023 09:38:03 +0200

> From: Andrea Corallo <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sat, 04 Mar 2023 00:20:41 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> Should we start with these?
> >
> > Yes, I think we should start with those, and add more as we discover
> > them.
> 
> BTW would you like to suggest a warning message?

Something like

  Redefining `%s' while compiling trampolines might fail compilation.

where %s is the primitive name.

> Should we say that redefining this primitive breaks Emacs in general or
> be more specific on the trampoline mechanism?

The latter, I think.

> I ask as I'm a little puzzled on what to say as there's certanly a ton
> of other primitives that when redefined breaks Emacs somewere else than
> the trampoline machinery, so maybe we should be not too generic if we
> want to have this warning also for nativecomp.  At the same time I feel
> beeing too specific in the message would be not ideal.

It's true that redefining arbitrary primitive is inherently dangerous,
but as long as that danger just causes the programmer shoot themselves
in the foot, that is their problem.  Here we are talking about a
mechanism -- native compilation of primitives -- that gets activated
implicitly, not by any request of the program that runs, so it's a bit
different.

Btw, an alternative is to automatically disable trampoline compilation
if we detect one of the critical primitives redefined.  Then we could
say in the warning

  Native compilation of trampolines disabled because `%s' is redefined.

WDYT about this possibility?