maybe-compile-{file,program,library} and automatic import
compilation now treat a malformed object file as if it were not present and needs to be regenerated. A malformed object file (particularly a truncated one) might occur if the compiling processes is killed or aborts before it has a chance to delete a partial object file. syntax.ss, 7.ms original commit: c2cb8c79a925c0eb2f9d589e3a497712800bd1dc
This commit is contained in:
parent
431c1af87f
commit
893dfe5d35
8
LOG
8
LOG
|
@ -744,3 +744,11 @@
|
|||
mats/examples.ms,
|
||||
examples/ez-grammar.ss, examples/ez-grammar-test.ss,
|
||||
examples/Makefile
|
||||
- maybe-compile-{file,program,library} and automatic import
|
||||
compilation now treat a malformed object file as if it were
|
||||
not present and needs to be regenerated. A malformed object
|
||||
file (particularly a truncated one) might occur if the compiling
|
||||
processes is killed or aborts before it has a chance to delete
|
||||
a partial object file.
|
||||
syntax.ss,
|
||||
7.ms
|
||||
|
|
41
mats/7.ms
41
mats/7.ms
|
@ -834,6 +834,47 @@
|
|||
(begin
|
||||
(rm-rf "testdir")
|
||||
#t)
|
||||
; make sure maybe-compile-file handles incomplete fasl files
|
||||
(begin
|
||||
(mkfile "testfile-mc-2a.ss"
|
||||
'(library (testfile-mc-2a)
|
||||
(export q)
|
||||
(import (chezscheme))
|
||||
(define f
|
||||
(lambda ()
|
||||
(printf "running f\n")
|
||||
"x"))
|
||||
(define-syntax q
|
||||
(begin
|
||||
(printf "expanding testfile-mc-2a\n")
|
||||
(lambda (x)
|
||||
(printf "expanding q\n")
|
||||
#'(f))))))
|
||||
(mkfile "testfile-mc-2.ss"
|
||||
'(import (chezscheme) (testfile-mc-2a))
|
||||
'(define-syntax qq
|
||||
(begin
|
||||
(printf "expanding testfile-mc-2\n")
|
||||
(lambda (x)
|
||||
(printf "expanding qq\n")
|
||||
#'q)))
|
||||
'(printf "qq => ~a\n" qq))
|
||||
(delete-file "testfile-mc-2a.so")
|
||||
(delete-file "testfile-mc-2.so")
|
||||
(display-string (separate-compile '(lambda (x) (parameterize ([compile-file-message #f] [compile-imported-libraries #t] [compile-compressed #f]) (maybe-compile-program x))) 'mc-2))
|
||||
#t)
|
||||
(begin
|
||||
(let ([p (open-file-input/output-port "testfile-mc-2a.so" (file-options no-create no-fail no-truncate))])
|
||||
(set-port-length! p 73)
|
||||
(close-port p))
|
||||
(display-string (separate-compile '(lambda (x) (parameterize ([compile-file-message #f] [compile-imported-libraries #t] [compile-compressed #f] [import-notify #t]) (maybe-compile-program x))) 'mc-2))
|
||||
#t)
|
||||
(begin
|
||||
(let ([p (open-file-input/output-port "testfile-mc-2.so" (file-options no-create no-fail no-truncate))])
|
||||
(set-port-length! p 87)
|
||||
(close-port p))
|
||||
(display-string (separate-compile '(lambda (x) (parameterize ([compile-file-message #f] [compile-imported-libraries #t] [compile-compressed #f] [import-notify #t]) (maybe-compile-program x))) 'mc-2))
|
||||
#t)
|
||||
)
|
||||
|
||||
(mat make-boot-file
|
||||
|
|
21
s/syntax.ss
21
s/syntax.ss
|
@ -4787,7 +4787,14 @@
|
|||
found-uid)]
|
||||
[else ($oops #f "re~:[loading~;compiling~] ~a did not define library ~s" compile-file? src-path path)])])
|
||||
(parameterize ([source-directories (cons (path-parent src-path) (source-directories))])
|
||||
($load-library obj-path (if ct? 'load 'revisit)))
|
||||
(guard (c [(and (irritants-condition? c) (member obj-path (condition-irritants c)))
|
||||
(with-message (with-output-to-string
|
||||
(lambda ()
|
||||
(display-string "failed to load object file: ")
|
||||
(display-condition c)))
|
||||
($oops/c #f ($make-recompile-condition path)
|
||||
"problem loading object file ~a ~s" obj-path c))])
|
||||
($load-library obj-path (if ct? 'load 'revisit))))
|
||||
(cond
|
||||
[(search-loaded-libraries path) =>
|
||||
(lambda (found-uid)
|
||||
|
@ -5193,8 +5200,14 @@
|
|||
(let ([ofn-mod-time (file-modification-time ofn)])
|
||||
(if (time>=? ofn-mod-time (with-new-who who (lambda () (file-modification-time ifn))))
|
||||
(with-message "object file is not older"
|
||||
(let ([rcinfo* (load-recompile-info who ofn)])
|
||||
(if (andmap
|
||||
(let ([rcinfo* (guard (c [else (with-message (with-output-to-string
|
||||
(lambda ()
|
||||
(display-string "failed to process object file: ")
|
||||
(display-condition c)))
|
||||
#f)])
|
||||
(load-recompile-info who ofn))])
|
||||
(if (and rcinfo*
|
||||
(andmap
|
||||
(lambda (rcinfo)
|
||||
(andmap
|
||||
(lambda (x)
|
||||
|
@ -5202,7 +5215,7 @@
|
|||
(lambda (x)
|
||||
(time<=? (with-new-who who (lambda () (file-modification-time x))) ofn-mod-time))))
|
||||
(recompile-info-include-req* rcinfo)))
|
||||
rcinfo*)
|
||||
rcinfo*))
|
||||
(if (compile-imported-libraries)
|
||||
(guard (c [(and ($recompile-condition? c) (eq? ($recompile-importer-path c) #f))
|
||||
(with-message (format "recompiling ~s because a dependency has changed" ifn)
|
||||
|
|
Loading…
Reference in New Issue
Block a user