Skip to content

Commit a64dcb4

Browse files
committed
update starlingmonkey dependency
Signed-off-by: Karthik Ganeshram <karthik.ganeshram@fermyon.com>
1 parent 5a75801 commit a64dcb4

File tree

18 files changed

+54
-212
lines changed

18 files changed

+54
-212
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ jobs:
8787
build-type:
8888
- 'release'
8989
- 'debug'
90-
- 'weval'
9190
steps:
9291
- uses: actions/checkout@v4
9392
with:
@@ -159,7 +158,6 @@ jobs:
159158
build-type:
160159
- 'release'
161160
- 'debug'
162-
- 'weval'
163161
steps:
164162
- uses: actions/checkout@v4
165163

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ examples/hello-world/guest/package-lock.json
1010
examples/hello-world/guest/hello.component.wasm
1111
/build-debug
1212
/build-release
13-
/build-release-weval
1413
.vscode
1514
/package-lock.json
1615
.idea

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ set(EMBEDDING_DEP "starling-raw.wasm")
2626
# Define output filenames based on build configuration
2727
set(OUTPUT_NAME_RELEASE "starlingmonkey_embedding.wasm")
2828
set(OUTPUT_NAME_DEBUG "starlingmonkey_embedding.debug.wasm")
29-
set(OUTPUT_NAME_WEVAL "starlingmonkey_embedding_weval.wasm")
3029

3130
# Set the appropriate name based on current configuration
3231
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
3332
set(OUTPUT_FILENAME ${OUTPUT_NAME_DEBUG})
34-
elseif(WEVAL)
35-
set(OUTPUT_FILENAME ${OUTPUT_NAME_WEVAL})
36-
set(EMBEDDING_DEP "starling-ics.wevalcache")
3733
else()
3834
set(OUTPUT_FILENAME ${OUTPUT_NAME_RELEASE})
3935
endif()

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ STARLINGMONKEY_DEPS = $(STARLINGMONKEY_SRC)/cmake/* embedding/* $(STARLINGMONKEY
1515
all: release
1616
debug: lib/starlingmonkey_embedding.debug.wasm lib/spidermonkey-embedding-splicer.js
1717
release: lib/starlingmonkey_embedding.wasm lib/spidermonkey-embedding-splicer.js
18-
release-weval: lib/starlingmonkey_ics.wevalcache lib/spidermonkey-embedding-splicer.js
1918

2019
lib/spidermonkey-embedding-splicer.js: target/wasm32-wasip1/release/splicer_component.wasm crates/spidermonkey-embedding-splicer/wit/spidermonkey-embedding-splicer.wit | obj lib
2120
@$(JCO) new target/wasm32-wasip1/release/splicer_component.wasm -o obj/spidermonkey-embedding-splicer.wasm --wasi-reactor
@@ -28,12 +27,6 @@ lib/starlingmonkey_embedding.wasm: $(STARLINGMONKEY_DEPS) | lib
2827
cmake -B build-release -DCMAKE_BUILD_TYPE=Release
2928
make -j16 -C build-release starlingmonkey_embedding
3029

31-
lib/starlingmonkey_embedding_weval.wasm: $(STARLINGMONKEY_DEPS) | lib
32-
cmake -B build-release-weval -DCMAKE_BUILD_TYPE=Release -DUSE_WASM_OPT=OFF -DWEVAL=ON
33-
make -j16 -C build-release-weval starlingmonkey_embedding
34-
35-
lib/starlingmonkey_ics.wevalcache: lib/starlingmonkey_embedding_weval.wasm
36-
@cp build-release-weval/starling-raw.wasm/starling-ics.wevalcache $@
3730

3831
lib/starlingmonkey_embedding.debug.wasm: $(STARLINGMONKEY_DEPS) | lib
3932
cmake -B build-debug -DCMAKE_BUILD_TYPE=RelWithDebInfo

README.md

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ As more components are written in JavaScript, and there exist scenarios where mu
4949

5050
Establishing this initial prototype as a singular flexible engine foundation that can be turned into a shared library is therefore the focus for this project.
5151

52-
### Weval AOT Compilation
53-
54-
5552
## Platform APIs
5653

5754
The following APIs are available:
@@ -106,23 +103,7 @@ See [types.d.ts](types.d.ts) for the full interface options.
106103

107104
The component itself can be executed in any component runtime, see the [example](EXAMPLE.md) for an end to end workflow in Wasmtime.
108105

109-
### AOT Compilation
110-
111-
To enable AOT compilation, set the `enableAot: true` option to run [Weval][weval] ahead-of-time compilation.
112-
113-
AOT compilation can also be configured with the following options:
114-
115-
| Option | Type | Example | Description |
116-
|------------------------|-------------------------------------|-----------------|--------------------------------------------------------------------------|
117-
| `aotMinStackSizeBytes` | `nubmer | Number | bigint | BigInt` | `2_007_846_092` | The minimum stack size (via `RUST_MIN_STACK` to set when running `weval` |
118-
119-
[weval]: https://github.com/bytecodealliance/weval
120-
121-
### Custom `weval` binary for AOT
122-
123-
To use a custom (pre-downloaded) [`weval`][weval] binary, set the `wevalBin` option to the path to your desired weval binary.
124-
125-
### Custom `wizer` binary when AOT is disabled
106+
### Custom `wizer` binary
126107

127108
To use a custom (pre-downloaded) [`wizer`](https://github.com/bytecodealliance/wizer) binary, set the `wizerBin` option to the path to your desired wizer binary.
128109

@@ -229,18 +210,6 @@ export function componentize(opts: {
229210
* Path to custom ComponentizeJS engine build to use
230211
*/
231212
engine?: string;
232-
/**
233-
* Path to custom weval cache to use
234-
*/
235-
aotCache?: string;
236-
/**
237-
* Enable AoT using weval
238-
*/
239-
enableAot?: boolean;
240-
/**
241-
* Use a pre-existing path to the `weval` binary, if present
242-
*/
243-
wevalBin?: string;
244213
/**
245214
* Use a pre-existing path to the `wizer` binary, if present
246215
*/
@@ -266,7 +235,7 @@ export function componentize(opts: {
266235
*/
267236
enableFeatures?: [];
268237
/**
269-
* Pass environment variables to the spawned Wizer or Weval Process
238+
* Pass environment variables to the spawned Wizer Process
270239
* If set to true, all host environment variables are passed
271240
* To pass only a subset, provide an object with the desired variables
272241
*/
@@ -347,12 +316,6 @@ npm run build
347316

348317
Before being able to use `componetize-js` (ex. via `npm link`, from `jco`), you'll need to run:
349318

350-
```
351-
npm run build:weval
352-
```
353-
354-
This will produce a few files, most importantly `lib/starlingmonkey_embedding_weval.wasm`.
355-
356319
To clean up a local installation (i.e. remove the installation of StarlingMonkey):
357320

358321
```console

StarlingMonkey

Submodule StarlingMonkey updated 133 files

examples/hello-world/guest/componentize.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ import { resolve } from 'node:path';
33

44
import { componentize } from '@bytecodealliance/componentize-js';
55

6-
// AoT compilation makes use of weval (https://github.com/bytecodealliance/weval)
7-
const enableAot = process.env.ENABLE_AOT == '1';
8-
96
const jsSource = await readFile('hello.js', 'utf8');
107

118
const { component } = await componentize(jsSource, {
129
witPath: resolve('hello.wit'),
13-
enableAot
1410
});
1511

1612
await writeFile('hello.component.wasm', component);

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
},
2323
"dependencies": {
2424
"@bytecodealliance/jco": "^1.9.1",
25-
"@bytecodealliance/weval": "^0.3.4",
2625
"@bytecodealliance/wizer": "^7.0.5",
2726
"es-module-lexer": "^1.6.0",
2827
"oxc-parser": "^0.76.0"
@@ -31,13 +30,11 @@
3130
"scripts": {
3231
"clean": "npm run clean:starlingmonkey",
3332
"clean:starlingmonkey": "rm -rf build-release",
34-
"build": "npm run build:release && npm run build:debug && npm run build:weval",
33+
"build": "npm run build:release && npm run build:debug",
3534
"build:release": "make release",
36-
"build:weval": "make release-weval",
3735
"build:debug": "make debug",
3836
"test": "vitest run -c test/vitest.ts",
3937
"test:release": "vitest run -c test/vitest.ts",
40-
"test:weval": "cross-env WEVAL_TEST=1 vitest run -c test/vitest.ts",
4138
"test:debug": "cross-env DEBUG_TEST=1 vitest run -c test/vitest.ts",
4239
"prepack": "node scripts/prepack.mjs"
4340
},
@@ -46,12 +43,10 @@
4643
"lib/spidermonkey-*",
4744
"lib/starlingmonkey_embedding.wasm",
4845
"lib/starlingmonkey_embedding.debug.wasm",
49-
"lib/starlingmonkey_embedding_weval.wasm",
50-
"lib/starlingmonkey_ics.wevalcache",
5146
"src",
5247
"types.d.ts"
5348
],
5449
"workspaces": [
5550
"."
5651
]
57-
}
52+
}

src/cli.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export async function componentizeCmd(jsSource, opts) {
1111
witPath: resolve(opts.wit),
1212
worldName: opts.worldName,
1313
runtimeArgs: opts.runtimeArgs,
14-
enableAot: opts.aot,
1514
disableFeatures: opts.disable,
1615
preview2Adapter: opts.preview2Adapter,
1716
debugBindings: opts.debugBindings,
@@ -29,7 +28,6 @@ program
2928
.requiredOption('-w, --wit <path>', 'WIT path to build with')
3029
.option('-n, --world-name <name>', 'WIT world to build')
3130
.option('--runtime-args <string>', 'arguments to pass to the runtime')
32-
.option('--aot', 'enable AOT compilation')
3331
.addOption(
3432
new Option('-d, --disable <feature...>', 'disable WASI features').choices(
3533
DEFAULT_FEATURES,

src/componentize.js

Lines changed: 34 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { createHash } from 'node:crypto';
1212

1313
import oxc from 'oxc-parser';
1414
import wizer from '@bytecodealliance/wizer';
15-
import getWeval from '@bytecodealliance/weval';
1615
import {
1716
componentNew,
1817
metadataAdd,
@@ -44,11 +43,6 @@ const CHECK_INIT_RETURN_FN_LIST = 1;
4443
/** Response code from check_init() that denotes being unable to parse core ABI export types */
4544
const CHECK_INIT_RETURN_TYPE_PARSE = 2;
4645

47-
/** Default path to the AOT weval cache */
48-
const DEFAULT_AOT_CACHE = fileURLToPath(
49-
new URL(`../lib/starlingmonkey_ics.wevalcache`, import.meta.url),
50-
);
51-
5246
/** Default settings for debug options */
5347
const DEFAULT_DEBUG_SETTINGS = {
5448
bindings: false,
@@ -110,7 +104,6 @@ export async function componentize(
110104

111105
runtimeArgs,
112106

113-
aotCache = DEFAULT_AOT_CACHE,
114107
} = opts;
115108

116109
debugBindings = debugBindings || debug?.bindings;
@@ -247,100 +240,48 @@ export async function componentize(
247240
sourcePath = maybeWindowsPath(sourcePath);
248241
let workspacePrefix = dirname(sourcePath);
249242

250-
// If the source path is within the current working directory, strip the
251-
// cwd as a prefix from the source path, and remap the paths seen by the
252-
// component to be relative to the current working directory.
253-
// This only works in wizer, not in weval, because the latter doesn't
254-
// support --mapdir.
255-
if (!opts.enableAot) {
256-
if (!useOriginalSourceFile) {
257-
workspacePrefix = sourcesDir;
258-
sourcePath = sourceName;
259-
}
260-
let currentDir = maybeWindowsPath(cwd());
261-
if (workspacePrefix.startsWith(currentDir)) {
262-
workspacePrefix = currentDir;
263-
sourcePath = sourcePath.slice(workspacePrefix.length + 1);
264-
}
243+
244+
if (!useOriginalSourceFile) {
245+
workspacePrefix = sourcesDir;
246+
sourcePath = sourceName;
247+
}
248+
let currentDir = maybeWindowsPath(cwd());
249+
if (workspacePrefix.startsWith(currentDir)) {
250+
workspacePrefix = currentDir;
251+
sourcePath = sourcePath.slice(workspacePrefix.length + 1);
265252
}
266253

267254
let args = `--initializer-script-path ${initializerPath} --strip-path-prefix ${workspacePrefix}/ ${sourcePath}`;
268255
runtimeArgs = runtimeArgs ? `${runtimeArgs} ${args}` : args;
269256

270257
let preopens = [`--dir ${sourcesDir}`];
271-
if (opts.enableAot) {
272-
preopens.push(`--dir ${workspacePrefix}`);
273-
} else {
274-
preopens.push(`--mapdir /::${workspacePrefix}`);
275-
}
258+
preopens.push(`--mapdir /::${workspacePrefix}`);
276259

277260
let postProcess;
278-
if (opts.enableAot) {
279-
// Determine the weval bin path, possibly using a pre-downloaded version
280-
let wevalBin;
281-
if (opts.wevalBin && existsSync(opts.wevalBin)) {
282-
wevalBin = opts.wevalBin;
283-
} else {
284-
wevalBin = await getWeval();
285-
}
286-
287-
// Set the min stack size, if one was provided
288-
if (opts.aotMinStackSizeBytes) {
289-
if (!isNumeric(opts.aotMinStackSizeBytes)) {
290-
throw new TypeError(
291-
`aotMinStackSizeBytes must be a numeric value, received [${opts.aotMinStackSizeBytes}] (type ${typeof opts.aotMinStackSizeBytes})`,
292-
);
293-
}
294-
env.RUST_MIN_STACK = opts.aotMinStackSizeBytes;
295-
} else {
296-
env.RUST_MIN_STACK = defaultMinStackSize();
297-
}
298261

299-
postProcess = spawnSync(
300-
wevalBin,
301-
[
302-
'weval',
303-
`--cache-ro ${aotCache}`,
304-
...preopens,
305-
'-w',
306-
'--init-func',
307-
'componentize.wizer',
308-
`-i ${inputWasmPath}`,
309-
`-o ${outputWasmPath}`,
310-
],
311-
{
312-
stdio: [null, stdout, 'pipe'],
313-
env,
314-
input: runtimeArgs,
315-
shell: true,
316-
encoding: 'utf-8',
317-
},
318-
);
319-
} else {
320-
const wizerBin = opts.wizerBin ?? wizer;
321-
postProcess = spawnSync(
322-
wizerBin,
323-
[
324-
'--allow-wasi',
325-
'--init-func',
326-
'componentize.wizer',
327-
...preopens,
328-
`--wasm-bulk-memory=true`,
329-
'--inherit-env=true',
330-
`-o=${outputWasmPath}`,
331-
inputWasmPath,
332-
],
333-
{
334-
stdio: [null, stdout, 'pipe'],
335-
env,
336-
input: runtimeArgs,
337-
shell: true,
338-
encoding: 'utf-8',
339-
},
340-
);
341-
}
262+
const wizerBin = opts.wizerBin ?? wizer;
263+
postProcess = spawnSync(
264+
wizerBin,
265+
[
266+
'--allow-wasi',
267+
'--init-func',
268+
'componentize.wizer',
269+
...preopens,
270+
`--wasm-bulk-memory=true`,
271+
'--inherit-env=true',
272+
`-o=${outputWasmPath}`,
273+
inputWasmPath,
274+
],
275+
{
276+
stdio: [null, stdout, 'pipe'],
277+
env,
278+
input: runtimeArgs,
279+
shell: true,
280+
encoding: 'utf-8',
281+
},
282+
);
342283

343-
// If the wizer (or weval) process failed, parse the output and display to the user
284+
// If the wizer process failed, parse the output and display to the user
344285
if (postProcess.status !== 0) {
345286
let wizerErr = parseWizerStderr(postProcess.stderr);
346287
let err = `Failed to initialize component:\n${wizerErr}`;
@@ -451,7 +392,7 @@ function stripLinesPrefixes(input, prefixPatterns) {
451392
}
452393

453394
/**
454-
* Parse output of post-processing step (whether Wizer or Weval)
395+
* Parse output of post-processing Wizer step
455396
*
456397
* @param {Stream} stderr
457398
* @returns {string} String that can be printed to describe error output
@@ -493,9 +434,7 @@ function getEnginePath(opts) {
493434
}
494435
const debugSuffix = opts?.debugBuild ? '.debug' : '';
495436
let engineBinaryRelPath = `../lib/starlingmonkey_embedding${debugSuffix}.wasm`;
496-
if (opts.enableAot) {
497-
engineBinaryRelPath = '../lib/starlingmonkey_embedding_weval.wasm';
498-
}
437+
499438
return fileURLToPath(new URL(engineBinaryRelPath, import.meta.url));
500439
}
501440

0 commit comments

Comments
 (0)