Drop the compiler image from no-eval binaries (footprint)
An AOT-compiled app only needs the analyzer/back end at runtime to compile from source — eval / load-string / load-file. Macros are expanded at build time and a require of a baked namespace no-ops, so a closed app that never compiles at runtime carries the compiler image (~0.8MB) as dead weight. Under --tree-shake, when reachability is trustworthy (no bail) and no reachable code references eval/load-string/load-file/load-reader/load, omit host/chez/seed/image.ss + compile-eval.ss from the runtime manifest. bld-tree-shake returns the flag alongside the shaken forms; bld-emit-runtime filters the manifest. Measured: build-app 9.84MB -> 9.05MB, still runs. Safety verified: an app that evals keeps the compiler (eval is a bail + compile ref) and eval works at runtime. build-smoke asserts the compiler is gone in the no-eval app; full make test green.
This commit is contained in:
parent
20c5b92ea8
commit
3c5d548b70
3 changed files with 61 additions and 35 deletions
|
|
@ -117,6 +117,14 @@
|
|||
"clojure.core/load-string" "clojure.core/load-file" "clojure.core/load-reader"
|
||||
"clojure.core/load"))
|
||||
|
||||
;; A reference that needs the analyzer/back end at runtime (compile-from-source). If
|
||||
;; reachable code uses none of these, the compiler image can be dropped from the
|
||||
;; binary — the AOT app is fully compiled. (resolve/require don't need it: resolve is
|
||||
;; a var-table lookup; a require of a baked ns no-ops.)
|
||||
(define dce-compile-refs
|
||||
'("clojure.core/eval" "clojure.core/load-string" "clojure.core/load-file"
|
||||
"clojure.core/load-reader" "clojure.core/load"))
|
||||
|
||||
;; One record per form: (vector keep? fqn refs str). keep? #t = a non-def form,
|
||||
;; always emitted, its refs are reachability roots; #f = a prunable def emitted only
|
||||
;; if fqn is reached. A macro is a prunable def (its expander isn't called at runtime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue