Subject: bug#70914: 29.3; Crashes often on Windows

From: Eli Zaretskii <[email-masked]>
Date: Fri, 24 May 2024 13:48:43 +0300

> From: Andrea Corallo <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Fri, 24 May 2024 03:59:51 -0400
> 
> Andrea Corallo <[email-masked]> writes:
> 
> > Eli Zaretskii <[email-masked]> writes:
> >
> >>> From: Andrea Corallo <[email-masked]>
> >>> Cc: Simen Endsjø <[email-masked]>,
> >>>   [email-masked]
> >>> Date: Thu, 16 May 2024 08:11:03 -0400
> >>> 
> >>> Eli Zaretskii <[email-masked]> writes:
> >>> 
> >>> > Another possible idea is to disable native-compilation and use of
> >>> > *.eln files that were already compiled.  The simplest way of doing the
> >>> > former is to set the variables native-comp-jit-compilation and
> >>> > native-comp-enable-subr-trampolines to nil in your early-init file,
> >>> > then start Emacs as usual.  Can you try that?
> >>> >
> >>> > AFAIK, the above does not prevent Emacs from loading and using the
> >>> > *.eln files that were already generated.  Andrea, what is the best way
> >>> > of disabling the use of existing *.eln files without rebuilding Emacs?
> >>> > Maybe renaming libgccjit-0.dll and restarting Emacs?
> >>> 
> >>> I don't recall any pre-cooked way of doing it.  I suspect renaming
> >>> libgccjit-0.dll on Windows should hinibit the compilation but not the
> >>> load.
> >>> 
> >>> The only option that comes to my mind would be applying the following
> >>> and running make.
> >>> 
> >>> ================
> >>> modified   src/lread.c
> >>> @@ -1430,7 +1430,7 @@ DEFUN ("load", Fload, Sload, 1, 5, 0,
> >>>    else
> >>>      file = Fsubstitute_in_file_name (file);
> >>> 
> >>> -  bool no_native = suffix_p (file, ".elc");
> >>> +  bool no_native = true;/* suffix_p (file, ".elc"); */
> >>> 
> >>>    /* Avoid weird lossage with null string as arg,
> >>>       since it would try to load a directory as a Lisp file.  */
> >>> ================
> >>> 
> >>> But I guess is not an option here if one can't recompile.
> >>
> >> Probably not.
> >>
> >> For the non-preloaded *.eln files, I guess moving them out of
> >> native-comp-eln-load-path and setting native-comp-jit-compilation and
> >> native-comp-enable-subr-trampolines to nil in early-init should force
> >> Emacs to load the *.elc files, right?  If not, why not?
> >
> > Yeah right, if moving files is an option it should work.
> >
> >> But if we don't have any way of disabling loading of *.eln, I think we
> >> should provide it.  WDYT?
> >
> > I agree, will do.
> 
> Going to implemnt it I realized I might already have done it in 2020 and
> forgot about it 😬
> 
> Is 'load-no-native' what we wanted here?

Not sure.  The doc string says

  Non-nil means not to load a .eln file when a .elc was requested.

which makes it unspecified what happens when one does

    (load "foo")
or
    (require 'foo)

If the above also load foo.el/foo.elc, then yes, load-no-native is
what we want here.