From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#15602: Compiling several files in the same session [2.0.9] Date: Sun, 13 Oct 2013 22:56:06 +0200 Message-ID: <87siw47uvt.fsf@gnu.org> References: <8761t19t4f.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1381697841 2704 80.91.229.3 (13 Oct 2013 20:57:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Oct 2013 20:57:21 +0000 (UTC) To: 15602@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Oct 13 22:57:25 2013 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 1VVSj4-0004OK-TU for guile-bugs@m.gmane.org; Sun, 13 Oct 2013 22:57:23 +0200 Original-Received: from localhost ([::1]:34530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVSj4-00021e-Ey for guile-bugs@m.gmane.org; Sun, 13 Oct 2013 16:57:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVSiv-00021T-GQ for bug-guile@gnu.org; Sun, 13 Oct 2013 16:57:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVSil-000157-2h for bug-guile@gnu.org; Sun, 13 Oct 2013 16:57:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVSik-000153-VH for bug-guile@gnu.org; Sun, 13 Oct 2013 16:57:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VVSij-0008Pe-Vo for bug-guile@gnu.org; Sun, 13 Oct 2013 16:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 13 Oct 2013 20:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15602 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 15602-submit@debbugs.gnu.org id=B15602.138169777332267 (code B ref 15602); Sun, 13 Oct 2013 20:57:01 +0000 Original-Received: (at 15602) by debbugs.gnu.org; 13 Oct 2013 20:56:13 +0000 Original-Received: from localhost ([127.0.0.1]:46536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVShw-0008OM-V2 for submit@debbugs.gnu.org; Sun, 13 Oct 2013 16:56:13 -0400 Original-Received: from hera.aquilenet.fr ([141.255.128.1]:46473) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVSht-0008OC-Jy for 15602@debbugs.gnu.org; Sun, 13 Oct 2013 16:56:10 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id CCF3E1704 for <15602@debbugs.gnu.org>; Sun, 13 Oct 2013 22:56:07 +0200 (CEST) Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07GoLHnAmxG5 for <15602@debbugs.gnu.org>; Sun, 13 Oct 2013 22:56:07 +0200 (CEST) Original-Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 71CC8146A for <15602@debbugs.gnu.org>; Sun, 13 Oct 2013 22:56:07 +0200 (CEST) In-Reply-To: <8761t19t4f.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 13 Oct 2013 15:51:12 +0200") User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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:7305 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > In the last case (one, three, two), the compiler: > > 1. compiles =E2=80=98one.scm=E2=80=99, which creates module (one) in th= e global name > space with just =E2=80=98expansion-time=E2=80=99 in its exported bin= dings; > > 2. when compiling =E2=80=98three.scm=E2=80=99, it loads =E2=80=98two.sc= m=E2=80=99; since (two) uses > (one), it does =E2=80=98(resolve-module '(one))=E2=80=99, and since = (one) already > exists it is used; > > however, the (one) we have comes from step 1, and lacks the > =E2=80=98run-time=E2=80=99 binding, hence the unbound variable failu= re. > > I think the right thing would be to use a separate module hierarchy in > the dynamic extent of =E2=80=98compile-file=E2=80=99, somehow, such that = all module side > effects are isolated. In Guix (the =E2=80=98guix pull=E2=80=99 command, which compiles all of Gui= x), I ended up with this: --=-=-= Content-Type: text/x-scheme; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable (define* (compile-file* file #:key output-file (opts '())) ;; Like 'compile-file', but remove any (guix =E2=80=A6) and (gnu =E2=80= =A6) modules ;; created during the process as an ugly workaround for ;; (FIXME). This ensures correctness, ;; but is overly conservative and very slow. (define (module-directory+file module) ;; Return the directory for MODULE, like the 'dir-hint' in ;; boot-9.scm. (match (module-name module) ((beginning ... last) (values (string-concatenate (map (lambda (elt) (string-append (symbol->string elt) file-name-separator-string)) beginning)) (symbol->string last))))) (define (clear-module-tree! root) ;; Delete all the modules under ROOT. (hash-for-each (lambda (name module) (module-remove! root name) (let-values (((dir name) (module-directory+file module))) (set-autoloaded! dir name #f)) (clear-module-tree! module)) (module-submodules root)) (hash-clear! (module-submodules root))) (compile-file file #:output-file output-file #:opts opts) (for-each (compose clear-module-tree! resolve-module) '((guix) (gnu)))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Of course the above can be worked around by running =E2=80=98compile-file= =E2=80=99 in a > child process, but forking alone is more expensive than =E2=80=98compile-= file=E2=80=99, > so that=E2=80=99s not really a solution when there are many files. As it turns out, the hack above is just as slow as forking: what takes time is not forking, but reloading the same modules over and over again. So we should have a way to keep modules that have been fully evaluated, and to discard modules that have not. Ideas welcome. Ludo=E2=80=99. --=-=-=--