`load' doesn't cause the compiler to be loaded in some cases

* module/system/base/compile.scm (compiled-file-name): Add a comment.
* module/ice-9/boot-9.scm (load): Avoid loading up (system base compile)
  just to compute an autocompiled file name. Fixes the issue whereby
  guile-tools snarf-check-and-output-texi was inadvertantly loading up
  srfi-1, and thereby a stale library, just to see if guile-tools itself
  had a compiled version.

  Not sure what the right unit test is here, other than vigilance.
This commit is contained in:
Andy Wingo 2010-02-16 21:11:27 +01:00
commit 04af4c4c52
2 changed files with 26 additions and 7 deletions

View file

@ -907,19 +907,34 @@
;; date, and autocompilation is enabled, will try autocompilation, just
;; as primitive-load-path does internally. primitive-load is
;; unaffected. Returns #f if autocompilation failed or was disabled.
(define (autocompiled-file-name name)
;;
;; NB: Unless we need to compile the file, this function should not cause
;; (system base compile) to be loaded up. For that reason compiled-file-name
;; partially duplicates functionality from (system base compile).
(define (compiled-file-name canon-path)
(and %compile-fallback-path
(string-append
%compile-fallback-path
;; no need for '/' separator here, canon-path is absolute
canon-path
(cond ((or (null? %load-compiled-extensions)
(string-null? (car %load-compiled-extensions)))
(warn "invalid %load-compiled-extensions"
%load-compiled-extensions)
".go")
(else (car %load-compiled-extensions))))))
(define (fresh-compiled-file-name go-path)
(catch #t
(lambda ()
(let* ((cfn ((@ (system base compile) compiled-file-name) name))
(scmstat (stat name))
(gostat (stat cfn #f)))
(let* ((scmstat (stat name))
(gostat (stat go-path #f)))
(if (and gostat (= (stat:mtime gostat) (stat:mtime scmstat)))
cfn
go-path
(begin
(if gostat
(format (current-error-port)
";;; note: source file ~a\n;;; newer than compiled ~a\n"
name cfn))
name go-path))
(cond
(%load-should-autocompile
(%warn-autocompilation-enabled)
@ -936,7 +951,9 @@
#f)))
(with-fluid* current-reader (and (pair? reader) (car reader))
(lambda ()
(let ((cfn (autocompiled-file-name name)))
(let ((cfn (and=> (and=> (false-if-exception (canonicalize-path name))
compiled-file-name)
fresh-compiled-file-name)))
(if cfn
(load-compiled cfn)
(start-stack 'load-stack

View file

@ -121,6 +121,8 @@
;;; compile-file explicitly, as in the srcdir != builddir case; or you
;;; don't know, in which case this function is called, and we just put
;;; them in your own ccache dir in ~/.guile-ccache.
;;;
;;; See also boot-9.scm:load.
(define (compiled-file-name file)
(define (compiled-extension)
(cond ((or (null? %load-compiled-extensions)