From 65f692658e81c940df8b3b315be873840dcef92b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 2 Mar 2016 10:21:45 -0800 Subject: [PATCH] Deterministic build improvements * configure.ac (BUILD_DETAILS): Rename from DETERMINISTIC_DUMP, and negate its sense. Use it via AC_SUBST, not AC_DEFINE, and have its value be either empty or --no-build-details. All uses changed. Change option to --disable-build-details. * doc/lispref/cmdargs.texi (Initial Options): Document --no-build-details. * doc/lispref/internals.texi (Building Emacs): * etc/NEWS: Document --disable-build-details. * doc/lispref/intro.texi (Version Info): Say that emacs-build-time can be nil. * lisp/erc/erc-compat.el (erc-emacs-build-time): Now nil if details are omitted. * lisp/erc/erc.el (erc-cmd-SV): * lisp/version.el (emacs-build-time): Now nil if no build details. (emacs-version): Output build time only if build details. * src/Makefile.in (BUILD_DETAILS): New macro. (temacs, bootstrap-emacs): Use it. * src/emacs.c (build_details): New var. (standard_args, main): Support --no-build-details. (Vdeterministic_dump): Remove; all uses replaced by !build_details. (syms_of_emacs): Set Vbuild_details to a boolean, not to a Lisp_Object. * src/lisp.h (build_details): New decl. * src/sysdep.c (init_system_name): When !build_details, set system-name to nil, not to "elided". --- configure.ac | 19 +++++++------------ doc/emacs/cmdargs.texi | 7 +++++++ doc/lispref/internals.texi | 10 ++++++++++ doc/lispref/intro.texi | 3 ++- etc/NEWS | 9 +++++++++ lisp/erc/erc-compat.el | 5 ++--- lisp/erc/erc.el | 6 ++++-- lisp/version.el | 24 +++++++++++++----------- src/Makefile.in | 7 +++++-- src/emacs.c | 18 ++++++++---------- src/lisp.h | 3 +++ src/sysdep.c | 7 +++---- 12 files changed, 73 insertions(+), 45 deletions(-) diff --git a/configure.ac b/configure.ac index ad90ce8b6c..0de6736aee 100644 --- a/configure.ac +++ b/configure.ac @@ -546,18 +546,13 @@ 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 +BUILD_DETAILS= +AC_ARG_ENABLE([build-details], + [AS_HELP_STRING([--disable-build-details], + [Make the build more deterministic by omitting host + names, time stamps, etc. from the output.])], + [test "$enableval" = no && BUILD_DETAILS=--no-build-details]) +AC_SUBST([BUILD_DETAILS]) 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 diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index a842cb84ab..646c8da1bb 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -283,6 +283,13 @@ which will invoke Emacs with @samp{--script} and supply the name of the script file as @var{file}. Emacs Lisp then treats the @samp{#!} on this first line as a comment delimiter. +@item --no-build-details +@opindex --no-build-details +@cindex build details +@cindex deterministic build +Omit details like system name and build time from the Emacs executable, +so that builds are more deterministic. + @item -q @opindex -q @itemx --no-init-file diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 41064df5a2..fedef3d7f4 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -66,6 +66,16 @@ into the dumped Emacs. If you port Emacs to a new operating system, and are not able to implement dumping, then Emacs must load @file{loadup.el} each time it starts. +@cindex build details +@cindex deterministic build +@cindex @option{--disable-build-details} option to @command{configure} + By default the dumped @file{emacs} executable records details such +as the build time and host name. Use the +@option{--disable-build-details} option of @command{configure} to +suppress these details, so that building and installing Emacs twice +from the same sources is more likely to result in identical copies of +Emacs. + @cindex @file{site-load.el} You can specify additional files to preload by writing a library named @file{site-load.el} that loads them. You may need to rebuild Emacs diff --git a/doc/lispref/intro.texi b/doc/lispref/intro.texi index 0f42d4d8a7..2f84aeee39 100644 --- a/doc/lispref/intro.texi +++ b/doc/lispref/intro.texi @@ -494,7 +494,8 @@ giving a prefix argument makes @var{here} non-@code{nil}. @defvar emacs-build-time The value of this variable indicates the time at which Emacs was built. It is a list of four integers, like the value of -@code{current-time} (@pxref{Time of Day}). +@code{current-time} (@pxref{Time of Day}), or is @code{nil} +if the information is not available. @example @group diff --git a/etc/NEWS b/etc/NEWS index a9ce265303..cf09350d17 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -25,6 +25,15 @@ otherwise leave it unmarked. * Installation Changes in Emacs 25.2 ++++ +** New configure option ‘--disable-build-details’ attempts to build an +Emacs that is more likely to be reproducible; that is, if you build +and install Emacs twice, the second Emacs is a copy of the first. +Deterministic builds omit the build date from the output of the +emacs-version and erc-cmd-SV functions, and the leave the following +variables nil: emacs-build-system, emacs-build-time, +erc-emacs-build-time. + * Startup Changes in Emacs 25.2 diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 5e03d30bf9..e5e63092df 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -54,10 +54,10 @@ See `erc-encoding-coding-alist'." (set (make-local-variable 'write-file-functions) new-val)) (defvar erc-emacs-build-time - (if (stringp emacs-build-time) + (if (or (stringp emacs-build-time) (not emacs-build-time)) emacs-build-time (format-time-string "%Y-%m-%d" emacs-build-time)) - "Time at which Emacs was dumped out.") + "Time at which Emacs was dumped out, or nil if not available.") ;; Emacs 21 and XEmacs do not have user-emacs-directory, but XEmacs ;; has user-init-directory. @@ -164,4 +164,3 @@ If START or END is negative, it counts from the end." ;; indent-tabs-mode: t ;; tab-width: 8 ;; End: - diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 68460d15c4..52adec1ce4 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3581,7 +3581,7 @@ the message given by REASON." (defun erc-cmd-SV () "Say the current ERC and Emacs version into channel." - (erc-send-message (format "I'm using ERC with %s %s (%s%s) of %s." + (erc-send-message (format "I'm using ERC with %s %s (%s%s)%s." (if (featurep 'xemacs) "XEmacs" "GNU Emacs") emacs-version system-configuration @@ -3602,7 +3602,9 @@ the message given by REASON." x-toolkit-scroll-bars))) "") (if (featurep 'multi-tty) ", multi-tty" "")) - erc-emacs-build-time)) + (if erc-emacs-build-time + (concat " of " erc-emacs-build-time) + ""))) t) (defun erc-cmd-SM () diff --git a/lisp/version.el b/lisp/version.el index ba24964bd2..dc228870d1 100644 --- a/lisp/version.el +++ b/lisp/version.el @@ -38,14 +38,11 @@ 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.") +(defconst emacs-build-system (system-name) + "Name of the system on which Emacs was built, or nil if not available.") -(defconst emacs-build-system - (if deterministic-dump "elided" (system-name)) - "Name of the system on which Emacs was built.") +(defconst emacs-build-time (if emacs-build-system (current-time)) + "Time at which Emacs was dumped out, or nil if not available.") (defvar motif-version-string) (defvar gtk-version-string) @@ -59,9 +56,7 @@ Don't use this function in programs to choose actions according to the system configuration; look at `system-configuration' instead." (interactive "P") (let ((version-string - (format (if (not (called-interactively-p 'interactive)) - "GNU Emacs %s (%s%s%s%s)\n of %s" - "GNU Emacs %s (%s%s%s%s) of %s") + (format "GNU Emacs %s (%s%s%s%s)%s" emacs-version system-configuration (cond ((featurep 'motif) @@ -80,7 +75,14 @@ to the system configuration; look at `system-configuration' instead." (format ", %s scroll bars" (capitalize (symbol-name x-toolkit-scroll-bars))) "") - (format-time-string "%Y-%m-%d" emacs-build-time)))) + (if emacs-build-time + (format-time-string (concat + (if (called-interactively-p + 'interactive) + "" "\n") + " of %Y-%m-%d") + emacs-build-time) + "")))) (if here (insert version-string) (if (called-interactively-p 'interactive) diff --git a/src/Makefile.in b/src/Makefile.in index 8dcaf7e475..c290a6082d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -313,6 +313,9 @@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ RUN_TEMACS = ./temacs +# Whether builds should contain details. '--no-build-details' or empty. +BUILD_DETAILS = @BUILD_DETAILS@ + UNEXEC_OBJ = @UNEXEC_OBJ@ CANNOT_DUMP=@CANNOT_DUMP@ @@ -534,7 +537,7 @@ emacs$(EXEEXT): temacs$(EXEEXT) \ ifeq ($(CANNOT_DUMP),yes) ln -f temacs$(EXEEXT) $@ else - LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump + LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup dump $(PAXCTL_if_present) -zex $@ ln -f $@ bootstrap-emacs$(EXEEXT) endif @@ -740,7 +743,7 @@ bootstrap-emacs$(EXEEXT): temacs$(EXEEXT) ifeq ($(CANNOT_DUMP),yes) ln -f temacs$(EXEEXT) $@ else - $(RUN_TEMACS) --batch --load loadup bootstrap + $(RUN_TEMACS) --batch $(BUILD_DETAILS) --load loadup bootstrap $(PAXCTL_if_present) -zex emacs$(EXEEXT) mv -f emacs$(EXEEXT) $@ endif diff --git a/src/emacs.c b/src/emacs.c index e7cb4ea4aa..a381da4fb8 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -181,6 +181,9 @@ bool noninteractive; /* True means remove site-lisp directories from load-path. */ bool no_site_lisp; +/* True means put details like time stamps into builds. */ +bool build_details; + /* Name for the server started by the daemon.*/ static char *daemon_name; @@ -222,6 +225,7 @@ Initialization options:\n\ --display, -d DISPLAY use X server DISPLAY\n\ ", "\ +--no-build-details do not add build details such as time stamps\n\ --no-desktop do not load a saved desktop\n\ --no-init-file, -q load neither ~/.emacs nor default.el\n\ --no-loadup, -nl do not load loadup.el into bare Emacs\n\ @@ -872,9 +876,6 @@ 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, @@ -1192,6 +1193,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem no_site_lisp = argmatch (argv, argc, "-nsl", "--no-site-lisp", 11, NULL, &skip_args); + build_details = ! argmatch (argv, argc, "-no-build-details", + "--no-build-details", 7, NULL, &skip_args); + #ifdef HAVE_NS ns_pool = ns_alloc_autorelease_pool (); #ifdef NS_IMPL_GNUSTEP @@ -1641,6 +1645,7 @@ static const struct standard_args standard_args[] = { "-help", "--help", 90, 0 }, { "-nl", "--no-loadup", 70, 0 }, { "-nsl", "--no-site-lisp", 65, 0 }, + { "-no-build-details", "--no-build-details", 63, 0 }, /* -d must come last before the options handled in startup.el. */ { "-d", "--display", 60, 1 }, { "-display", 0, 60, 1 }, @@ -2535,13 +2540,6 @@ 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/lisp.h b/src/lisp.h index 18d986441f..9c7955e2bc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4132,6 +4132,9 @@ extern bool noninteractive; /* True means remove site-lisp directories from load-path. */ extern bool no_site_lisp; +/* True means put details like time stamps into builds. */ +extern bool build_details; + /* Pipe used to send exit notification to the daemon parent at startup. On Windows, we use a kernel event instead. */ #ifndef WINDOWSNT diff --git a/src/sysdep.c b/src/sysdep.c index b01c64d52a..a01bf1d7c1 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1408,11 +1408,10 @@ setup_pty (int fd) void init_system_name (void) { - if (DETERMINISTIC_DUMP && (might_dump || ! NILP (Vpurify_flag))) + if (!build_details) { - /* If we're dumping, set the hostname to a literal so that the - dump is deterministic. */ - Vsystem_name = build_pure_c_string ("elided"); + /* Set system-name to nil so that the build is deterministic. */ + Vsystem_name = Qnil; return; } char *hostname_alloc = NULL; -- 2.39.2