mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-02 07:43:42 +08:00
Calls into Node now run on one dedicated 64 MB stack with a guard page, reached by a context switch, and the bridge sets V8's stack limit on it (bridge ABI 2). Before, a call from an async fiber (512 KB stacks without a guard page) failed to bootstrap Node, which the dev-mode LLVM differential showed. The runtime's stack guard follows the switch, and the switch carries ASan's fiber annotations. The Node island tests load Node from a libnode pack. Until the NI-13 packs are published, .github/actions/libnode-dev-pack assembles one for the Linux x64 test lanes (plain and sanitized): a pinned, checksum-verified prebuilt libnode of the repository's Node release (24.22.0) and Node's official headers (packages/libnode-common/dev-pack.json), with the bridge built against them by build-pack.mjs. The pack is cached by its inputs and the bridge source, so only a cache miss downloads and builds; the normal build path never does. tests/harness/libnode.ts makes a missing pack a failure in those lanes: island tests skip only off Linux x64 CI without a configured pack. The bridge smoke test (packages/libnode-common/test/bridge-smoke.c) loads the pack the way scr_node_island.c does and makes synchronous, throwing and asynchronous calls through the bridge with the runtime's bootstrap. IR, LLVM and object outputs of programs that call into Node no longer need a pack at build time; only executables record one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
/* Node island tests need a libnode pack (SCRIPTC_LIBNODE). The Linux x64 CI
|
|
* test lanes provide one (.github/actions/libnode-dev-pack) and must run
|
|
* these tests, so there a missing pack is a failure, never a skip. Other
|
|
* platforms have no pack yet (NI-13), and a local run without a pack skips. */
|
|
import { readFileSync } from "node:fs";
|
|
|
|
/** `// @requires-libnode` in a corpus program's two-line directive head. */
|
|
export function requiresLibnode(file: string): boolean {
|
|
return readFileSync(file, "utf8")
|
|
.split("\n", 2)
|
|
.some((line) => /^\/\/ @requires-libnode\s*$/.test(line));
|
|
}
|
|
|
|
/** Whether CI must run the Node island tests on this machine. */
|
|
export const libnodeRequired =
|
|
process.env["CI"] !== undefined &&
|
|
process.env["CI"] !== "" &&
|
|
process.env["CI"] !== "false" &&
|
|
process.platform === "linux" &&
|
|
process.arch === "x64";
|
|
|
|
/** The configured pack, or null. Throws where CI requires one. */
|
|
export function libnodePack(): string | null {
|
|
const pack = process.env["SCRIPTC_LIBNODE"];
|
|
if (pack !== undefined && pack !== "") return pack;
|
|
if (libnodeRequired)
|
|
throw new Error(
|
|
"Node island tests need a libnode pack in this CI lane, and SCRIPTC_LIBNODE is not set (.github/actions/libnode-dev-pack provides it)",
|
|
);
|
|
return null;
|
|
}
|