unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#21613: Include messes up when compiling file in load path
@ 2015-10-04 14:36 Taylan Ulrich Bayırlı/Kammer
  2015-10-04 22:31 ` Taylan Ulrich Bayırlı/Kammer
  2016-06-24 14:49 ` Andy Wingo
  0 siblings, 2 replies; 4+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2015-10-04 14:36 UTC (permalink / raw)
  To: 21613

When a file to be compiled, A.scm, contains (include "B.scm"), the
compiler fails to find B.scm if the directory containing A and B are in
Guile's load path.

Here's a shell transcript showcasing the bug:

--- snip ---
$ mkdir test
$ echo '(include "test2.scm")' > test/test1.scm
$ echo '(display "foo\n")' > test/test2.scm
$ pwd
/home/taylan
$ export GUILE_LOAD_PATH=/home/taylan/test
$ unset GUILE_LOAD_COMPILED_PATH
$ guile -q
GNU Guile 2.0.11
Copyright (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (compile-file "/home/taylan/test/test1.scm")
ice-9/boot-9.scm:106:20: In procedure #<procedure 248a580 at ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: In procedure open-file: No such file or directory: "./test2.scm"

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(#{ g269}#) [1]>
--- snip ---

This seems to be related to 'compile-file' setting
'%file-port-name-canonicalization' to 'relative', but I don't know what
the correct fix is.

Taylan





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#21613: Include messes up when compiling file in load path
  2015-10-04 14:36 bug#21613: Include messes up when compiling file in load path Taylan Ulrich Bayırlı/Kammer
@ 2015-10-04 22:31 ` Taylan Ulrich Bayırlı/Kammer
  2016-06-21  8:49   ` Taylan Ulrich Bayırlı/Kammer
  2016-06-24 14:49 ` Andy Wingo
  1 sibling, 1 reply; 4+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2015-10-04 22:31 UTC (permalink / raw)
  To: 21613

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

taylanbayirli@gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:

> This seems to be related to 'compile-file' setting
> '%file-port-name-canonicalization' to 'relative', but I don't know
> what the correct fix is.

With the following trivial patch changing 'relative' to 'absolute',
Guile's test suite passes and the bug seems to be fixed, but I still
don't know whether this is the right fix...


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-include-for-files-in-load-path.patch --]
[-- Type: text/x-diff, Size: 1630 bytes --]

From 3e508926631a6fe3d81f6a584352562afc0e96ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
Date: Mon, 5 Oct 2015 00:15:56 +0200
Subject: [PATCH] Fix 'include' for files in load path.

Fixes <http://debbugs.gnu.org/21613>.

* module/system/base/compile.scm (compile-file): Set
  %file-port-name-canonicalization to 'absolute by default.
(compile-and-load): Ditto.
---
 module/system/base/compile.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm
index c522b74..66eec44 100644
--- a/module/system/base/compile.scm
+++ b/module/system/base/compile.scm
@@ -136,7 +136,7 @@
                        (to 'objcode)
                        (env (default-environment from))
                        (opts '())
-                       (canonicalization 'relative))
+                       (canonicalization 'absolute))
   (with-fluids ((%file-port-name-canonicalization canonicalization))
     (let* ((comp (or output-file (compiled-file-name file)
                      (error "failed to create path for auto-compiled file"
@@ -157,7 +157,7 @@
 
 (define* (compile-and-load file #:key (from (current-language)) (to 'value)
                            (env (current-module)) (opts '())
-                           (canonicalization 'relative))
+                           (canonicalization 'absolute))
   (with-fluids ((%file-port-name-canonicalization canonicalization))
     (read-and-compile (open-input-file file)
                       #:from from #:to to #:opts opts
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#21613: Include messes up when compiling file in load path
  2015-10-04 22:31 ` Taylan Ulrich Bayırlı/Kammer
@ 2016-06-21  8:49   ` Taylan Ulrich Bayırlı/Kammer
  0 siblings, 0 replies; 4+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2016-06-21  8:49 UTC (permalink / raw)
  To: 21613

Ping with CC to Andy. :-)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#21613: Include messes up when compiling file in load path
  2015-10-04 14:36 bug#21613: Include messes up when compiling file in load path Taylan Ulrich Bayırlı/Kammer
  2015-10-04 22:31 ` Taylan Ulrich Bayırlı/Kammer
@ 2016-06-24 14:49 ` Andy Wingo
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2016-06-24 14:49 UTC (permalink / raw)
  To: Taylan Ulrich "Bayırlı/Kammer"; +Cc: 21613

On Sun 04 Oct 2015 16:36, taylanbayirli@gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:

> $ mkdir test
> $ echo '(include "test2.scm")' > test/test1.scm
> $ echo '(display "foo\n")' > test/test2.scm
> $ pwd
> /home/taylan
> $ export GUILE_LOAD_PATH=/home/taylan/test
> $ unset GUILE_LOAD_COMPILED_PATH
> $ guile -L test test/test1.scm
...
> ERROR: In procedure open-file:
> ERROR: In procedure open-file: No such file or directory: "./test2.scm"

The way this works is that test/test1.scm is opened.  To set the
port-filename of the port, Guile uses "relative" canonicalization of the
path, which will result in "test1.scm" being the port-filename, as we
found test1.scm in test/.  After that it all breaks down -- the
intention is for `include' of a relative path to look for it relative to
the dirname of the file doing the including, but (dirname "test1.scm")
is ".", so it looks for "./test2.scm"... bogus.

The intention of relative canonicalization is to allow for errors to be
signalled relative to a path-relative file name.  For example in a
recent backtrace:

In ice-9/psyntax.scm:
  1200:36  5 (expand-top-sequence ((include "test2.scm")) _ _ #f e # #)

The fact that it's ice-9/psyntax.scm comes from there.  You can build
the file locally and install it and it the debugging information doesn't
embed the full dirname of the build tree.

But, for that to work well, you really need `include-from-path' and not
`include'.  All of the uses of `include' in Guile itself are really
`include-from-path'.  And if you use `include' in a file which is in a
path... well I guess that's not working.

Clearly going backwards from a relative path to an absolute path is not
going to work.  I guess my only proposal would be to include the
absolute path of a file port, in addition to the relative path.  I guess
that would be somewhere around the call to fport_canonicalize_filename
in fports.c.

Thoughts?

Andy





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-24 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-04 14:36 bug#21613: Include messes up when compiling file in load path Taylan Ulrich Bayırlı/Kammer
2015-10-04 22:31 ` Taylan Ulrich Bayırlı/Kammer
2016-06-21  8:49   ` Taylan Ulrich Bayırlı/Kammer
2016-06-24 14:49 ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).