Skip to content

Make the library allocation-free; drop vendored Urbit headers#13

Merged
sigilante merged 1 commit into
masterfrom
fix/allocation-urbit-headers
May 30, 2026
Merged

Make the library allocation-free; drop vendored Urbit headers#13
sigilante merged 1 commit into
masterfrom
fix/allocation-urbit-headers

Conversation

@sigilante
Copy link
Copy Markdown
Collaborator

Answers "do we strictly need the Urbit headers in SoftBLAS?" — no.

A1 — allocation-free core

The only heap allocation in the compiled library was qasum's accumulator (which also leakedqvec/malloc, never freed). Replaced with a stack float128_t. The library now does zero heap allocation.

A3 — test helpers out of the public header

svec/dvec/hvec/qvec (the only other malloc users) are test-only — never called by the library or by Vere/Lagoon. Moved them + float128_pair_t into the test header and added NULL checks.

A2 — drop the Urbit coupling

With nothing in the library allocating, the #ifdef VERE block (#include "noun.h", #define malloc u3a_malloc) is unnecessary. Removed it and deleted the 20 vendored Urbit runtime headers PR #1 copied into include/. VERE is defined nowhere (the block was inert), and when SoftBLAS builds inside Vere, Vere's own headers are already on the include path — the copies were only a staleness liability that would drift. include/ is now just softblas.h.

If the host allocator is ever wanted, supply it via a one-line host shim, not a vendored header tree.

143/143 pass. Third of the audit-backlog PRs (after #11 test honesty, #12 correctness bugs).

🤖 Generated with Claude Code

SoftBLAS routines operate in place on caller-provided buffers; the only
heap allocation in the compiled library was qasum's accumulator (which
also leaked). Replace it with a stack float128_t. The library now does
zero heap allocation.

The svec/dvec/hvec/qvec helpers (the only other malloc users) are
test-only conveniences — never called by the library or by Vere/Lagoon.
Move them, with float128_pair_t, out of the public header into the test
header, and add NULL checks.

With nothing in the library allocating, the Urbit-allocator coupling is
unnecessary: remove the `#ifdef VERE` block (`#include "noun.h"`,
`#define malloc u3a_malloc`) and delete the 20 vendored Urbit runtime
headers that PR #1 copied into include/. `VERE` was defined nowhere (not
in SoftBLAS's build, not in Vere's ext/softblas build), so the block was
inert; and when SoftBLAS builds inside Vere, Vere's own headers are
already on the include path, so the copies were only a staleness
liability. include/ is now just softblas.h. If the host allocator is
ever needed it can be supplied via a one-line host shim, not a vendored
header tree.

143/143 tests pass; CI builds the same set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sigilante sigilante merged commit 393d5e7 into master May 30, 2026
1 check passed
@sigilante sigilante deleted the fix/allocation-urbit-headers branch May 30, 2026 16:28
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