From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#20272: Support reproducible builds Date: Fri, 12 Feb 2016 11:29:23 -0500 Message-ID: <87a8n5vqn0.fsf@netris.org> References: <87twws88hr.fsf@gnu.org> <87vb5vn2nw.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1455294677 28696 80.91.229.3 (12 Feb 2016 16:31:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Feb 2016 16:31:17 +0000 (UTC) Cc: 20272@debbugs.gnu.org To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Feb 12 17:31:07 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aUGcd-00031f-7N for guile-bugs@m.gmane.org; Fri, 12 Feb 2016 17:31:07 +0100 Original-Received: from localhost ([::1]:34100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUGcZ-0005Gl-9Z for guile-bugs@m.gmane.org; Fri, 12 Feb 2016 11:31:03 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUGbe-0004YZ-7a for bug-guile@gnu.org; Fri, 12 Feb 2016 11:30:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUGba-0002P4-5G for bug-guile@gnu.org; Fri, 12 Feb 2016 11:30:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUGba-0002O3-2G for bug-guile@gnu.org; Fri, 12 Feb 2016 11:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aUGbZ-0004Dx-ON for bug-guile@gnu.org; Fri, 12 Feb 2016 11:30:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 12 Feb 2016 16:30:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20272 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20272-submit@debbugs.gnu.org id=B20272.145529457816187 (code B ref 20272); Fri, 12 Feb 2016 16:30:01 +0000 Original-Received: (at 20272) by debbugs.gnu.org; 12 Feb 2016 16:29:38 +0000 Original-Received: from localhost ([127.0.0.1]:38140 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aUGbB-0004D0-Jh for submit@debbugs.gnu.org; Fri, 12 Feb 2016 11:29:37 -0500 Original-Received: from world.peace.net ([50.252.239.5]:49125 ident=hope9) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aUGb9-0004Cs-17 for 20272@debbugs.gnu.org; Fri, 12 Feb 2016 11:29:35 -0500 Original-Received: from [10.1.10.78] (helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aUGay-0000fF-Km; Fri, 12 Feb 2016 11:29:24 -0500 In-Reply-To: <87vb5vn2nw.fsf@netris.org> (Mark H. Weaver's message of "Thu, 11 Feb 2016 02:09:55 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.90 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7960 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mark H Weaver writes: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Currently .go files embed randomly-generated symbols stemming from >> =E2=80=98syntax-session-id=E2=80=99, which prevents reproducible builds = (see >> .) > > I've given this more thought, and I think I have a way that avoids > session-ids altogether. > > Currently, we include both the session-id and a global gensym counter in > the names of freshly generated marks and labels in psyntax.scm. > Instead, let them include the module name and a per-module counter. I've attached a preliminary implementation of this idea, but I'm not yet confident in its correctness. Mark --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-PRELIMINARY-psyntax-Remove-uses-of-syntax-session-id.patch Content-Description: [PATCH] PRELIMINARY: psyntax: Remove uses of syntax-session-id >From c5ce1d3ac0ccf76e0ceadf4980f2cd72379b31d8 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 12 Feb 2016 11:19:38 -0500 Subject: [PATCH] PRELIMINARY: psyntax: Remove uses of syntax-session-id. This is an attempted fix for , but I'm not yet confident in its correctness. * module/ice-9/boot-9.scm (module-generate-unique-id!): New procedure. (module): Add 'next-unique-id' field. (the-root-module): Inherit 'next-unique-id' value from early stub. (make-module, make-autoload-interface): Adjust calls to module-constructor. * module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique identifiers from the module name and the per-module unique-id. --- module/ice-9/boot-9.scm | 25 +++++++++++++++++++++---- module/ice-9/psyntax-pp.scm | 15 +++++++++++++-- module/ice-9/psyntax.scm | 13 ++++++++++--- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 872594b..1b1f185 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -1,6 +1,6 @@ ;;; -*- mode: scheme; coding: utf-8; -*- -;;;; Copyright (C) 1995-2014 Free Software Foundation, Inc. +;;;; Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -381,6 +381,12 @@ If there is no handler at all, Guile prints an error and then exits." (define (module-ref module sym) (let ((v (module-variable module sym))) (if v (variable-ref v) (error "badness!" (pk module) (pk sym))))) +(define module-generate-unique-id! + (let ((next-id 0)) + (lambda (m) + (let ((i next-id)) + (set! next-id (+ i 1)) + i)))) (define (resolve-module . args) #f) @@ -2018,7 +2024,8 @@ VALUE." submodules submodule-binder public-interface - filename))) + filename + next-unique-id))) ;; make-module &opt size uses binder @@ -2046,7 +2053,7 @@ VALUE." (make-hash-table %default-import-size) '() (make-weak-key-hash-table 31) #f - (make-hash-table 7) #f #f #f)) + (make-hash-table 7) #f #f #f 0)) @@ -2653,6 +2660,11 @@ VALUE." (let ((m (make-module 0))) (set-module-obarray! m (%get-pre-modules-obarray)) (set-module-name! m '(guile)) + + ;; Inherit next-unique-id from preliminary stub of + ;; %module-get-next-unique-id! defined above. + (set-module-next-unique-id! m (module-generate-unique-id! #f)) + m)) ;; The root interface is a module that uses the same obarray as the @@ -2681,6 +2693,11 @@ VALUE." the-root-module (error "unexpected module to resolve during module boot" name))) +(define (module-generate-unique-id! m) + (let ((i (module-next-unique-id m))) + (set-module-next-unique-id! m (+ i 1)) + i)) + ;; Cheat. These bindings are needed by modules.c, but we don't want ;; to move their real definition here because that would be unnatural. ;; @@ -3010,7 +3027,7 @@ VALUE." #:warning "Failed to autoload ~a in ~a:\n" sym name)))) (module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f (make-hash-table 0) '() (make-weak-value-hash-table 31) #f - (make-hash-table 0) #f #f #f))) + (make-hash-table 0) #f #f #f 0))) (define (module-autoload! module . args) "Have @var{module} automatically load the module named @var{name} when one diff --git a/module/ice-9/psyntax-pp.scm b/module/ice-9/psyntax-pp.scm index 1ec5107..c81b69e 100644 --- a/module/ice-9/psyntax-pp.scm +++ b/module/ice-9/psyntax-pp.scm @@ -312,7 +312,12 @@ (values x (car w))))) (gen-label (lambda () - (string-append "l-" (session-id) (symbol->string (gensym "-"))))) + (let ((mod (current-module))) + (simple-format + #f + "l-~s~s" + (module-generate-unique-id! mod) + (module-name mod))))) (gen-labels (lambda (ls) (if (null? ls) '() (cons (gen-label) (gen-labels (cdr ls)))))) @@ -960,7 +965,13 @@ ((transformer-environment (lambda (k) (k e r w s rib mod)))) (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod)) - (gensym (string-append "m-" (session-id) "-"))))))) + (let ((mod (current-module))) + (string->symbol + (simple-format + #f + "m-~s~s" + (module-generate-unique-id! mod) + (module-name mod))))))))) (expand-body (lambda (body outer-form r w mod) (let* ((r (cons '("placeholder" placeholder) r)) diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 79b353d..b9110f7 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -1,7 +1,7 @@ ;;;; -*-scheme-*- ;;;; ;;;; Copyright (C) 2001, 2003, 2006, 2009, 2010, 2011, -;;;; 2012, 2013 Free Software Foundation, Inc. +;;;; 2012, 2013, 2016 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -642,7 +642,10 @@ ;; labels must be comparable with "eq?", have read-write invariance, ;; and distinct from symbols. (define (gen-label) - (string-append "l-" (session-id) (symbol->string (gensym "-")))) + (let ((mod (current-module))) + (simple-format #f "l-~s~s" + (module-generate-unique-id! mod) + (module-name mod)))) (define gen-labels (lambda (ls) @@ -671,7 +674,11 @@ (cons 'shift (wrap-subst w))))) (define-syntax-rule (new-mark) - (gensym (string-append "m-" (session-id) "-"))) + (let ((mod (current-module))) + (string->symbol + (simple-format #f "m-~s~s" + (module-generate-unique-id! mod) + (module-name mod))))) ;; make-empty-ribcage and extend-ribcage maintain list-based ribcages for ;; internal definitions, in which the ribcages are built incrementally -- 2.6.3 --=-=-=--