aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2020-09-26 15:12:30 +0200
committerAndrea Corallo2020-09-26 15:46:31 +0200
commitdc0cf16c7a60f36aafcf9b56513a855cefa7e1ad (patch)
treeb56d844da0d424bde63c9897f8e46249577d2fe3
parent29a8d9303bd3098eed88f3eb7394b66ae28cc887 (diff)
downloademacs-dc0cf16c7a60f36aafcf9b56513a855cefa7e1ad.tar.gz
emacs-dc0cf16c7a60f36aafcf9b56513a855cefa7e1ad.zip
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'.
-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)
413 413
414/* Set `invocation-name' `invocation-directory'. */ 414/* Set `invocation-name' `invocation-directory'. */
415 415
416void 416static void
417set_invocation_vars (char *argv0, char const *original_pwd) 417set_invocation_vars (char *argv0, char const *original_pwd)
418{ 418{
419 /* This function can be called from within pdumper or later during
420 boot. No need to run it twice. */
421 static bool double_run_guard;
422 if (double_run_guard)
423 return;
424 double_run_guard = true;
425
426 Lisp_Object raw_name, handler; 419 Lisp_Object raw_name, handler;
427 AUTO_STRING (slash_colon, "/:"); 420 AUTO_STRING (slash_colon, "/:");
428 421
@@ -480,6 +473,25 @@ set_invocation_vars (char *argv0, char const *original_pwd)
480 } 473 }
481} 474}
482 475
476/* Initialize a number of variables (ultimately
477 'Vinvocation_directory') needed by pdumper to complete native code
478 load. */
479
480void
481init_vars_for_load (char *argv0, char const *original_pwd)
482{
483 /* This function is called from within pdumper while loading (as
484 soon as we are able to allocate) or later during boot if pdumper
485 is not used. No need to run it twice. */
486 static bool double_run_guard;
487 if (double_run_guard)
488 return;
489 double_run_guard = true;
490
491 init_callproc_1 (); /* Must precede init_cmdargs and init_sys_modes. */
492 set_invocation_vars (argv0, original_pwd);
493}
494
483 495
484/* Code for dealing with Lisp access to the Unix command line. */ 496/* Code for dealing with Lisp access to the Unix command line. */
485static void 497static void
@@ -492,8 +504,6 @@ init_cmdargs (int argc, char **argv, int skip_args, char const *original_pwd)
492 initial_argv = argv; 504 initial_argv = argv;
493 initial_argc = argc; 505 initial_argc = argc;
494 506
495 set_invocation_vars (argv[0], original_pwd);
496
497 Vinstallation_directory = Qnil; 507 Vinstallation_directory = Qnil;
498 508
499 if (!NILP (Vinvocation_directory)) 509 if (!NILP (Vinvocation_directory))
@@ -1788,7 +1798,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1788 /* Init buffer storage and default directory of main buffer. */ 1798 /* Init buffer storage and default directory of main buffer. */
1789 init_buffer (); 1799 init_buffer ();
1790 1800
1791 init_callproc_1 (); /* Must precede init_cmdargs and init_sys_modes. */ 1801 init_vars_for_load (argv[0], original_pwd);
1792 1802
1793 /* Must precede init_lread. */ 1803 /* Must precede init_lread. */
1794 init_cmdargs (argc, argv, skip_args, original_pwd); 1804 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;
4430extern Lisp_Object decode_env_path (const char *, const char *, bool); 4430extern Lisp_Object decode_env_path (const char *, const char *, bool);
4431extern Lisp_Object empty_unibyte_string, empty_multibyte_string; 4431extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
4432extern AVOID terminate_due_to_signal (int, int); 4432extern AVOID terminate_due_to_signal (int, int);
4433extern void set_invocation_vars (char *argv0, char const *original_pwd); 4433extern void init_vars_for_load (char *, char const *);
4434#ifdef WINDOWSNT 4434#ifdef WINDOWSNT
4435extern Lisp_Object Vlibrary_cache; 4435extern Lisp_Object Vlibrary_cache;
4436#endif 4436#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)
5587 5587
5588 /* Once we can allocate and before loading .eln files we must set 5588 /* Once we can allocate and before loading .eln files we must set
5589 Vinvocation_directory (.eln paths are relative to it). */ 5589 Vinvocation_directory (.eln paths are relative to it). */
5590 set_invocation_vars (argv0, original_pwd); 5590 init_vars_for_load (argv0, original_pwd);
5591
5591 dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS); 5592 dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS);
5592 dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS); 5593 dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS);
5593 initialized = true; 5594 initialized = true;