Source: emacs24 Version: 24.5+1-6 Severity: wishlist Tags: patch upstream User: reproducible-builds@lists.alioth.debian.org Usertags: toolchain X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org
Dear Maintainer, When bytecompiling elisp files, cl-gensym-counter is initialized from the current time, leading to unreproducible results. This can affect reproducibility [1] of some software packages that build-depend on emacs (and of emacs24 itself). I suggest to set the initial value of cl-gensym-counter from the names of the files to be compiled (see proposed patch). Test-case: cd /tmp wget https://sources.debian.net/data/main/e/emacs24/24.5+1-5/lisp/org/ob-C.el emacs -batch --no-site-file --no-site-lisp -f batch-byte-compile ob-C.el cp ob-C.elc ob-C.elc.0 sleep 1 emacs -batch --no-site-file --no-site-lisp -f batch-byte-compile ob-C.el diff ob-C.elc ob-C.elc.0 The two files should be the same, but they differ (with different #:Gnnn values) Regards, Alexis Bienvenüe. [1] https://wiki.debian.org/ReproducibleBuilds/
Description: Reproducible gensym-counter When calling batch-byte-compile, set the start value of gensym-counter from a hash of the command-line arguments instead of time, so that the compiled files can be reproducible. Author: Alexis Bienvenüe <p...@passoire.fr> Index: emacs24-24.5+1/lisp/emacs-lisp/bytecomp.el =================================================================== --- emacs24-24.5+1.orig/lisp/emacs-lisp/bytecomp.el +++ emacs24-24.5+1/lisp/emacs-lisp/bytecomp.el @@ -4625,6 +4625,10 @@ already up-to-date." (if (not noninteractive) (error "`batch-byte-compile' is to be used only with -batch")) (let ((error nil)) + ;; Init gensym-counter from command-line arguments instead of + ;; time, to get a reproducible result. + (cl-init-gensym-counter + (mapconcat 'identity (sort command-line-args-left 'string<) ";")) (while command-line-args-left (if (file-directory-p (expand-file-name (car command-line-args-left))) ;; Directory as argument. Index: emacs24-24.5+1/lisp/emacs-lisp/cl-lib.el =================================================================== --- emacs24-24.5+1.orig/lisp/emacs-lisp/cl-lib.el +++ emacs24-24.5+1/lisp/emacs-lisp/cl-lib.el @@ -261,6 +261,12 @@ so that they are registered at compile-t (defvar cl--gensym-counter (* (logand (cl--random-time) 1023) 100)) +(defun cl-init-gensym-counter (string) + "Set gensym-counter from a hash of string." + (setq cl--gensym-counter (* (logand + (string-to-number (substring (secure-hash 'sha1 string) -3) 16) + 1023) 100))) + ;;; Numbers.
_______________________________________________ Reproducible-builds mailing list Reproducible-builds@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds