perl: generate Errno.pm on the wasm cross target so use Errno works (kd-gtxa)#827
Open
brandonpayton wants to merge 1 commit into
Conversation
ext/Errno/Errno_pm.PL discovers the E* errno constants by preprocessing `#include <errno.h>` and scanning cpp output for `# <line> "file"` linemarkers. perl-cross defines cpp/cpprun/cppstdin as "$cc -E -P"; -P suppresses those linemarkers, so on the wasm cross target the scan found no headers, collected no constants, and Errno_pm.PL died "No error definitions found" -- Errno.pm was never generated/staged and `use Errno` failed. The constants are plain `#define E* <int>` in the sysroot (musl arch/generic bits/errno.h). build-perl.sh now patches get_files() to fall back to the sysroot errno headers when linemarker discovery yields nothing, adds Errno.pm to the fail-loud runtime post-check, and bumps the package revision (perl-runtime.zip now ships Errno.pm; perl.wasm is byte-unchanged). Adds Node + browser use-Errno smokes. Stacked on #821 (kd-k7zy). Verified: Node errno-smoke 16/16 (Errno.pm with 134 musl-valued constants + %! tie); browser smoke harness committed (skips where the browser bundle is absent; browser acceptance tracked by kd-yuef). 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.
Problem (kd-gtxa)
On the wasm cross target, Perl shipped without
Errno.pm, souse Errnofailed("Can't locate Errno.pm") and any module needing errno constants broke. During
make,ext/Errno/Errno_pm.PLdied: "No error definitions found atErrno_pm.PL line 208."
Root cause
Errno_pm.PL::get_files()discovers which headers define theE*constants bypreprocessing
#include <errno.h>and scanning the cpp output for# <line> "file"linemarkers, then greps those headers for#define E*.perl-cross defines
cpp/cpprun/cppstdinas"$cc -E -P"(cnf/configure_tool.sh),and
-Psuppresses linemarkers — so the scan discovered zero headers,collected no constants, and
Errno_pm.PLdied. Not an include-path problem: theSDK cc wrapper always injects
--sysroot, and the constants are plain#define E* <int>in the sysroot (musl arch/generic bits/errno.h, 134 of them).They were simply never discovered.
Confirmed directly:
wasm32posix-cc -E errno.cemits 13 linemarkers pointing atsysroot/include/bits/errno.h;-E -Pemits 0.Fix
build-perl.shpatchesget_files()to fall back to the sysroot errno headers(
$WASM_POSIX_SYSROOT/include/{errno.h,bits/errno.h}) when linemarker discoveryyields nothing — surgical (zero blast radius on the configure probes that
-Pserves), fallback-only (upstream discovery is untouched where it works), and
fail-loud (aborts if the anchor moves).
Errno.pmis added to the runtimepost-check so a regression fails the build. Revision bumped 2→3 (perl-runtime.zip
now ships
Errno.pm; perl.wasm is byte-unchanged — Errno is pure-perl, notlinked in). The formula installs it automatically (it unzips
lib/*).Verification
Errno_pm.PL line 208→ Errno.pmabsent from privlib + perl-runtime.zip.
Errno.pmgenerated with 134 constants at exact musl values and staged intoperl-runtime.zip.demo/errno-smoke.ts):PERL_ERRNO_SMOKE_PASS— 16/16(
use Errnoloads; EPERM/ENOENT/…/EINVAL match musl; ERRNO_COUNT=134;%!tie).demo/errno-browser-smoke.ts): committed + ready; skipswith reason where the browser bundle/playwright are absent. Host-agnostic:
perl.wasm is byte-identical to the interpreter perl: run on the default/unset locale without a startup panic (kd-dvph) #822 browser-verified, and the
browser perl-vfs image is built from
perl-src/lib(now containing Errno.pm).Full browser acceptance tracked by kd-yuef.
Stacking
Stacked on #821 (kd-k7zy) — the Errno failure only exists on that recipe
(origin/main's
build-perl.shstops atmake perland never builds ext/Errno).Base is the #821 branch; retarget to
mainafter #821 merges.🤖 Generated with Claude Code