compiler/cm: don't misue old .dep files

The `get-compiled-file-sha1` function assumed that a ".dep" file is
up-to-date when present. That may not be consistent with all uses,
including in `file-stamp-in-paths` as used by DrRacket for "populate
compiled", and an old file can go wrong with the recent ".dep" format
change. Make `get-compiled-file-sha1` at least check the version on
the ".dep" content before trying to use it.

Relevant to #2354
This commit is contained in:
Matthew Flatt 2018-11-02 20:22:21 -06:00
parent 93def1f753
commit 1293674ddb

View File

@ -521,7 +521,11 @@
(string-append (string-append
(call-with-input-file* path sha1) (call-with-input-file* path sha1)
(with-handlers ([exn:fail:filesystem? (lambda (exn) "")]) (with-handlers ([exn:fail:filesystem? (lambda (exn) "")])
(call-with-input-file* dep-path (lambda (p) (cdaddr (read p)))))))))) (call-with-input-file* dep-path (lambda (p)
(define deps (read p))
(and (equal? (version) (car deps))
(equal? (system-type 'vm) (cadr deps))
(cdaddr deps))))))))))
(define (get-compiled-sha1 path->mode roots path) (define (get-compiled-sha1 path->mode roots path)
(define-values (dir name) (get-compilation-dir+name path #:modes (list (path->mode path)) #:roots roots)) (define-values (dir name) (get-compilation-dir+name path #:modes (list (path->mode path)) #:roots roots))