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 15:51:12 +0200 Message-ID: <8761t19t4f.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1381672643 12394 80.91.229.3 (13 Oct 2013 13:57:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Oct 2013 13:57:23 +0000 (UTC) To: 15602@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Oct 13 15:57:26 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 1VVMAf-0001vz-Bm for guile-bugs@m.gmane.org; Sun, 13 Oct 2013 15:57:25 +0200 Original-Received: from localhost ([::1]:33219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVMAe-0002FY-TO for guile-bugs@m.gmane.org; Sun, 13 Oct 2013 09:57:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVMAT-0002EU-2F for bug-guile@gnu.org; Sun, 13 Oct 2013 09:57:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVMAJ-00023Y-Jh for bug-guile@gnu.org; Sun, 13 Oct 2013 09:57:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVMAJ-00023T-Fx for bug-guile@gnu.org; Sun, 13 Oct 2013 09:57:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VVMAI-0006Fd-Qs for bug-guile@gnu.org; Sun, 13 Oct 2013 09: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 13:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15602 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.138167261624021 (code B ref -1); Sun, 13 Oct 2013 13:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Oct 2013 13:56:56 +0000 Original-Received: from localhost ([127.0.0.1]:45772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVMAA-0006FN-RJ for submit@debbugs.gnu.org; Sun, 13 Oct 2013 09:56:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:32984) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VVMA2-0006FE-Cg for submit@debbugs.gnu.org; Sun, 13 Oct 2013 09:56:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVM9n-00021n-JZ for submit@debbugs.gnu.org; Sun, 13 Oct 2013 09:56:40 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:45156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVM9n-00021i-Fh for submit@debbugs.gnu.org; Sun, 13 Oct 2013 09:56:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVM9g-0002DB-4o for bug-guile@gnu.org; Sun, 13 Oct 2013 09:56:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVM9Y-0001yv-QC for bug-guile@gnu.org; Sun, 13 Oct 2013 09:56:24 -0400 Original-Received: from hera.aquilenet.fr ([141.255.128.1]:38556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVM9Y-0001yb-Fz for bug-guile@gnu.org; Sun, 13 Oct 2013 09:56:16 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 118D516FC for ; Sun, 13 Oct 2013 15:51:14 +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 6Pm2Yqr1QfXg for ; Sun, 13 Oct 2013 15:51:13 +0200 (CEST) Original-Received: from pluto (reverse-83.fdn.fr [80.67.176.83]) by hera.aquilenet.fr (Postfix) with ESMTPSA id A2FD516D4 for ; Sun, 13 Oct 2013 15:51:13 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 21 =?UTF-8?Q?Vend=C3=A9miaire?= an 222 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:7303 Archived-At: Consider these three modules: --8<---------------cut here---------------start------------->8--- (define-module (one) #:use-module (srfi srfi-9) #:export (run-time expansion-time)) (define run-time 'one) (define-syntax expansion-time (identifier-syntax 'one)) --8<---------------cut here---------------end--------------->8--- two.scm: --8<---------------cut here---------------start------------->8--- (define-module (two) #:use-module (one) #:export (bar)) (define bar (list run-time)) --8<---------------cut here---------------end--------------->8--- and three.scm: --8<---------------cut here---------------start------------->8--- (define-module (three) #:use-module (two)) (define chbouib bar) --8<---------------cut here---------------end--------------->8--- And now see how the order influences the compilation result: --8<---------------cut here---------------start------------->8--- $ guile --no-auto-compile -L . -c '(use-modules (system base compile)) (for= -each compile-file (list "one.scm" "two.scm" "three.scm"))' $ guile --no-auto-compile -L . -c '(use-modules (system base compile)) (for= -each compile-file (list "three.scm" "two.scm" "one.scm"))' $ guile --no-auto-compile -L . -c '(use-modules (system base compile)) (for= -each compile-file (list "one.scm" "three.scm" "two.scm"))' Backtrace: In system/base/compile.scm: 153: 19 [# #] 216: 18 [read-and-compile # #:from ...] 232: 17 [lp () #f #] 180: 16 [lp (#) (define-module # # .= ..) ...] In ice-9/boot-9.scm: 2325: 15 [save-module-excursion #] In language/scheme/compile-tree-il.scm: 31: 14 [#] In ice-9/psyntax.scm: 1091: 13 [expand-top-sequence ((define-module (three) #:use-module ...)) ()= ...] 976: 12 [scan ((define-module (three) #:use-module ...)) () ...] 270: 11 [scan ((#(syntax-object let # ...) (#) (# #) ...)) () ...] In ice-9/eval.scm: 411: 10 [eval # ()] In ice-9/boot-9.scm: 2875: 9 [define-module* (three) #:filename ...] 2850: 8 [resolve-imports (((two)))] 2788: 7 [resolve-interface (two) #:select ...] 2713: 6 [# # ...] 2986: 5 [try-module-autoload (two) #f] 2325: 4 [save-module-excursion #] 3006: 3 [#] In unknown file: ?: 2 [primitive-load-path "two" ...] In two.scm: 1: 1 [#] In ice-9/boot-9.scm: 106: 0 [# mi= sc-error ...] ice-9/boot-9.scm:106:20: In procedure #: ice-9/boot-9.scm:106:20: In procedure #: Unbound vari= able: run-time --8<---------------cut here---------------end--------------->8--- So, what happened? In the last case (one, three, two), the compiler: 1. compiles =E2=80=98one.scm=E2=80=99, which creates module (one) in the = global name space with just =E2=80=98expansion-time=E2=80=99 in its exported bindi= ngs; 2. when compiling =E2=80=98three.scm=E2=80=99, it loads =E2=80=98two.scm= =E2=80=99; since (two) uses (one), it does =E2=80=98(resolve-module '(one))=E2=80=99, and since (o= ne) 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 failure. 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 al= l module side effects are isolated. 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-fi= le=E2=80=99, so that=E2=80=99s not really a solution when there are many files. Thanks, Ludo=E2=80=99.