raco exe: fix excessive memory use

Avoid retaining namespaces that are created to gather runtime paths.
If expansion generates a lot of instances with a lot of type
information, for example, this repair can save a lot of space.
This commit is contained in:
Matthew Flatt 2018-12-06 21:13:12 -07:00
parent f9551bcaa5
commit 9ce4dd8770

View File

@ -546,18 +546,28 @@
(module-compiled-submodules code #f null)
#t
null))
(eval no-submodule-code)
(let ([module-path
(if (path? module-path)
(path->complete-path module-path)
module-path)])
(unless (module-declared? module-path)
(parameterize ([current-module-declare-name
(module-path-index-resolve (module-path-index-join
module-path
#f))])
(eval no-submodule-code)))
(define e (expand `(,#'module m racket/kernel
(#%require (only ,module-path)
racket/runtime-path)
(runtime-paths ,module-path))))
(syntax-case e (quote)
[(_ m mz (#%mb req (quote (spec ...))))
(syntax->datum #'(spec ...))]
(for/list ([p (in-list (syntax->datum #'(spec ...)))])
;; Strip variable reference from 'module specs, because
;; we don't need them and they retain the namespace:
(if (and (pair? p) (eq? 'module (car p)))
(list 'module (cadr p))
p))]
[_else (error 'create-empbedding-executable
"expansion mismatch when getting external paths: ~e"
(syntax->datum e))]))))]