summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-09-26 15:12:30 +0200
committerAndrea Corallo <akrl@sdf.org>2020-09-26 15:46:31 +0200
commitdc0cf16c7a60f36aafcf9b56513a855cefa7e1ad (patch)
treeb56d844da0d424bde63c9897f8e46249577d2fe3 /src
parent29a8d9303bd3098eed88f3eb7394b66ae28cc887 (diff)
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'.
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c32
-rw-r--r--src/lisp.h2
-rw-r--r--src/pdumper.c3
3 files changed, 24 insertions, 13 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 07e40fdc8bd..1f7f5eabc56 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 452f48f3468..e33577b5633 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 0a7e0388f1d..03391c49505 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;