@wasm-oj/core 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -100,6 +100,8 @@ interface ProjectFile {
100
100
  content: string;
101
101
  }
102
102
  interface BuildConfig {
103
+ /** C/C++ linear-memory stack reservation in bytes; omitted uses the toolchain default. */
104
+ stackSizeBytes?: number;
103
105
  language: Language;
104
106
  target: TargetAbi;
105
107
  optimization: OptimizationLevel;
@@ -352,8 +354,8 @@ declare function isCostProfileFor(profile: string, language: Language, target: T
352
354
 
353
355
  /** Executable runtime components covered by deterministic cost calibration. */
354
356
  declare const WASM_OJ_RUNTIME_COMPONENTS: Readonly<{
355
- readonly runtimeCoreWasmSha256: "0ae00fc646f529aafb5d1a68758220e6428f6c565e8e621eeb6c8f14ac5d4a10";
356
- readonly runtimeSourceRootSha256: "a7e9071511d127e3b14920558c7c38c27a1fa19d98906c8476c1df8041a9c3bb";
357
+ readonly runtimeCoreWasmSha256: "077aa936a3382a242eee7222fc17369769cb5ad265303d730ffc45ee192367e9";
358
+ readonly runtimeSourceRootSha256: "c65b3bbcad41359f86b8f1d1315af8f079b44f0e9084ace0d6d50c0ec418415b";
357
359
  readonly wasmerNativeVersion: "7.2.1";
358
360
  readonly wasmerSdkVersion: "0.10.0";
359
361
  readonly wasmerSdkWasmSha256: "49a6646209f5ab5e7c737eac33407d87d9a9959ac83e5ecaaab9261b2323589e";
@@ -364,7 +366,7 @@ declare const WASM_OJ_RUNTIME_COMPONENTS: Readonly<{
364
366
  * Release verification independently checks the component bytes before this
365
367
  * identity is admitted into a calibrated release.
366
368
  */
367
- declare const WASM_OJ_RUNTIME_IDENTITY_SHA256 = "e5680beae9bd832ed2b679267250ce1efc7d104dd005bb155135664b40f961fb";
369
+ declare const WASM_OJ_RUNTIME_IDENTITY_SHA256 = "47684bee57aafd163b18a787fa16eed33cab3ec3c0005c3c46bb4f1803ffc835";
368
370
  /** Exact canonical serialization hashed by `WASM_OJ_RUNTIME_IDENTITY_SHA256`. */
369
371
  declare function runtimeIdentityBytes(): Uint8Array;
370
372
  declare function verifyRuntimeIdentity(): Promise<void>;
@@ -748,6 +750,8 @@ interface CompileInput {
748
750
  files: Readonly<Record<string, string>>;
749
751
  target?: TargetAbi$1;
750
752
  optimization?: OptimizationLevel$1;
753
+ /** C/C++ stack reservation, in bytes and aligned to 16; omitted uses the toolchain default. */
754
+ stackSizeBytes?: number;
751
755
  name?: string;
752
756
  projectId?: string;
753
757
  dependencies?: DependencyBuildBundle;
package/dist/index.js CHANGED
@@ -374,8 +374,8 @@ async function sha256Hex$1(value) {
374
374
  //#region src/core/runtime-identity.ts
375
375
  /** Executable runtime components covered by deterministic cost calibration. */
376
376
  var WASM_OJ_RUNTIME_COMPONENTS = Object.freeze({
377
- runtimeCoreWasmSha256: "0ae00fc646f529aafb5d1a68758220e6428f6c565e8e621eeb6c8f14ac5d4a10",
378
- runtimeSourceRootSha256: "a7e9071511d127e3b14920558c7c38c27a1fa19d98906c8476c1df8041a9c3bb",
377
+ runtimeCoreWasmSha256: "077aa936a3382a242eee7222fc17369769cb5ad265303d730ffc45ee192367e9",
378
+ runtimeSourceRootSha256: "c65b3bbcad41359f86b8f1d1315af8f079b44f0e9084ace0d6d50c0ec418415b",
379
379
  wasmerNativeVersion: "7.2.1",
380
380
  wasmerSdkVersion: "0.10.0",
381
381
  wasmerSdkWasmSha256: "49a6646209f5ab5e7c737eac33407d87d9a9959ac83e5ecaaab9261b2323589e",
@@ -386,13 +386,13 @@ var WASM_OJ_RUNTIME_COMPONENTS = Object.freeze({
386
386
  * Release verification independently checks the component bytes before this
387
387
  * identity is admitted into a calibrated release.
388
388
  */
389
- var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "e5680beae9bd832ed2b679267250ce1efc7d104dd005bb155135664b40f961fb";
389
+ var WASM_OJ_RUNTIME_IDENTITY_SHA256 = "47684bee57aafd163b18a787fa16eed33cab3ec3c0005c3c46bb4f1803ffc835";
390
390
  /** Exact canonical serialization hashed by `WASM_OJ_RUNTIME_IDENTITY_SHA256`. */
391
391
  function runtimeIdentityBytes() {
392
392
  return canonicalJsonBytes(WASM_OJ_RUNTIME_COMPONENTS);
393
393
  }
394
394
  async function verifyRuntimeIdentity() {
395
- if (await sha256Hex$1(runtimeIdentityBytes()) !== "e5680beae9bd832ed2b679267250ce1efc7d104dd005bb155135664b40f961fb") throw new Error("WASM-OJ runtime identity declaration does not match its digest.");
395
+ if (await sha256Hex$1(runtimeIdentityBytes()) !== "47684bee57aafd163b18a787fa16eed33cab3ec3c0005c3c46bb4f1803ffc835") throw new Error("WASM-OJ runtime identity declaration does not match its digest.");
396
396
  }
397
397
  //#endregion
398
398
  //#region src/core/cost-profile.ts
@@ -537,6 +537,12 @@ function assertNonNegativeMetric(value, label) {
537
537
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${label} must be a non-negative safe integer.`);
538
538
  }
539
539
  //#endregion
540
+ //#region src/core/build-stack.ts
541
+ function assertBuildStackSize(language, value) {
542
+ if (language !== "c" && language !== "cpp") throw new Error("stackSizeBytes is supported only for C/C++ builds.");
543
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 16 || value > 4294967280 || value % 16 !== 0) throw new Error("stackSizeBytes must be a multiple of 16 between 16 and 4294967280 bytes.");
544
+ }
545
+ //#endregion
540
546
  //#region src/core/project-files.ts
541
547
  var PROJECT_SOURCE_LIMITS = Object.freeze({
542
548
  files: 256,
@@ -881,8 +887,10 @@ function assertResources(value) {
881
887
  resolveResourcePolicy(value);
882
888
  }
883
889
  function assertProjectConfig(value) {
884
- const config = exactDataRecord(value, "Project config", PROJECT_CONFIG_KEYS);
890
+ const hasStackSize = Boolean(value && typeof value === "object" && Object.hasOwn(value, "stackSizeBytes"));
891
+ const config = exactDataRecord(value, "Project config", hasStackSize ? [...PROJECT_CONFIG_KEYS, "stackSizeBytes"] : PROJECT_CONFIG_KEYS);
885
892
  assertLanguageIdentifier$1(config.language);
893
+ if (hasStackSize) assertBuildStackSize(config.language, config.stackSizeBytes);
886
894
  if (config.target !== "wasip1" && config.target !== "wasix") throw new Error("Project target must be 'wasip1' or 'wasix'.");
887
895
  if (config.optimization !== "debug" && config.optimization !== "release") throw new Error("Project optimization must be 'debug' or 'release'.");
888
896
  if (isBuiltinLanguage$1(config.language) && !TOOLCHAINS[config.language].targets.includes(config.target)) throw new Error(`Project target '${config.target}' is unsupported for built-in language '${config.language}'.`);
@@ -1371,6 +1379,7 @@ function projectBuildIdentity(project, compilerCacheIdentity = JSON.stringify(to
1371
1379
  language: project.config.language,
1372
1380
  target: project.config.target,
1373
1381
  optimization: project.config.optimization,
1382
+ ...project.config.stackSizeBytes === void 0 ? {} : { stackSizeBytes: project.config.stackSizeBytes },
1374
1383
  entry: project.config.entry
1375
1384
  },
1376
1385
  compiler: compilerCacheIdentity,
@@ -3048,6 +3057,7 @@ function createSdkProject(input) {
3048
3057
  if (input.language === "java" && target !== "wasip1") throw new Error("Java does not support the WASIX target.");
3049
3058
  const optimization = input.optimization ?? "release";
3050
3059
  if (optimization !== "debug" && optimization !== "release") throw new Error(`Unsupported optimization level '${String(optimization)}'.`);
3060
+ if (input.stackSizeBytes !== void 0) assertBuildStackSize(input.language, input.stackSizeBytes);
3051
3061
  const inferredName = entry.split("/").at(-1)?.replace(/\.[^.]+$/, "") || "wasm-oj-project";
3052
3062
  const name = optionalMetadata(input.name, "Project name", 4096) ?? inferredName;
3053
3063
  const projectId = optionalMetadata(input.projectId, "Project ID", 16384) ?? `sdk:${name}`;
@@ -3063,6 +3073,7 @@ function createSdkProject(input) {
3063
3073
  language: input.language,
3064
3074
  target,
3065
3075
  optimization,
3076
+ ...input.stackSizeBytes === void 0 ? {} : { stackSizeBytes: input.stackSizeBytes },
3066
3077
  entry,
3067
3078
  args: [],
3068
3079
  stdin: "",
@@ -8232,6 +8243,41 @@ var STDIO_CONFORMANCE_CASES = programs.flatMap((program) => inputs.map(({ id, st
8232
8243
  //#endregion
8233
8244
  //#region src/conformance/cases.ts
8234
8245
  var DEFAULT_CONFORMANCE_CASES = deepFreeze([
8246
+ ...["c", "cpp"].flatMap((language) => [7, 9].map((mebibytes) => ({
8247
+ id: language + "-wasip1-stack-" + mebibytes + "mib",
8248
+ label: language + " / wasip1 / " + mebibytes + " MiB local arrays",
8249
+ input: {
8250
+ language,
8251
+ stackSizeBytes: 8388608,
8252
+ target: "wasip1",
8253
+ entry: language === "c" ? "main.c" : "main.cpp",
8254
+ files: { [language === "c" ? "main.c" : "main.cpp"]: [
8255
+ "#include <stdio.h>",
8256
+ "int main(void) {",
8257
+ " char first[" + mebibytes * 1024 * 512 + "];",
8258
+ " char second[" + mebibytes * 1024 * 512 + "];",
8259
+ " if (scanf(\"%3s %3s\", first, second) != 2) return 2;",
8260
+ " printf(\"%s %s\\n\", first, second);",
8261
+ " return 0;",
8262
+ "}"
8263
+ ].join("\n") }
8264
+ },
8265
+ run: {
8266
+ stdin: "abc def\n",
8267
+ resources: { memoryLimitBytes: 16777216 }
8268
+ },
8269
+ expect: mebibytes === 7 ? {
8270
+ code: 0,
8271
+ stdout: "abc def\n",
8272
+ stderr: "",
8273
+ termination: "exited"
8274
+ } : {
8275
+ code: 1,
8276
+ stdout: "",
8277
+ termination: "trap",
8278
+ trapMessageIncludes: "out of bounds"
8279
+ }
8280
+ }))),
8235
8281
  {
8236
8282
  id: "c-wasip1",
8237
8283
  label: "C / wasip1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasm-oj/core",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Host-neutral compiler, runner, judge, dependency, and replay orchestration for WASM-OJ.",
5
5
  "license": "MIT",
6
6
  "author": "JacobLinCool",
@@ -43,7 +43,7 @@
43
43
  "node": ">=24.18.0 <25"
44
44
  },
45
45
  "dependencies": {
46
- "@wasm-oj/contracts": "0.2.4",
46
+ "@wasm-oj/contracts": "0.2.6",
47
47
  "fflate": "0.8.3"
48
48
  },
49
49
  "scripts": {