]> code.delx.au - gnu-emacs/commitdiff
Remove build system name from deterministic dumps
authorPhilipp Stephani <phst@google.com>
Wed, 2 Mar 2016 18:21:45 +0000 (10:21 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 2 Mar 2016 18:24:11 +0000 (10:24 -0800)
* configure.ac (DETERMINISTIC_DUMP): New configuration option.
* lisp/version.el (emacs-build-time): Add a comment to make the
build time deterministic if requested.
(emacs-build-system): Make variable deterministic if requested.
* src/emacs.c (main): Initialize `deterministic-dump' from the
configuration option.
(syms_of_emacs): New constant `deterministic-dump'.
* src/sysdep.c (init_system_name): Use a constant
if a deterministic dump is requested.

configure.ac
lisp/version.el
src/emacs.c
src/sysdep.c

index 48d9df1426370482d1915187736afac410f9c4b9..ad90ce8b6cca487e923782f8d303b65e44ec2c5e 100644 (file)
@@ -546,6 +546,19 @@ AC_ARG_ENABLE(gtk-deprecation-warnings,
                [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
 
+AC_ARG_ENABLE(deterministic-dump,
+[AS_HELP_STRING([--enable-deterministic-dump],
+                [Make dumping deterministic by removing system-specific
+                information from the dump, such as host names and
+                timestamps.])])
+if test "x${enableval}" = xno ; then
+   AC_DEFINE(DETERMINISTIC_DUMP, false,
+   [Set this to true to make dumping deterministic.])
+else
+   AC_DEFINE(DETERMINISTIC_DUMP, true,
+   [Set this to true to make dumping deterministic.])
+fi
+
 dnl This used to use changequote, but, apart from 'changequote is evil'
 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
 dnl the great gob of text.  Thus it's not processed for possible expansion.
index 77188a51ee3b03e5f5895b85a2a89fe406805937..ba24964bd2554540ba884b850d09eb45bdddf02a 100644 (file)
@@ -38,12 +38,13 @@ This variable first existed in version 19.23.")
   "Minor version number of this version of Emacs.
 This variable first existed in version 19.23.")
 
+;; FIXME: The next variable should also be a constant if
+;; `deterministic-dump' is t.
 (defconst emacs-build-time (current-time)
   "Time at which Emacs was dumped out.")
 
-;; I think this should be obsoleted/removed.  It's just one more meaningless
-;; difference between different builds.  It's usually not even an fqdn.
-(defconst emacs-build-system (system-name)
+(defconst emacs-build-system
+  (if deterministic-dump "elided" (system-name))
   "Name of the system on which Emacs was built.")
 
 (defvar motif-version-string)
index c512885076c35773d12a49093853f46a2f98951b..e7cb4ea4aaae083f6c837840c317842102194abc 100644 (file)
@@ -872,6 +872,9 @@ main (int argc, char **argv)
   SET_BINARY (fileno (stdout));
 #endif /* MSDOS */
 
+  if (DETERMINISTIC_DUMP)
+    Vdeterministic_dump = Qt;
+
   /* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case.
      The build procedure uses this while dumping, to ensure that the
      dumped Emacs does not have its system locale tables initialized,
@@ -2532,6 +2535,13 @@ libraries; only those already known by Emacs will be loaded.  */);
   Vdynamic_library_alist = Qnil;
   Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt);
 
+  DEFVAR_BOOL ("deterministic-dump", Vdeterministic_dump,
+    doc: /* If non-nil, attempt to make dumping deterministic by
+avoiding sources of nondeterminism such as absolute file names, the
+hostname, or timestamps.  */);
+  Vdeterministic_dump = DETERMINISTIC_DUMP ? Qt : Qnil;
+  XSYMBOL (intern_c_string ("deterministic-dump"))->constant = 1;
+
 #ifdef WINDOWSNT
   Vlibrary_cache = Qnil;
   staticpro (&Vlibrary_cache);
index 418c50d5e78e907a70f4b00fb8d9de11b40c12bf..b01c64d52ac6c86897487a45f76fc753b8add2a1 100644 (file)
@@ -1408,6 +1408,13 @@ setup_pty (int fd)
 void
 init_system_name (void)
 {
+  if (DETERMINISTIC_DUMP && (might_dump || ! NILP (Vpurify_flag)))
+    {
+      /* If we're dumping, set the hostname to a literal so that the
+         dump is deterministic.  */
+      Vsystem_name = build_pure_c_string ("elided");
+      return;
+    }
   char *hostname_alloc = NULL;
   char *hostname;
 #ifndef HAVE_GETHOSTNAME