Subject: Re: bug#73318: 31.0.50; with-native-compilation=aot breaks exec -a emacs

From: Eli Zaretskii <[email-masked]>
Date: Wed, 09 Oct 2024 15:13:06 +0300

> From: Stefan Kangas <[email-masked]>
> Date: Tue, 8 Oct 2024 23:35:11 +0000
> Cc: [email-masked], [email-masked], [email-masked], 
> 	[email-masked], [email-masked]
> 
> Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <[email-masked]> writes:
> 
> > Yes, I'm persuaded now that if we use /proc/self/exe, we should also use
> > argv[0].  As Po Lu said, /proc can be unmounted, so we must have some
> > other mechanism besides just /proc/self/exe.
> [...]
> > If we use /proc/self/exe, I'm fine with it being a fallback if all other
> > mechanisms fail.  That should make these cases still work fine, right?
> 
> Did we discard the idea to check for /proc/self/exe first (on systems
> that support it, of course), and falling back to argv[0] if that fails?

This will have to somehow resolve the potential problems I listed in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73318#32 (and perhaps
some others I didn't mention there).  That is not trivial, and will
probably need to do something we already do, just without using
/proc/self/exe.

So I very much dislike this alternative.  At the time Daniel coded the
initial version of this code, he decided (and others generally agreed)
that use of /proc/self/exe does not bring us any advantages.  The code
which was written then and improved and enhanced since then is solid,
supports quite a few use patterns (some of them quite surprising), and
was tested by 3 Emacs releases.  Significant modifications of the
code's logic (which will be necessary of /proc/self/exe is the first
method to be used) will basically set us back to where we were in
Emacs 28, something I'd like to avoid.

> Could we use getauxval(AT_EXECFN) when we have glibc?

Isn't that the same method as /proc/self/exe, just thinly disguised?