Skip to content

Install the standard library from Tarver's StLib sources (SBCL/CLISP)#9

Merged
pyrex41 merged 1 commit into
masterfrom
stlib/tarver-native-source
Jul 14, 2026
Merged

Install the standard library from Tarver's StLib sources (SBCL/CLISP)#9
pyrex41 merged 1 commit into
masterfrom
stlib/tarver-native-source

Conversation

@pyrex41

@pyrex41 pyrex41 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Retires the community stlib.kl graft on the image-based hosts in favour of
Mark Tarver's canonical StLib sources (mirror pyrex41/shen-upstream, tag
s41.2-pristine-20260711, Lib/StLib). SBCL and CLISP now run Tarver's
install.shen through the freshly built image at build time (typecheck + load
each module, declare the stlib externals as system functions); the saved image
bakes it in — exactly as Tarver's own install.lsp does. Follows the merged
S41.2 refresh (#8).

What Tarver's install.shen does vs what we adopted

Lib/StLib/install.shen cds into the StLib dir and loads each module in a
precise order, toggling (tc +/-) and (factorise +/-): Symbols → Maths
(macros, maths, rationals/complex/numerals + their .dtype datatypes) → Lists
→ Strings (+ smart) → Vectors macros → IO → Tuples; then package-stlib.shen
(defines the stlib package as the union of module externals) and
(map (fn systemf) …) to declare the externals as system functions, ending
with (preclude-all-but []) and (cd "").

Adopted verbatim: boot.lsp's shen-cl.initialise-stlib is now
(cd "kernel/lib/StLib") (load "install.shen") (cd ""). Tarver's native order
already loads the Maths datatypes before Vectors/macros.shen, so the ':='
vector-macro-vs-typechecker hazard that forced a custom ordering under the
community stlib is avoided by construction (the old reorder comment is gone).

ECL keeps the graft (documented)

ECL builds via c:build-program, which links object files rather than dumping
an image, so it cannot bake the runtime state from loading StLib sources;
and loading them at ECL startup costs ~105s (ECL C-compiles each definition
on load). So ECL alone keeps the precompiled community stlib.kl, imported
under #+ecl in boot.lsp and replayed cheaply at startup (~1.5s). This is the
one stdlib divergence across implementations; retiring it needs a
StLib→.lsp packager (fleet follow-up).

Launcher preserved

The launcher CLI (eval -l file -e expr) is untouched — it remains a
deliberate, documented community-sourced extension (Tarver ships no
non-interactive CLI), and ratatoskr stage-1 depends on it.

Test status (macOS, arm64)

Impl Build Kernel suite StLib stlib fns + launcher
SBCL 2.6.2 pass 134/134 Tarver source (baked) factorial/take/uppercase, eval -e/-q -l -e
GNU CLISP 2.49.92 pass 134/134 Tarver source (baked) factorial/take/uppercase, eval -l file -e expr
ECL 26.5.5 pass 134/134 community stlib.kl (graft) factorial/take, eval -e/-l -e; ~1.5s startup
CCL out of scope no Apple-Silicon native build

ratatoskr stage-1 host: with this branch's SBCL binary as $RATATOSKR_HOST,
ratatoskr shake tests/fib.shen gives kernel.kl = 54 defuns / 13.4 KB,
byte-identical to the pre-change host and deterministic across runs; the
user <prog>.kl differs only in gensym variable numbering (semantically
identical). Launcher CLI intact.

Reproducibility

scripts/assemble-tarver-kernel.sh (make fetch-tarver) copies Tarver's
Lib/StLib to kernel/lib/StLib and keeps community stlib.kl for ECL. Pass
the pyrex41/shen-upstream checkout as $1 to build from the pinned tag.

Upstream StLib observations

No patches needed — Tarver's Lib/StLib sources load and typecheck cleanly on
shen-cl (SBCL/CLISP) as-is. Nothing to report upstream from this pass.

🤖 Generated with Claude Code

Retires the community stlib.kl graft on the image-based hosts in favour of
Mark Tarver's canonical StLib sources (mirror pyrex41/shen-upstream, tag
s41.2-pristine-20260711, Lib/StLib). SBCL and CLISP now run his install.shen
through the freshly built image at build time -- typechecking and loading each
module, declaring the stlib externals as system functions -- and the saved
image bakes it in, exactly as Tarver's own install.lsp does.

- scripts/assemble-tarver-kernel.sh: copy Tarver's Lib/StLib to kernel/lib/StLib;
  keep community stlib.kl for ECL only (documented).
- boot.lsp: #-ecl path loads kernel/lib/StLib/install.shen (cd/load/cd);
  the community stlib.lsp is imported under #+ecl only.
- scripts/build.shen: keep precompiling stlib solely for ECL.
- src/primitives.lsp: ECL init keeps stlib.initialise-* (graft) with a comment
  explaining why (see below).

ECL keeps the graft: c:build-program links object files rather than dumping an
image, so it cannot bake the runtime state from loading StLib sources; and
loading them at ECL startup costs ~105s (ECL C-compiles each definition on
load). Retiring ECL's graft needs a StLib->.lsp packager (fleet follow-up).
This is the one stdlib divergence across implementations.

Gate (macOS arm64): SBCL, CLISP and ECL all build and pass 134/134 with working
stdlib (factorial/take/uppercase) and launcher (eval -l file -e expr). The
ratatoskr stage-1 shake of tests/fib.shen is byte-identical (kernel.kl, 54
defuns) and deterministic; the launcher CLI ratatoskr depends on is preserved.
No upstream StLib patches were needed. See docs/KERNEL-PROVENANCE-tarver-s41.2.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pyrex41
pyrex41 merged commit a00d69b into master Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant