compiler/cm: avoid rewriting machine-indepedent files

The multi-cross mode, don't rewrite a machine-indepedent file
by recompiling it to itself. This shouldn't matter, but not
touching files makes the result cleaner.
This commit is contained in:
Matthew Flatt 2018-12-09 11:02:09 -07:00
parent 344b72b4f8
commit db2ac559a7

View File

@ -448,6 +448,15 @@
'debug))
(define receiver (make-log-receiver accomplice-logger 'info 'cm-accomplice))
(define dest-roots (list (car roots)))
(define-values (code-dir code-name)
(get-compilation-dir+name path #:modes (list (path->mode path)) #:roots dest-roots))
(define zo-name
;; If we have multiple roots, make sure that compilation uses the first one
(if (or (pair? (cdr roots)) (not orig-zo-name))
(build-path code-dir (path-add-suffix code-name #".zo"))
orig-zo-name))
;; Compile the code:
(define code
(parameterize ([current-reader-guard
@ -482,6 +491,11 @@
managed-compiled-context-key
path
(cond
[(and (equal? recompile-from zo-name)
(not (current-compile-target-machine)))
;; We don't actually need to do anything, so
;; avoid updating the file
#f]
[recompile-from
(recompile-module-code recompile-from
path
@ -493,16 +507,9 @@
#:extension-handler (lambda (a b) #f)
#:roots (list (car roots))
#:source-reader read-src-syntax)]))))
(define dest-roots (list (car roots)))
(define-values (code-dir code-name)
(get-compilation-dir+name path #:modes (list (path->mode path)) #:roots dest-roots))
(define zo-name
;; If we have multiple roots, make sure that compilation uses the first one
(if (or (pair? (cdr roots)) (not orig-zo-name))
(build-path code-dir (path-add-suffix code-name #".zo"))
orig-zo-name))
;; Get all accomplice data:
(when code
(let loop ()
(let ([l (sync/timeout 0 receiver)])
(when l
@ -515,7 +522,7 @@
(hash-ref (file-dependency/options-table (vector-ref l 2))
'indirect
#f))))
(loop))))
(loop)))))
;; Write the code and dependencies:
(when code