Skip to content

Commit 2be17c7

Browse files
Guy BedfordJakeChampion
andauthored
StarlingMonkey debug build with names section only (#882)
Co-authored-by: Jake Champion <[email protected]>
1 parent 60d1d20 commit 2be17c7

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
- uses: actions/upload-artifact@v3
138138
with:
139139
name: engine-${{ matrix.profile }}
140+
if-no-files-found: error
140141
path: |
141142
js-compute-runtime.wasm
142143
js-compute-runtime-component.wasm
@@ -403,6 +404,12 @@ jobs:
403404
run: |
404405
rustup toolchain install 1.77.1
405406
rustup target add wasm32-wasi --toolchain 1.77.1
407+
- name: Restore wasm-tools from cache
408+
uses: actions/cache@v3
409+
id: wasm-tools
410+
with:
411+
path: "/home/runner/.cargo/bin/wasm-tools"
412+
key: crate-cache-wasm-tools-${{ env.wasm-tools_version }}
406413
- name: Build
407414
if: ${{ matrix.profile == 'release' }}
408415
run: npm run build:starlingmonkey
@@ -411,8 +418,9 @@ jobs:
411418
run: npm run build:starlingmonkey:debug
412419
- uses: actions/upload-artifact@v3
413420
with:
421+
if-no-files-found: error
414422
name: starling-${{ matrix.profile }}
415-
path: starling.wasm
423+
path: starling${{ matrix.profile == 'debug' && '.debug.wasm' || '.wasm' }}
416424

417425
starlingmonkey-run_wpt:
418426
concurrency:
@@ -529,6 +537,6 @@ jobs:
529537
- name: Yarn install
530538
run: yarn && cd ./integration-tests/js-compute && yarn
531539

532-
- run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }}
540+
- run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'debug' && '--debug-build' || '' }}
533541
env:
534542
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ node_modules/
1414
/rusturl/
1515
# compiler_flags
1616
/js-compute-runtime.wasm
17-
/js-compute-runtime-component.wasm
17+
/starling.debug.wasm
1818
/starling.wasm
1919
/runtime/js-compute-runtime/obj
2020
tests/wpt-harness/wpt-test-runner.js

integration-tests/js-compute/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ let args = argv.slice(2);
3636

3737
const local = args.includes('--local');
3838
const starlingmonkey = !args.includes('--disable-starlingmonkey');
39+
const debugBuild = args.includes('--debug-build');
3940
const filter = args.filter(arg => !arg.startsWith('--'));
4041

4142
async function $(...args) {
@@ -72,6 +73,11 @@ if (!starlingmonkey) {
7273
buildArgs.splice(-1, null, '--disable-starlingmonkey')
7374
config.scripts.build = buildArgs.join(' ')
7475
}
76+
if (debugBuild) {
77+
const buildArgs = config.scripts.build.split(' ')
78+
buildArgs.splice(-1, null, '--debug-build')
79+
config.scripts.build = buildArgs.join(' ')
80+
}
7581
await writeFile(join(fixturePath, 'fastly.toml'), TOML.stringify(config), 'utf-8')
7682
if (!local) {
7783
core.startGroup('Delete service if already exists')

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,28 @@
1616
"files": [
1717
"types",
1818
"js-compute-runtime-cli.js",
19-
"*.wasm",
19+
"starling.wasm",
20+
"js-compute-runtime.wasm",
2021
"src",
2122
"index.d.ts",
2223
"package.json",
2324
"README.md",
2425
"CHANGELOG.md"
2526
],
2627
"ignore": [
27-
"starling.wasm"
28+
"starling.debug.wasm"
2829
],
2930
"scripts": {
3031
"test": "npm run test:types && npm run test:cli",
3132
"test:cli": "brittle --bail integration-tests/cli/**.test.js",
32-
"test:integration": "node ./integration-tests/js-compute/test.js --disable-starlingmonkey",
33+
"test:integration": "node ./integration-tests/js-compute/test.js",
3334
"test:wpt": "tests/wpt-harness/build-wpt-runtime.sh && node ./tests/wpt-harness/run-wpt.mjs -vv",
3435
"test:types": "tsd",
3536
"build": "make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/js-compute-runtime.wasm .",
3637
"build:debug": "DEBUG=true make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/js-compute-runtime.wasm .",
3738
"build:starlingmonkey": "./runtime/fastly/build-release.sh",
3839
"build:starlingmonkey:debug": "./runtime/fastly/build-debug.sh",
40+
"build:starlingmonkey:debug:info": "./runtime/fastly/build-debug.sh --keep-debug-info",
3941
"format-changelog": "node ci/format-changelog.js CHANGELOG.md"
4042
},
4143
"devDependencies": {

runtime/fastly/build-debug.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
set -x
5+
26
cd "$(dirname "$0")" || exit 1
37
RUNTIME_VERSION=$(npm pkg get version --json --prefix=../../ | jq -r)
48
HOST_API=$(realpath host-api) cmake -B build-debug -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILTIN_WEB_FETCH=0 -DENABLE_BUILTIN_WEB_FETCH_FETCH_EVENT=0 -DRUNTIME_VERSION="\"$RUNTIME_VERSION-debug\""
59
cmake --build build-debug --parallel 10
6-
mv build-debug/starling.wasm/starling.wasm ../../
10+
if [ "${1:-default}" != "--keep-debug-info" ]; then
11+
wasm-tools strip build-debug/starling.wasm/starling.wasm -d ".debug_(info|loc|ranges|abbrev|line|str)" -o ../../starling.debug.wasm
12+
else
13+
cp build-debug/starling.wasm/starling.wasm ../../starling.debug.wasm
14+
fi

src/parseInputs.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { fileURLToPath } from "node:url";
22
import { dirname, join, isAbsolute } from "node:path";
33
import { unknownArgument } from "./unknownArgument.js";
44
import { tooManyEngines } from "./tooManyEngines.js";
5+
import { existsSync } from "node:fs";
56

67
export async function parseInputs(cliInputs) {
78
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -47,6 +48,16 @@ export async function parseInputs(cliInputs) {
4748
case "--starlingmonkey": {
4849
break;
4950
}
51+
case "--debug-build": {
52+
starlingMonkey = true;
53+
wasmEngine = join(__dirname, "../starling.debug.wasm");
54+
if (!existsSync(wasmEngine)) {
55+
console.error('Debug builds are not currently available for published releases');
56+
process.exit(1);
57+
}
58+
console.log('Building with the debug engine');
59+
break;
60+
}
5061
case "--disable-starlingmonkey": {
5162
starlingMonkey = false;
5263
wasmEngine = join(__dirname, "../js-compute-runtime.wasm");

0 commit comments

Comments
 (0)