cs: use cross-compiler server for fasl
The Chez Scheme fasl format is not machine-independent when record types are involved, so use the process that serves compilation to also serve fasl encoding.
This commit is contained in:
parent
f68248ee3b
commit
ed807f8584
|
@ -45,6 +45,9 @@
|
|||
(case cmd
|
||||
[(compile)
|
||||
(compile-to-port (list `(lambda () ,(read-fasled))) o)]
|
||||
[(fasl)
|
||||
;; Reads host fasl format, then writes target fasl format
|
||||
(fasl-write (read-fasled) o)]
|
||||
[else
|
||||
(error 'serve-cross-compile (format "unrecognized command: ~s" cmd))])
|
||||
(let ([result (get)])
|
||||
|
|
|
@ -253,9 +253,7 @@
|
|||
(define (make-cross-compile-to-bytevector machine)
|
||||
(lambda (s paths format)
|
||||
(let ([bv (cond
|
||||
[(eq? format 'interpret)
|
||||
;; fasl format is not machine-specific:
|
||||
(compile-to-bytevector s paths format)]
|
||||
[(eq? format 'interpret) (cross-fasl-to-string machine s)]
|
||||
[else (cross-compile machine s)])])
|
||||
(if compress-code?
|
||||
(bytevector-compress bv)
|
||||
|
|
|
@ -52,17 +52,23 @@
|
|||
(unsafe-place-local-set! cross-machine-compiler-cache
|
||||
(cons a (unsafe-place-local-ref cross-machine-compiler-cache)))))
|
||||
|
||||
(define (cross-compile machine v)
|
||||
(define (do-cross cmd machine v)
|
||||
(let* ([a (find-cross 'cross-compile machine)]
|
||||
[ch (cadr a)]
|
||||
[reply-ch (make-channel)])
|
||||
(channel-put ch (list 'compile
|
||||
(channel-put ch (list cmd
|
||||
v
|
||||
reply-ch))
|
||||
(begin0
|
||||
(channel-get reply-ch)
|
||||
(cache-cross-compiler a))))
|
||||
|
||||
(define (cross-compile machine v)
|
||||
(do-cross 'compile machine v))
|
||||
|
||||
(define (cross-fasl-to-string machine v)
|
||||
(do-cross 'fasl machine v))
|
||||
|
||||
;; Start a compiler as a Racket thread under the root custodian.
|
||||
;; Using Racket's scheduler lets us use the event and I/O system,
|
||||
;; including support for running a process and managing resources
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
|
||||
(define (write-linklet-bundle-hash ht dest-o)
|
||||
(let-values ([(ht cross-machine) (encode-linklet-paths ht)])
|
||||
(let ([bstr (let-values ([(o get) (open-bytevector-output-port)])
|
||||
(let ([bstr (if cross-machine
|
||||
(cross-fasl-to-string cross-machine ht)
|
||||
(let-values ([(o get) (open-bytevector-output-port)])
|
||||
(fasl-write* ht o)
|
||||
(get))])
|
||||
(get)))])
|
||||
(write-bytes (integer->integer-bytes (bytes-length bstr) 4 #f #f) dest-o)
|
||||
(write-bytes bstr dest-o))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user