perl: ship a usable core-module runtime (generated files + static XS) so File::Spec/POSIX load on Kandelo#821
Open
brandonpayton wants to merge 1 commit into
Conversation
The Perl bottle shipped only perl.wasm with no core-module runtime, and the interpreter crashed on any real module load, so the port only ever passed a trivial arithmetic smoke. Make Perl-on-Kandelo usable: File::Spec, POSIX, Cwd, XSLoader, Config and the pure-perl core all load and run. Fixes kd-k7zy (the kd-p3hr follow-up where File::Spec failed on missing generated XSLoader.pm). Three root causes, all in the build recipe: - Generated runtime files were never produced/packaged: `make perl` stops before perl-cross's nonxs/extensions targets that generate lib/XSLoader.pm and stage the core tree, and the target Config had an empty osname so MakeMaker's probes failed. Fix: -Dosname=linux + build with `make -k`, then package lib/perl5/5.40.3 as a new perl-runtime.zip output. - The interpreter miscompiled and panicked on any weak-ref use: -O2 without -fno-strict-aliasing miscompiles perl's weak-ref code into a magic_killbackrefs panic. The flag was on HOSTCFLAGS only; add it to the target -Dccflags. - XS core modules could not load: usedl=define builds .so's loaded via dlopen, which Kandelo wasm lacks. -Uusedl links XS into perl.wasm with a boot table so XSLoader::load resolves them without dlopen. perl-cross ignores -Dnoextensions, so the static set is curated by editing Makefile.config's fullpath_static_ext (drop ext/re, which duplicates core regcomp symbols, and external-lib/threads exts). Also work around a perl-cross bug where the static-ext recipe never runs pm_to_blib: after make -k, stage each curated static ext's .pm. build.toml revision 1 -> 2 (output bytes change). package.toml declares the perl-runtime output. Formula/perl.rb installs perl.wasm + the runtime and tests File::Spec/POSIX/XSLoader. demo/runtime-smoke.ts is a Node kernel-host smoke. Verified via Node runCentralizedProgram against the packaged perl-runtime.zip (LC_ALL=C): File::Spec catfile/rel2abs, Cwd, POSIX, Fcntl, List::Util, Data::Dumper, XSLoader, Config all load (PERL_RUNTIME_SMOKE_PASS). Known boundaries filed: kd-dvph (default-locale startup panic), kd-gtxa (Errno errno extraction), kd-14n8 (broaden static XS / dlopen). Browser bottle tracks kd-yuef. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
brandonpayton
added a commit
that referenced
this pull request
Jul 1, 2026
…s bottle This branch's perl.rb staged the runtime by globbing the source tree, which could not include the generated XSLoader.pm (never produced by `make perl`), so File::Spec failed. PR #821 (kd-k7zy) fixes this end to end: it generates the core-module runtime, packages it as perl-runtime.zip, statically links the core XS (Kandelo wasm has no dlopen), and fixes the target -fno-strict-aliasing miscompile -- File::Spec/POSIX/Cwd/XSLoader all load (Node-verified). Per coordinator decision (kd-k7zy owns Perl, same resolution as ruby->#814 / cpython->#818): revert packages/registry/perl/build-perl.sh to origin/main and delete this branch's homebrew/kandelo-homebrew/Formula/perl.rb so #821's perl is the sole owner. This branch no longer touches Perl vs main; php/erlang/texlive are unchanged. #810's build-perl.sh delta was purely the resolver-contract refactor, which #821 already carries, so nothing is preserved separately. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Purpose
The Perl Homebrew bottle shipped only
perl.wasmwith no core-module runtime,and the interpreter crashed on any real module load — so the port only ever
passed a trivial arithmetic smoke. This makes Perl-on-Kandelo actually usable:
File::Spec,POSIX,Cwd,XSLoader,Configand the pure-perl core allload and run. Fixes kd-k7zy (follow-up from the kd-p3hr language-runtime wave,
where
File::Specfailed because generated runtime files such asXSLoader.pmwere never staged).
Root causes fixed
Generated runtime files were never produced or packaged.
build-perl.shran
make perl, which stops before perl-cross'snonxs_ext/extensionstargets that generate
lib/XSLoader.pm(fromdist/XSLoader/XSLoader_pm.PL)and stage the core-module tree via
pm_to_blib. Compounding it, the targetConfighad an emptyosname, soExtUtils::MakeMaker's$Config{osname} eq …probes hitundefand every module's staging failed. Fix:-Dosname=linux(Kandelo is a POSIX/linux-like syscall surface) + build withmake -k, then packagelib/perl5/5.40.3as a newperl-runtime.zipoutput.The shipped interpreter miscompiled and panicked on any weak-ref use.
build-perl.shalready documents-fno-strict-aliasingas load-bearing(clang
-O2miscompiles perl's weak-ref machinery into amagic_killbackrefspanic) but applied it only to
HOSTCFLAGS(host miniperl), not the target-Dccflags. Soperl.wasmpanickedmagic_killbackrefs/del_backrefthemoment any module traversed weak refs (
use File::Spec,use Config). Fix:add
-fno-strict-aliasingto the targetccflags.XS core modules could not load. The config shipped
usedl=define; XSmodules built
.sos loaded viadlopen, which Kandelo's wasm musl does notimplement (
dlerror() not implemented). SoFile::Spec(→File::Spec::Unix→
Cwd, an XS module),POSIX,Fcntl,List::Utilall failed. Fix:-Uusedlbuilds extensions statically, linking their XS intoperl.wasmwitha boot table so
XSLoader::loadresolves them withoutdlopen. perl-crossignores
-Dnoextensions, so the statically-linked set is curated by editingMakefile.config'sfullpath_static_ext— droppingext/re(recompilesregcomp.c→ duplicate symbols vs coreregcomp.o) and extensions needinglibraries absent from the wasm sysroot / threads.
Changes
packages/registry/perl/build-perl.sh— resolver-contract output handling(
WASM_POSIX_DEP_OUT_DIR,sdk/activate.sh);-Dosname=linux;-fno-strict-aliasingon target ccflags;-Uusedl+ curatedfullpath_static_ext;make -kstaging +perl-runtime.zippackaging with apost-check that the generated files (
XSLoader.pm,Config.pm,File/Spec.pm,File/Spec/Unix.pm,Cwd.pm) are present.packages/registry/perl/package.toml— declare theperl-runtimeoutput.packages/registry/perl/build.toml— revision 1 → 2 (output bytes change).homebrew/kandelo-homebrew/Formula/perl.rb— installperl.wasm+ unzip theruntime into
lib/perl5/5.40.3;testcoversFile::Spec,POSIX(a modulethat bootstraps via XSLoader), and
XSLoader. (Requires the tap'sformula_support/kandelo_package.rb; bottle-test acceptance tracks kd-yuef.)packages/registry/perl/demo/runtime-smoke.ts— Node kernel-host smoke.Verification
Node
runCentralizedProgram(host-fs passthrough,LC_ALL=C,PERL5LIB=staged privlib) against the builtperl.wasm(~4.2M static):RESULTS=Config=ok,XSLoader=ok,FileSpec_catfile=ok,FileSpec_rel2abs=ok,Cwd_xs=ok,POSIX_xs=ok,Fcntl_xs=ok,ListUtil_xs=ok,DataDumper_xs=ok→ PERL_RUNTIME_SMOKE_PASSFile::Spec->catfile('a','b','c.txt')→a/b/c.txtFile::Spec->rel2abs('x','/root')→/root/x(Cwd's XS bootstraps via XSLoader)POSIX::floor(3.7)→ 3;Fcntl O_RDONLY;List::Util::sum(1..4)→ 10;Cwd::getcwdData::Dumper;XSLoader0.32;Configversion 5.40.3perl.wasm≈ 4.2M (static XS);perl-runtime.zip≈ 10M (711 core.pmincl unicore).Full gate (
cargo test -p kandelo … --lib,vitest, libc/posix suites,check-abi-version) was not run: this change is package-recipe only (build script,
manifest, formula, demo) and touches no kernel/host/ABI code. Browser bottle run
tracks kd-yuef.
Known boundaries (follow-ups filed)
default locale (
C.UTF-8;C;C;C;C;C); tests/smoke setLC_ALL=C.Errno_pm.PLfinds no errno constants under the wasm sysroot, soErrno.pmis absent (make -kkeeps going past it).wiring the needed libs into the sysroot or implementing a working wasm dlopen.
🤖 Generated with Claude Code