Skip to content

v0.1.3

Choose a tag to compare

@yogthos yogthos released this 11 Aug 22:50
· 13 commits to main since this release
9955782

Tree shaking works again for programs that use this library. Reported and diagnosed by @sundbp, who also wrote the original change in #10.

The problem

jdbc.core reached the postgres driver through (resolve (symbol "db.pg" n)) behind a runtime require. A reachable call to resolve stops jolt from building a sound whole-program call graph, so jolt build --tree-shake skipped shaking entirely for any program that loaded jdbc.core, including sqlite-only ones. A runtime require is also the wrong dependency edge for an AOT binary, which has no source roots to load db.pg from later.

Both jdbc.core and db.jdbc-shim now require db.pg statically and call it directly.

before:  jolt build: tree-shake skipped (reachable code resolves vars at runtime)
after:   jolt build: tree-shake kept 341 of 766 defs (core 242/661)

A sqlite-only app still does not need libpq

Loading db.pg only declares the FFI bindings; ffi/defcfn resolves a symbol on first call, so a program that never opens a postgres connection never touches the library. Checked directly rather than assumed: a project whose deps.edn points :jolt/native at a libpq that does not exist builds, tree-shakes, runs and returns rows.

Upgrading

No API or behaviour change. This is a build-time fix.

Verified against jolt v0.7.3, which is also the first release carrying the three host fixes from jolt-lang/jolt#585 that the java.sql shim depends on. The suite passes on sqlite and postgres 16.

Changes

  • #11 Require db.pg statically so tree shaking can proceed, adopting #10 by @sundbp