diff --git a/racket/collects/compiler/private/cm-minimal.rkt b/racket/collects/compiler/private/cm-minimal.rkt index 9061b426f5..399784ca09 100644 --- a/racket/collects/compiler/private/cm-minimal.rkt +++ b/racket/collects/compiler/private/cm-minimal.rkt @@ -158,7 +158,7 @@ (and (pair? p) (cdr p))) (define deps-imports cdddr) -(define (get-compilation-path path->mode roots path) +(define (get-compilation-path path->mode roots path #:for-lock? [for-lock? #f]) (let-values ([(dir name) (get-compilation-dir+name path #:modes (list (path->mode path)) #:roots roots @@ -167,7 +167,8 @@ ;; may pick the first root where there's no ".dep" ;; written yet when the second root on has a ".dep" ;; and the ".zo" is not yet in place - #:default-root (if (cross-multi-compile? roots) + #:default-root (if (and (not for-lock?) + (cross-multi-compile? roots)) (cadr roots) (car roots)))]) (build-path dir name))) @@ -702,6 +703,11 @@ (touch zo-name) #f] [else + (define lock-zo-name (if (cross-multi-compile? roots) + ;; Make sure we use a file path for the lock that is consistent + ;; with being in a phase of compiling for the current machine: + (path-add-extension (get-compilation-path path->mode roots path) #".zo") + zo-name)) ;; Called when `tryng-sha1?` is #f and this process (or some process) ;; needs to compile, recompile, or touch: (define (build #:just-touch? [just-touch? #f] @@ -711,7 +717,7 @@ #:use-existing-deps [use-existing-deps #f]) (define lc (parallel-lock-client)) (when lc (log-compile-event path 'locking)) - (define locked? (and lc (lc 'lock zo-name))) + (define locked? (and lc (lc 'lock lock-zo-name))) (define ok-to-compile? (or (not lc) locked?)) (dynamic-wind (lambda () (void)) @@ -756,7 +762,7 @@ [else 'finish-compile]) 'already-done)) (when locked? - (lc 'unlock zo-name)))) + (lc 'unlock lock-zo-name)))) #f) ;; Called to recompile bytecode that is currently in ;; machine-independent form: @@ -776,8 +782,8 @@ (define (build/sync) (define lc (parallel-lock-client)) (when lc - (when (lc 'lock zo-name) - (lc 'unlock zo-name))) + (when (lc 'lock lock-zo-name) + (lc 'unlock lock-zo-name))) #f) ;; ---------------------------------------- ;; Determine whether and how to rebuild the file: