Skip to content

feat: expose configurable C/C++ stack capacity - #110

Merged
JacobLinCool merged 2 commits into
wasm-oj:mainfrom
TakalaWang:codex/clang-stack-parity
Oct 31, 2026
Merged

JacobLinCool merged 2 commits into
wasm-oj:mainfrom
TakalaWang:codex/clang-stack-parity

Conversation

@TakalaWang

@TakalaWang TakalaWang commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Expose an optional stackSizeBytes compile setting so downstream judges can select a C/C++ stack capacity that matches their native environment. Omitting the option preserves the pinned toolchain's existing size and layout; this PR no longer changes Forge's global default.

The option is carried by SDK CompileInput and Project.config, validated at both boundaries, and included in artifact cache keys. The shared Clang linker applies an explicit size with a stack-first layout; incremental link keys include the actual argv so differently configured builds cannot reuse linked artifacts. Other languages reject the option. Values must be integer multiples of 16 from 16 through 4294967280 bytes; linker and run memory limits still apply.

Example:

await engine.compile({
  language: "c",
  entry: "main.c",
  files: { "main.c": source },
  stackSizeBytes: 8 * 1024 * 1024,
});

Validation on c65bdc2:

  • Full local suite: 198 files passed, 4 skipped; 1009 tests passed, 14 skipped.
  • Library build/typecheck, changed-file ESLint, 13-package packing verification and clean NodeNext consumer verification passed.
  • Chromium: unchanged reported source traps with omitted/1 MiB stack, succeeds with explicit 8 MiB, and produces distinct cache keys.
  • C and C++, debug and release: 7 MiB local arrays succeed and 9 MiB trap with an explicit 8 MiB stack under a 16 MiB total memory limit.
  • NOJV's actual browser execution service passes the unchanged source when configured with 8 MiB against this local candidate; its web check/lint, test typechecks and 138 relevant tests passed.

NOJV will consume a published upstream version; no downstream fork or package patch is proposed.

@TakalaWang
TakalaWang marked this pull request as ready for review October 31, 2026 09:22
@TakalaWang TakalaWang changed the title fix: reserve an 8 MiB stack for C/C++ builds feat: expose configurable C/C++ stack capacity Oct 31, 2026
@JacobLinCool
JacobLinCool merged commit 0a28ae1 into wasm-oj:main Oct 31, 2026
1 check passed
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.

2 participants