Skip to content

Commit fe341fe

Browse files
author
Guy Bedford
authored
feat: support the debugBuild option for debugging Wasm stacks (#192)
1 parent 7f18854 commit fe341fe

File tree

9 files changed

+557
-320
lines changed

9 files changed

+557
-320
lines changed

.github/workflows/main.yml

Lines changed: 56 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -34,124 +34,49 @@ jobs:
3434

3535
build-splicer:
3636
runs-on: ubuntu-latest
37-
strategy:
38-
fail-fast: false
39-
matrix:
40-
node-version:
41-
- '22'
42-
- latest
4337
steps:
4438
- uses: actions/checkout@v4
4539

46-
- name: Install Rust Toolchain
47-
run: |
48-
rustup toolchain install 1.77.1
49-
rustup target add wasm32-wasi --toolchain 1.77.1
50-
rustup target add wasm32-wasip1
51-
52-
- uses: actions/setup-node@v4
53-
with:
54-
node-version: ${{matrix.node-version}}
55-
56-
- name: Install NPM packages
57-
run: npm install
58-
5940
- name: Cache Splicer build
6041
uses: actions/cache@v4
6142
id: splicer-build
6243
with:
63-
key: output-splicer-node-${{matrix.node-version}}-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
44+
key: splicer-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
6445
path: |
65-
lib/spidermonkey-embedding-splicer.core2.wasm
66-
lib/spidermonkey-embedding-splicer.core.wasm
67-
lib/spidermonkey-embedding-splicer.d.ts
68-
lib/spidermonkey-embedding-splicer.js
46+
lib
6947
target
7048
71-
- name: Build splicer
72-
if: steps.splicer-build.outputs.cache-hit != 'true'
73-
run: |
74-
make lib/spidermonkey-embedding-splicer.js
75-
76-
build-jit:
77-
runs-on: ubuntu-latest
78-
needs:
79-
- build-splicer
80-
strategy:
81-
fail-fast: false
82-
matrix:
83-
node-version:
84-
- '22'
85-
- latest
86-
steps:
87-
- uses: actions/checkout@v4
88-
with:
89-
submodules: recursive
90-
91-
- name: Get StarlingMonkey Commit
92-
id: starlingmonkey-commit
93-
run: echo "STARLINGMONKEY_HASH=$(git submodule status | head -c9 | tail -c8)" >> "$GITHUB_OUTPUT"
94-
9549
- name: Install Rust Toolchain
50+
if: steps.splicer-build.outputs.cache-hit != 'true'
9651
run: |
9752
rustup toolchain install 1.77.1
9853
rustup target add wasm32-wasi --toolchain 1.77.1
9954
rustup target add wasm32-wasip1
10055
101-
- name: Restore Embedding Splicer from cache
102-
uses: actions/cache/restore@v4
103-
id: splicer-build
104-
with:
105-
key: output-splicer-node-${{matrix.node-version}}-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
106-
path: |
107-
lib/spidermonkey-embedding-splicer.core2.wasm
108-
lib/spidermonkey-embedding-splicer.core.wasm
109-
lib/spidermonkey-embedding-splicer.d.ts
110-
lib/spidermonkey-embedding-splicer.js
111-
target
112-
11356
- uses: actions/setup-node@v4
57+
if: steps.splicer-build.outputs.cache-hit != 'true'
11458
with:
115-
node-version: ${{matrix.node-version}}
59+
node-version: '22'
11660

11761
- name: Install NPM packages
62+
if: steps.splicer-build.outputs.cache-hit != 'true'
11863
run: npm install
11964

120-
- name: Cache StarlingMonkey
121-
uses: actions/cache@v4
122-
id: starlingmonkey-jit
123-
with:
124-
key: output-starlingmonkey-jit-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
125-
lookup-only: 'true'
126-
path: |
127-
lib/starlingmonkey_embedding.wasm
128-
build-release
129-
130-
- name: Build ComponentizeJS
131-
if: steps.starlingmonkey-jit.outputs.cache-hit != 'true'
132-
run: |
133-
npm run clean
134-
npm run build
135-
136-
- uses: actions/upload-artifact@v4
137-
if: steps.starlingmonkey-jit.outputs.cache-hit != 'true'
138-
with:
139-
name: starlingmonkey-jit-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
140-
if-no-files-found: 'error'
141-
path: |
142-
lib/starlingmonkey_embedding.wasm
143-
build-release
65+
- name: Build splicer
66+
if: steps.splicer-build.outputs.cache-hit != 'true'
67+
run: make lib/spidermonkey-embedding-splicer.js
14468

145-
build-aot:
69+
build:
14670
runs-on: ubuntu-latest
14771
needs:
14872
- build-splicer
14973
strategy:
15074
fail-fast: false
15175
matrix:
152-
node-version:
153-
- '22'
154-
- latest
76+
build-type:
77+
- 'release'
78+
- 'debug'
79+
- 'weval'
15580
steps:
15681
- uses: actions/checkout@v4
15782
with:
@@ -160,108 +85,79 @@ jobs:
16085
- name: Get StarlingMonkey Commit
16186
id: starlingmonkey-commit
16287
run: echo "STARLINGMONKEY_HASH=$(git submodule status | head -c9 | tail -c8)" >> "$GITHUB_OUTPUT"
88+
89+
- uses: actions/cache@v4
90+
id: starlingmonkey-build
91+
with:
92+
key: starlingmonkey-${{matrix.build-type}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
93+
path: lib
16394

16495
- name: Install Rust Toolchain
96+
if: steps.starlingmonkey-build.outputs.cache-hit != 'true'
16597
run: |
16698
rustup toolchain install 1.77.1
16799
rustup target add wasm32-wasi --toolchain 1.77.1
168100
rustup target add wasm32-wasip1
169101
102+
- name: Install wasm-tools
103+
if: steps.starlingmonkey-build.outputs.cache-hit != 'true'
104+
run: cargo install wasm-tools
105+
170106
- name: Restore Embedding Splicer from cache
171107
uses: actions/cache/restore@v4
172108
id: splicer-build
173109
with:
174-
key: output-splicer-node-${{matrix.node-version}}-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
110+
key: splicer-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
175111
path: |
176-
lib/spidermonkey-embedding-splicer.core2.wasm
177-
lib/spidermonkey-embedding-splicer.core.wasm
178-
lib/spidermonkey-embedding-splicer.d.ts
179-
lib/spidermonkey-embedding-splicer.js
112+
lib
180113
target
181114
182115
- uses: actions/setup-node@v4
116+
if: steps.starlingmonkey-build.outputs.cache-hit != 'true'
183117
with:
184-
node-version: ${{matrix.node-version}}
118+
node-version: '22'
185119

186120
- name: Install NPM packages
121+
if: steps.starlingmonkey-build.outputs.cache-hit != 'true'
187122
run: npm install
188123

189-
- name: Cache StarlingMonkey (Weval)
190-
uses: actions/cache@v4
191-
id: starlingmonkey-aot
192-
with:
193-
key: output-starlingmonkey-aot-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
194-
lookup-only: 'true'
195-
path: |
196-
lib/starlingmonkey_embedding_weval.wasm
197-
lib/starlingmonkey_ics.wevalcache
198-
build-release-weval
199-
200-
- name: Build Weval
201-
if: steps.starlingmonkey-aot.outputs.cache-hit != 'true'
124+
- name: Build ComponentizeJS
125+
if: steps.starlingmonkey-build.outputs.cache-hit != 'true'
202126
run: |
203127
npm run clean
204-
npm run build:weval
205-
206-
- uses: actions/upload-artifact@v4
207-
if: steps.starlingmonkey-aot.outputs.cache-hit != 'true'
208-
with:
209-
name: starlingmonkey-aot-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
210-
if-no-files-found: 'error'
211-
path: |
212-
lib/starlingmonkey_embedding_weval.wasm
213-
lib/starlingmonkey_ics.wevalcache
214-
build-release-weval
128+
npm run build:${{matrix.build-type}}
215129
216130
########
217131
# Test #
218132
########
219133

220-
test-jit:
134+
test:
221135
runs-on: ubuntu-latest
222136
needs:
223-
- build-jit
137+
- build
224138
strategy:
225139
fail-fast: false
226140
matrix:
227141
node-version:
228-
- '22'
229-
- latest
142+
- '22.14.0'
143+
# - latest reenable when https://github.com/nodejs/node/issues/57172 is fixed
144+
build-type:
145+
- 'release'
146+
- 'debug'
147+
- 'weval'
230148
steps:
231149
- uses: actions/checkout@v4
232150

233151
- name: Get StarlingMonkey Commit
234152
id: starlingmonkey-commit
235153
run: echo "STARLINGMONKEY_HASH=$(git submodule status | head -c9 | tail -c8)" >> "$GITHUB_OUTPUT"
236154

237-
- name: Restore Embedding Splicer from cache
238-
uses: actions/cache/restore@v4
239-
id: splicer-build
240-
with:
241-
key: output-splicer-node-${{matrix.node-version}}-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
242-
path: |
243-
lib/spidermonkey-embedding-splicer.core2.wasm
244-
lib/spidermonkey-embedding-splicer.core.wasm
245-
lib/spidermonkey-embedding-splicer.d.ts
246-
lib/spidermonkey-embedding-splicer.js
247-
target
248-
249155
- name: Restore StarlingMonkey build from cache
250156
uses: actions/cache/restore@v4
251157
id: restore-starlingmonkey-jit-build
252158
with:
253-
key: output-starlingmonkey-jit-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
254-
path: |
255-
lib/starlingmonkey_embedding.wasm
256-
build-release
257-
258-
- uses: actions/download-artifact@v4
259-
if: steps.restore-starlingmonkey-jit-build.outputs.cache-hit != 'true'
260-
with:
261-
name: starlingmonkey-jit-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
262-
path: |
263-
lib/starlingmonkey_embedding.wasm
264-
build-release
159+
key: starlingmonkey-${{matrix.build-type}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
160+
path: lib
265161

266162
- uses: actions/setup-node@v4
267163
with:
@@ -271,84 +167,40 @@ jobs:
271167
run: npm install
272168

273169
- name: Test
274-
run: npm run test
275-
276-
- name: Cache Example build
277-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # 4.1.2
278-
with:
279-
path: example/target
280-
key: output-example-jit-cargo-${{ hashFiles('example/src/main.rs', 'example/Cargo.lock', 'example/hello.wit') }}
170+
run: npm run test:${{matrix.build-type}}
281171

282-
- name: Test Example
283-
working-directory: examples/hello-world
284-
run: bash test.sh
285-
286-
test-aot:
172+
test-example:
287173
runs-on: ubuntu-latest
288174
needs:
289-
- build-aot
290-
strategy:
291-
fail-fast: false
292-
matrix:
293-
node-version:
294-
- '22'
295-
- latest
296-
env:
297-
ENABLE_AOT: "1"
175+
- build
298176
steps:
299177
- uses: actions/checkout@v4
300178

301179
- name: Get StarlingMonkey Commit
302180
id: starlingmonkey-commit
303181
run: echo "STARLINGMONKEY_HASH=$(git submodule status | head -c9 | tail -c8)" >> "$GITHUB_OUTPUT"
304182

305-
- name: Restore Embedding Splicer from cache
306-
uses: actions/cache/restore@v4
307-
id: splicer-build
308-
with:
309-
key: output-splicer-node-${{matrix.node-version}}-${{ hashFiles('Cargo.lock', 'crates/spidermonkey-embedding-splicer/src/**/*.rs') }}
310-
path: |
311-
lib/spidermonkey-embedding-splicer.core2.wasm
312-
lib/spidermonkey-embedding-splicer.core.wasm
313-
lib/spidermonkey-embedding-splicer.d.ts
314-
lib/spidermonkey-embedding-splicer.js
315-
target
316-
317-
- name: Restore StarlingMonkey AOT build from cache
183+
- name: Restore StarlingMonkey build from cache
318184
uses: actions/cache/restore@v4
319-
id: restore-starlingmonkey-aot-build
320-
with:
321-
key: output-starlingmonkey-aot-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
322-
path: |
323-
lib/starlingmonkey_embedding_weval.wasm
324-
lib/starlingmonkey_ics.wevalcache
325-
build-release-weval
326-
327-
- uses: actions/download-artifact@v4
328-
if: steps.restore-starlingmonkey-aot-build.outputs.cache-hit != 'true'
185+
id: restore-starlingmonkey-jit-build
329186
with:
330-
name: starlingmonkey-aot-node-${{matrix.node-version}}-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
331-
path: |
332-
lib/starlingmonkey_embedding_weval.wasm
333-
lib/starlingmonkey_ics.wevalcache
334-
build-release-weval
187+
key: starlingmonkey-release-${{ steps.starlingmonkey-commit.outputs.STARLINGMONKEY_HASH }}
188+
path: lib
335189

336190
- uses: actions/setup-node@v4
337191
with:
338-
node-version: ${{matrix.node-version}}
192+
node-version: '22'
339193

340194
- name: Install NPM packages
341195
run: npm install
342196

343-
- name: Test
344-
run: npm run test:weval
345-
346197
- name: Cache Example build
347198
uses: actions/cache@v4
348199
with:
349-
path: example/target
350-
key: output-example-aot-cargo-${{ hashFiles('example/src/main.rs', 'example/Cargo.lock', 'example/hello.wit') }}
200+
path: examples/target
201+
key: example-jit-cargo-${{ hashFiles('examples/src/main.rs', 'examples/Cargo.lock', 'examples/hello.wit') }}
351202

352203
- name: Test Example
353-
working-directory: examples/hello-world
354-
run: bash test.sh
204+
run: |
205+
cd examples/hello-world
206+
./test.sh

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ lib/starlingmonkey_ics.wevalcache: lib/starlingmonkey_embedding_weval.wasm
3737
lib/starlingmonkey_embedding.debug.wasm: StarlingMonkey/cmake/* embedding/* StarlingMonkey/runtime/* StarlingMonkey/builtins/* StarlingMonkey/builtins/*/* StarlingMonkey/builtins/*/*/* StarlingMonkey/include/* | lib
3838
cmake -B build-debug -DCMAKE_BUILD_TYPE=RelWithDebInfo
3939
make -j16 -C build-debug
40-
@cp build-debug/starling-raw.wasm/starling-raw.wasm $@
40+
wasm-tools strip build-debug/starling-raw.wasm/starling-raw.wasm -d ".debug_(info|loc|ranges|abbrev|line|str)" -o $@
4141

4242
obj:
4343
mkdir -p obj

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export function componentize(jsSource: string, opts: {
178178
witPath: string,
179179
worldName: string,
180180
debug?: bool,
181+
debugBuild?: bool,
181182
sourceName?: string,
182183
engine?: string,
183184
preview2Adapter?: string,

0 commit comments

Comments
 (0)