@wasm-oj/core 0.2.5 → 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 +4 -0
- package/dist/index.js +47 -1
- package/package.json +2 -2
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;
|
|
@@ -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
|
@@ -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
|
|
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.
|
|
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.
|
|
46
|
+
"@wasm-oj/contracts": "0.2.6",
|
|
47
47
|
"fflate": "0.8.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|