Skip to content

fix(link): #886 — link perry-ext-* libs in jsruntime arm so express + http compiles#887

Merged
proggeramlug merged 1 commit into
mainfrom
pr-886-jsruntime-http-link
May 17, 2026
Merged

fix(link): #886 — link perry-ext-* libs in jsruntime arm so express + http compiles#887
proggeramlug merged 1 commit into
mainfrom
pr-886-jsruntime-http-link

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

  • Express (perry.compilePackages: ["express"]) link-failed on _js_node_http_create_server / _js_node_http_res_end even though auto-optimize: built …/libperry_ext_http.a ran successfully. Trace via PERRY_DEBUG_LINK=1 confirmed the linker command-line omitted both libperry_stdlib.a and every libperry_ext_*.a.
  • Root cause: build_and_run_link's if let Some(ref jsruntime) = jsruntime_lib {…} arm only appended jsruntime + runtime; the parallel else if ctx.needs_stdlib arm that emits well_known_libs + stdlib_lib was unreachable whenever a V8-fallback .js module flipped ctx.needs_js_runtime = true. The codegen-side FFI provenance registry (fix: #835/#846 followup — feed codegen FFI provenance into auto-optimize stdlib features #884) correctly drained OwnerKind::WellKnown("http") into ctx.native_module_imports and the auto-optimize layer built perry-ext-http.a + pushed it onto well_known_libs — but the link command then silently dropped it.
  • Fix mirrors the well-known emission into the jsruntime arm: after jsruntime + runtime, when ctx.needs_stdlib, append stdlib_lib (if Some) + every well_known_libs entry. First-definition-wins archive scan keeps jsruntime's bundled-stdlib copies for duplicates; the perry-ext-* libs only fill gaps.

Test plan

  • Regression smoke test test-files/test_issue_886_jsruntime_http_link.ts + test-files/fixtures/issue_886_pkg/index.js exercises both halves standalone: static-import a .js fixture (forces ctx.needs_js_runtime = true) + import { createServer } from "node:http"; createServer(...) (forces well_known_libs to contain perry-ext-http). Fails to link without the fix (verified by reverting + rebuilding); compiles + links + reaches server created: true runtime output post-fix.
  • Express repro (mkdir /tmp/perry-express && cd /tmp/perry-express && echo '{"perry":{"compilePackages":["express"]}}' > package.json; npm install express; echo 'import express from "express"; console.log(typeof express);' > main.ts; perry main.ts -o out) links cleanly post-fix — advances to a separate, pre-existing runtime TypeError from the Proxy / callable-shape path (out of scope per the issue).
  • cargo build --release -p perry-runtime -p perry-stdlib -p perry -p perry-jsruntime clean.
  • cargo test --release --workspace clean (1098 passed, 0 failed, excluding cross-host UI crates).

Refs #886 (express link failure), follows #884 (the v0.5.930 codegen-side FFI provenance work that this PR completes by wiring the well-known half through to the link line).

…sruntime arm of build_and_run_link

Express (perry.compilePackages: ["express"]) link-failed on
_js_node_http_create_server / _js_node_http_res_end because
build_and_run_link's `if let Some(ref jsruntime) = jsruntime_lib {...}`
arm appended only jsruntime + runtime — the parallel
`else if ctx.needs_stdlib` arm that emits well_known_libs +
stdlib_lib was unreachable. The codegen-side FFI provenance
registry (#884) correctly drained OwnerKind::WellKnown("http") into
ctx.native_module_imports, and the auto-optimize layer built
libperry_ext_http.a + pushed it onto well_known_libs — but the
link command then silently dropped it.

Fix mirrors the well-known emission into the jsruntime arm:
after jsruntime + runtime, when ctx.needs_stdlib is true,
append stdlib_lib (if Some) + every well_known_libs entry.
Mach-O / ELF archive scan is first-definition-wins, so
jsruntime's bundled-stdlib copies still win for duplicate js_*
symbols (the documented duplicate-symbol warnings); the
perry-ext-* libs cover symbols neither jsruntime nor its
bundled stdlib carries.

Validation: express repro links cleanly (advances to a separate
runtime TypeError from the Proxy/callable shape — out of scope
per the issue). New regression test exercises both halves
standalone: static-import a .js fixture (forces ctx.needs_js_runtime)
+ http.createServer (forces well_known_libs to contain
perry-ext-http). cargo test --release --workspace clean (1098
passed, 0 failed).
@proggeramlug proggeramlug merged commit 9ebf9a7 into main May 17, 2026
9 checks passed
@proggeramlug proggeramlug deleted the pr-886-jsruntime-http-link branch May 17, 2026 01:50
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