emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp dc0cf16 3/3: Always set 'Vexec_path' before 'Vinvoca


From: Andrea Corallo
Subject: feature/native-comp dc0cf16 3/3: Always set 'Vexec_path' before 'Vinvocation_directory' (bug#43137)
Date: Sat, 26 Sep 2020 09:47:45 -0400 (EDT)

branch: feature/native-comp
commit dc0cf16c7a60f36aafcf9b56513a855cefa7e1ad
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Always set 'Vexec_path' before 'Vinvocation_directory' (bug#43137)
    
    Do this as depending on the OS if argv0 is not populated 'Vexec_path'
    is used to infer 'Vinvocation_directory'.
    
                * src/pdumper.c (pdumper_load): Invoke 'init_vars_for_load' 
instead
        of 'set_invocation_vars'.
    
        * src/lisp.h: Extern 'init_vars_for_load' instead of
        'set_invocation_vars' .
    
        * src/emacs.c (set_invocation_vars): Make it static and remove
        double invocation guard.
        (init_vars_for_load): Wrap 'init_callproc_1' and 'set_invocation_vars'
        calls + add double invocation guard.
        (init_cmdargs): Move out 'set_invocation_vars' invocation.
        (main): Call 'init_vars_for_load' instead of 'init_callproc_1'.
---
 src/emacs.c   | 32 +++++++++++++++++++++-----------
 src/lisp.h    |  2 +-
 src/pdumper.c |  3 ++-
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/emacs.c b/src/emacs.c
index 07e40fd..1f7f5ea 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -413,16 +413,9 @@ terminate_due_to_signal (int sig, int backtrace_limit)
 
 /* Set `invocation-name' `invocation-directory'.  */
 
-void
+static void
 set_invocation_vars (char *argv0, char const *original_pwd)
 {
-  /* This function can be called from within pdumper or later during
-     boot.  No need to run it twice.  */
-  static bool double_run_guard;
-  if (double_run_guard)
-    return;
-  double_run_guard = true;
-
   Lisp_Object raw_name, handler;
   AUTO_STRING (slash_colon, "/:");
 
@@ -480,6 +473,25 @@ set_invocation_vars (char *argv0, char const *original_pwd)
     }
 }
 
+/* Initialize a number of variables (ultimately
+   'Vinvocation_directory') needed by pdumper to complete native code
+   load.  */
+
+void
+init_vars_for_load (char *argv0, char const *original_pwd)
+{
+  /* This function is called from within pdumper while loading (as
+     soon as we are able to allocate) or later during boot if pdumper
+     is not used.  No need to run it twice.  */
+  static bool double_run_guard;
+  if (double_run_guard)
+    return;
+  double_run_guard = true;
+
+  init_callproc_1 ();  /* Must precede init_cmdargs and init_sys_modes.  */
+  set_invocation_vars (argv0, original_pwd);
+}
+
 
 /* Code for dealing with Lisp access to the Unix command line.  */
 static void
@@ -492,8 +504,6 @@ init_cmdargs (int argc, char **argv, int skip_args, char 
const *original_pwd)
   initial_argv = argv;
   initial_argc = argc;
 
-  set_invocation_vars (argv[0], original_pwd);
-
   Vinstallation_directory = Qnil;
 
   if (!NILP (Vinvocation_directory))
@@ -1788,7 +1798,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   /* Init buffer storage and default directory of main buffer.  */
   init_buffer ();
 
-  init_callproc_1 ();  /* Must precede init_cmdargs and init_sys_modes.  */
+  init_vars_for_load (argv[0], original_pwd);
 
   /* Must precede init_lread.  */
   init_cmdargs (argc, argv, skip_args, original_pwd);
diff --git a/src/lisp.h b/src/lisp.h
index 452f48f..e33577b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4430,7 +4430,7 @@ extern bool display_arg;
 extern Lisp_Object decode_env_path (const char *, const char *, bool);
 extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
 extern AVOID terminate_due_to_signal (int, int);
-extern void set_invocation_vars (char *argv0, char const *original_pwd);
+extern void init_vars_for_load (char *, char const *);
 #ifdef WINDOWSNT
 extern Lisp_Object Vlibrary_cache;
 #endif
diff --git a/src/pdumper.c b/src/pdumper.c
index 0a7e038..03391c49 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5587,7 +5587,8 @@ pdumper_load (const char *dump_filename, char *argv0, 
char const *original_pwd)
 
   /* Once we can allocate and before loading .eln files we must set
      Vinvocation_directory (.eln paths are relative to it). */
-  set_invocation_vars (argv0, original_pwd);
+  init_vars_for_load (argv0, original_pwd);
+
   dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS);
   dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS);
   initialized = true;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]