2 Commits 01206b179f ... b408ffefee

Author SHA1 Message Date
  Maxim Cournoyer b408ffefee ice-9: Fix 'include' when used in compilation contexts. 1 year ago
  Maxim Cournoyer 01206b179f ice-9: Fix 'include' when used in compilation contexts. 1 year ago
3 changed files with 15 additions and 5 deletions
  1. 13 0
      module/ice-9/boot-9.scm
  2. 2 1
      module/ice-9/psyntax.scm
  3. 0 4
      module/system/base/compile.scm

+ 13 - 0
module/ice-9/boot-9.scm

@@ -1375,6 +1375,19 @@ CONV is not applied to the initial value."
 
 
 
+;;;
+;;; This parameter captures the original compiled source file name,
+;;; before it gets potentially stripped by the file ports
+;;; canonicalization.  It is used with 'include' to locate the true
+;;; source, which is necessary when using relative paths during
+;;; compilation, for example.  It is defined here because it is used
+;;; lazily in the `include' procedure in ice-9/psyntax.scm, which is
+;;; loaded even before this module and before there is support to refer
+;;; to other modules.
+(define compilation-source-file-name (make-parameter #f))
+
+
+
 ;;; {Languages}
 ;;;
 

+ 2 - 1
module/ice-9/psyntax.scm

@@ -3273,7 +3273,8 @@ parameter is set, its value is used directly, overriding any FILENAME
 and DIRNAME argument provided."
       (let* ((filename (syntax->datum filename))
              (p (open-input-file
-                 (cond ((compilation-source-file-name) => identity)
+                 (cond ((and (defined? 'compilation-source-file-name)
+                             (compilation-source-file-name)) => identity)
                        ((absolute-file-name? filename)
                            filename)
                        (dirname

+ 0 - 4
module/system/base/compile.scm

@@ -44,10 +44,6 @@
 (define default-warning-level (make-parameter 1 level-validator))
 (define default-optimization-level (make-parameter 2 level-validator))
 
-;;; This parameter is used by `include' to locate the true source when
-;;; 'relative canonicalization strips a leading part of the source file.
-(define compilation-source-file-name (make-parameter #f))
-
 ;;;
 ;;; Compiler
 ;;;