emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] pdumper e875742: More fixes of the MS-Windows build.


From: Eli Zaretskii
Subject: [Emacs-diffs] pdumper e875742: More fixes of the MS-Windows build.
Date: Wed, 14 Feb 2018 11:16:35 -0500 (EST)

branch: pdumper
commit e8757425cbe66037c7cfcb767fa0388dd0489203
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    More fixes of the MS-Windows build.
    
    This finally gets Emacs to dump itself to the correct place,
    and find and load the .pdmp file after dumping.  It then
    crashes due to the assertion in prepare_to_modify_buffer_1.
---
 lisp/loadup.el |  4 +++-
 src/emacs.c    | 58 +++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/lisp/loadup.el b/lisp/loadup.el
index b047561..13c1c50 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -479,8 +479,10 @@ lost after dumping")))
       (condition-case ()
           (delete-file output)
         (file-error nil))
+      ;; On MS-Windows, the current directory is not necessarily the
+      ;; same as invocation-directory.
       (if (member dump-mode '("pdump" "pbootstrap"))
-          (dump-emacs-portable output)
+          (dump-emacs-portable (expand-file-name output invocation-directory))
         (dump-emacs output "temacs")
         (message "%d pure bytes used" pure-bytes-used)
         ;; Recompute NAME now, so that it isn't set when we dump.
diff --git a/src/emacs.c b/src/emacs.c
index d8ebdaf..c4c5e3f 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -739,6 +739,9 @@ load_dump (int *inout_argc, char ***inout_argv, const char 
*argv0_base)
   char **argv = *inout_argv;
   const char *suffix = ".pdmp";
   enum pdumper_load_result result;
+#ifdef WINDOWSNT
+  size_t argv0_len;
+#endif
 
   /* Look for an explicitly-specified dump file.  */
 
@@ -768,6 +771,13 @@ load_dump (int *inout_argc, char ***inout_argv, const char 
*argv0_base)
      should have the same basename.  */
 
   dump_file = alloca (strlen (argv[0]) + strlen (suffix) + 1);
+#ifdef WINDOWSNT
+  /* Remove the .exe extension if present.  */
+  argv0_len = strlen (argv[0]);
+  if (argv0_len >= 4 && c_strcasecmp (argv[0] + argv0_len - 4, ".exe") == 0)
+    sprintf (dump_file, "%.*s%s", argv0_len - 4, argv[0], suffix);
+  else
+#endif
   sprintf (dump_file, "%s%s", argv[0], suffix);
 
   result = pdumper_load (dump_file);
@@ -782,6 +792,8 @@ load_dump (int *inout_argc, char ***inout_argv, const char 
*argv0_base)
      "emacs" in "emacs.pdmp" so that the Emacs binary still works
      if the user copies and renames it.  */
   argv0_base = "emacs";
+  /* FIXME: On MS-Windows, PATH_EXEC starts with a literal
+     "%emacs_dir%", so it will never work without some tweaking.  */
   dump_file = alloca (strlen (PATH_EXEC)
                       + 1
                       + strlen (argv0_base)
@@ -800,12 +812,6 @@ load_dump (int *inout_argc, char ***inout_argv, const char 
*argv0_base)
 }
 #endif /* HAVE_PDUMPER */
 
-static double
-timeval_to_double (struct timeval tv)
-{
-  return tv.tv_sec + tv.tv_usec / 1e6;
-}
-
 /* ARGSUSED */
 int
 main (int argc, char **argv)
@@ -850,6 +856,23 @@ main (int argc, char **argv)
 #endif
   const char *loaded_dump = NULL;
 
+#if defined WINDOWSNT || defined HAVE_NTGUI
+  /* Set global variables used to detect Windows version.  Do this as
+     early as possible.  (unexw32.c calls this function as well, but
+     the additional call here is harmless.) */
+  cache_system_info ();
+#ifdef WINDOWSNT
+  /* On Windows 9X, we have to load UNICOWS.DLL as early as possible,
+     to have non-stub implementations of APIs we need to convert file
+     names between UTF-8 and the system's ANSI codepage.  */
+  maybe_load_unicows_dll ();
+  /* Initialize the codepage for file names, needed to decode
+     non-ASCII file names during startup.  */
+  w32_init_file_name_codepage ();
+#endif
+  w32_init_main_thread ();
+#endif
+
   const char *dump_mode = NULL;
   if (!initialized && is_temacs)
     {
@@ -882,8 +905,10 @@ main (int argc, char **argv)
       loaded_dump = load_dump (&argc, &argv, argv0_base);
       struct timeval end ;
       gettimeofday (&end, NULL);
-      fprintf (stderr, "load_dump completed in %g milliseconds\n",
-               1000.0 * (timeval_to_double (end) - timeval_to_double (start)));
+      double tdif =
+       1000.0 * (end.tv_sec - start.tv_sec)
+       + (end.tv_usec - start.tv_usec) / 1.0e3;
+      fprintf (stderr, "load_dump completed in %g milliseconds\n", tdif);
 #endif
     }
 
@@ -916,23 +941,6 @@ main (int argc, char **argv)
     }
 #endif
 
-#if defined WINDOWSNT || defined HAVE_NTGUI
-  /* Set global variables used to detect Windows version.  Do this as
-     early as possible.  (unexw32.c calls this function as well, but
-     the additional call here is harmless.) */
-  cache_system_info ();
-#ifdef WINDOWSNT
-  /* On Windows 9X, we have to load UNICOWS.DLL as early as possible,
-     to have non-stub implementations of APIs we need to convert file
-     names between UTF-8 and the system's ANSI codepage.  */
-  maybe_load_unicows_dll ();
-  /* Initialize the codepage for file names, needed to decode
-     non-ASCII file names during startup.  */
-  w32_init_file_name_codepage ();
-#endif
-  w32_init_main_thread ();
-#endif
-
 #ifdef RUN_TIME_REMAP
   if (initialized)
     run_time_remap (argv[0]);



reply via email to

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