Tree-shake the clojure.core prelude too (whole-program DCE)
--tree-shake now shakes the clojure.core/stdlib prelude in the same reachability graph as the app + libraries — only core fns actually reached from -main ship. dce-blob-records reads prelude.ss with Chez `read`, unwraps each (guard ... (def-var! "ns" "name" V)) and builds the core->core call graph from the (var-deref/jolt-var "ns" "name") refs in V — the real emitted edges, no re-analysis. bld-shake-all merges core + app records into one BFS; roots are -main, side-effecting forms, and the clojure.core fns the runtime .ss shims reference by name (enumerated in dce-runtime-core-roots). The shaken core is spliced where the prelude.ss blob was, in original (tier) order, so load-time deps are preserved. Bail (reachable runtime resolve) keeps the prelude whole. Soundness follows Stalin's rule (any reference, value or call, keeps a def live): dce-collect-refs counts :var and :the-var; non-def registration forms are always kept (covers protocol/multimethod dispatch). Validated by make shakesmoke: the four deps.edn git-lib apps build byte-identical output shaken vs not. Wins (binary): build-app 9.84MB -> 8.12MB (dropped 403/457 core defs); malli-app 10.0MB -> 8.1MB; markdown 9.9 -> 8.3; commonmark 9.8 -> 8.1 — all output-identical. build-smoke asserts an unused core fn (group-by) is dropped; full make test green.
This commit is contained in:
parent
f7fd73c448
commit
298ac66fb1
3 changed files with 96 additions and 38 deletions
|
|
@ -96,4 +96,8 @@ fi
|
|||
if grep -q 'def-var! "jolt.analyzer"' "$out.build/flat.ss"; then
|
||||
echo " FAIL: --tree-shake kept the compiler image in a no-eval app"; exit 1
|
||||
fi
|
||||
echo "build smoke: passed (release + optimized + direct-link + tree-shake + compiler-drop)"
|
||||
# Core is shaken: a clojure.core overlay fn this app never uses is dropped.
|
||||
if grep -q 'def-var! "clojure.core" "group-by"' "$out.build/flat.ss"; then
|
||||
echo " FAIL: --tree-shake kept an unreachable clojure.core fn (group-by)"; exit 1
|
||||
fi
|
||||
echo "build smoke: passed (release + optimized + direct-link + tree-shake + compiler+core shake)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue