Repository navigation
pycvc wasm host: Python extensions from inittab manifests, one namespace each, no --allow-multiple-definition - #1027
Merged
Merged
Conversation
…ace each, no --allow-multiple-definition link-host.sh linked numpy's extension objects into one wasm module with --allow-multiple-definition, because each bundles npymath. That also hid a real clash: numpy.random.mtrand and _bounded_integers define seven distributions under the same names with different signatures (i32 against i64), so wasm-ld bound one extension's calls to a trapping stub, and np.random.RandomState(1).poisson(4.0, 4) aborted the host with "RuntimeError: unreachable". Now each extension object gets a namespace of its own (cvcpkg/recipes/_common/wasm_pyext.py, vendored from cy-pca/cvcpkg: the PyInit renamed after its dotted module, the other globals local), and link-host.sh: - reads the deps prefix's share/python-wasm/*.inittab manifests, and localizes copies of a numpy that ships none (numpy-cp312 before cvc.6) in a scratch dir, never in the prefix; - refuses a set that would clash (wasm_pyext.py check), writes the registrar (pycvc_register_pyext_inittab, PYCVC_EMBED_PYEXT in pycvc_host.cpp) and links with no --allow-multiple-definition; - takes PYTHON for those steps; the pycvc-gl-cp312 build scripts pass their native interpreter. The full host (VTK bridge, numpy, 256 deps archives) links that way here and its smoke prints PYCVC_WASM_OK; a minimal host runs RandomState's and Generator's binomial, poisson, zipf, negative_binomial, geometric and multinomial, where the old link trapped. publish-pycvc-gl-wasm.yml uploads the host only on a real publish: a dry run packs and checks and stores no artifact.
Re-vendors cy-pca/cvcpkg's recipes/_common/wasm_pyext.py after its review. Weak _ZTI/_ZTS stay global and weak, so a -fno-rtti extension still catches what libc++ throws (an out-of-memory in np.unique raises MemoryError instead of aborting the host). The init symbol encoding is now injective (PyInit__x_5numpy5_core5_simd). On the full pycvc_gl host linked by link-host.sh: the smoke prints PYCVC_WASM_OK; np.unique out of memory raises MemoryError; RandomState's and Generator's poisson, zipf, binomial, negative_binomial, geometric and multinomial all return. master's link crashes on the latter (RuntimeError: unreachable). Roadmap 5.5: the problem in the past tense, the RTTI rule and the new encoding, check's weak-symbol rule, and the publish order for numpy-cp312 cvc.6.
transfix
added a commit
that referenced
this pull request
Nov 6, 2026
The roadmap conflicted with #1028 (what P1 shipped) and #1027 (§5.5) in four places. Both sides are kept: - status: #1028's "P1 shipped / the rest is design" lines, plus this PR's §6.5 and S5-S7 date; - §1: #1028's rows for the Python host and the P1 scripting hosts; - risks: #1028's rewrap of 15, then this PR's 16-19; - phases: this PR's S5-S7 rows, then #1028's L1/G1, which need the script_engine interface (P1b).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roadmap phase W2 (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md §5.5), libcvc's side. The cvcpkg side is cy-pca/cvcpkg#549.
The bug it fixes.
link-host.shlinked numpy's extension objects with--allow-multiple-definition, because each bundles npymath. That hid a real clash:numpy.random.mtrandand_bounded_integersdefine seven distributions under the same names with different signatures (i32 against i64). wasm-ld bound one extension's calls to a trapping stub, sonp.random.RandomState(1).poisson(4.0, 4)aborts the host withRuntimeError: unreachable.What changes.
cvcpkg/recipes/_common/wasm_pyext.py, vendored byte-for-byte from numpy-cp312 (wasm, wasm-mt): one namespace per extension, and an inittab manifest cy-pca/cvcpkg#549, gives each extension object its own namespace:PyInit__x_5numpy5_core5_simd);bindings/pycvc/wasm/link-host.sh:share/python-wasm/*.inittabmanifests;check(refuses a clashing set), thenregistrar;--allow-multiple-definition;PYTHONfor those steps, which the pycvc-gl-cp312build-wasm.sh/.ps1now pass.pycvc_host.cpp:pycvc_register_pyext_inittab()underPYCVC_EMBED_PYEXT.publish-pycvc-gl-wasm.yml: uploads the host only on a real publish. A dry run packs, checks, and stores nothing.Verified locally (Windows, emsdk 5.0.7, the full pycvc_gl closure: VTK bridge, numpy, 256 deps archives):
PYCVC_WASM_OKPYCVC_WASM_OKRuntimeError: unreachablenp.uniqueout of memoryMemoryErrorMemoryErrorThe smoke's garbage-collector tracebacks (VTK's
AddModule, cy-pca/cvcpkg#543) are unchanged, and identical in both.An adversarial review caught an earlier version making weak RTTI local, which turned that
MemoryErrorinto an aborted host. That is fixed in cy-pca/cvcpkg#549 and re-vendored here; the table is from the fixed version.Order. This works with numpy-cp312 cvc.5 (it localizes numpy itself) and with cvc.6 (manifests). Publish cvc.6 only after this is on master.
Not covered by CI. No PR job links the wasm host (
publish-pycvc-gl-wasm.ymlis dispatch- and tag-only), so the table above is the evidence. Adry_rundispatch on this branch would check it on Linux, and now stores no artifacts.