>From a6364c408a156a413d1833992790877f974187d1 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sun, 20 Dec 2015 01:57:34 +0100 Subject: [PATCH 1/2] Remove build system name from deterministic dumps * 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 | 13 +++++++++++++ lisp/version.el | 7 ++++--- src/emacs.c | 10 ++++++++++ src/sysdep.c | 7 +++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 0b7b403..abbe7f8 100644 --- a/configure.ac +++ b/configure.ac @@ -542,6 +542,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. diff --git a/lisp/version.el b/lisp/version.el index 43103fd..a3f0ea0 100644 --- a/lisp/version.el +++ b/lisp/version.el @@ -38,12 +38,13 @@ emacs-minor-version "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) diff --git a/src/emacs.c b/src/emacs.c index 2e9f950..863473a 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -925,6 +925,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, @@ -2566,6 +2569,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); diff --git a/src/sysdep.c b/src/sysdep.c index 1af323e..5bbf723 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1399,6 +1399,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 -- 2.5.0