Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: strip wasm debug #9987

Merged
merged 8 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion barretenberg/acir_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
acir_tests
acir_tests
**/.yarn/*
!**/.yarn/releases
4 changes: 4 additions & 0 deletions barretenberg/acir_tests/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

(cd headless-test && yarn && npx playwright install && npx playwright install-deps)
(cd browser-test-app && yarn && yarn build)
1 change: 1 addition & 0 deletions barretenberg/acir_tests/browser-test-app/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
7,591 changes: 4,618 additions & 2,973 deletions barretenberg/acir_tests/browser-test-app/yarn.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions barretenberg/acir_tests/headless-test/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion barretenberg/acir_tests/headless-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"chalk": "^5.3.0",
"commander": "^12.1.0",
"playwright": "^1.42.1",
"playwright": "^1.48.2",
"puppeteer": "^22.4.1"
},
"devDependencies": {
Expand Down
2,991 changes: 2,046 additions & 945 deletions barretenberg/acir_tests/headless-test/yarn.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@
"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE": "ONLY",
"CMAKE_C_COMPILER_WORKS": "ON",
"CMAKE_CXX_COMPILER_WORKS": "ON",
"MULTITHREADING": "OFF"
"MULTITHREADING": "OFF",
"DISABLE_AZTEC_VM": "ON"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ preset-wasm:
SAVE ARTIFACT build/bin
ELSE
DO +CACHE_BUILD_BIN --prefix=preset-wasm \
--command="cmake --preset wasm -Bbuild && cmake --build build --target barretenberg.wasm && /opt/wasi-sdk/bin/llvm-strip ./build/bin/barretenberg.wasm"
--command="cmake --preset wasm -Bbuild && cmake --build build --target barretenberg.wasm && /opt/wasi-sdk/bin/llvm-strip ./build/bin/barretenberg.wasm && gzip -c ./build/bin/barretenberg.wasm > ./build/bin/barretenberg.wasm.gz"
SAVE ARTIFACT build/bin
SAVE IMAGE --cache-hint
END
Expand All @@ -140,7 +140,7 @@ preset-sol:
preset-wasm-threads:
FROM +source
DO +CACHE_BUILD_BIN --prefix=preset-wasm-threads \
--command="cmake --preset wasm-threads -Bbuild && cmake --build build --target barretenberg.wasm"
--command="cmake --preset wasm-threads -Bbuild && cmake --build build --target barretenberg.wasm && /opt/wasi-sdk/bin/llvm-strip ./build/bin/barretenberg.wasm && gzip -c ./build/bin/barretenberg.wasm > ./build/bin/barretenberg.wasm.gz"
SAVE ARTIFACT build/bin

preset-gcc:
Expand Down
3 changes: 3 additions & 0 deletions barretenberg/cpp/scripts/gzip-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
(cd ./build-wasm/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz)
(cd ./build-wasm-threads/bin && gzip barretenberg.wasm -c > barretenberg.wasm.gz)
3 changes: 1 addition & 2 deletions barretenberg/cpp/scripts/strip-wasm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh
/opt/wasi-sdk/bin/llvm-strip ./build-wasm/bin/barretenberg.wasm
# TODO(https://github.com/AztecProtocol/barretenberg/issues/941) We currently do not strip barretenberg threaded wasm, for stack traces.
# /opt/wasi-sdk/bin/llvm-strip ./build-wasm-threads/bin/barretenberg.wasm
/opt/wasi-sdk/bin/llvm-strip ./build-wasm-threads/bin/barretenberg.wasm
8 changes: 4 additions & 4 deletions barretenberg/ts/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ deps:
COPY --dir src *.json *.js *.cjs *.md .

# copy over wasm builds from cpp folder
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm src/barretenberg_wasm/barretenberg-threads.wasm
COPY ../cpp/+preset-wasm/bin/barretenberg.wasm src/barretenberg_wasm/barretenberg.wasm
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm dest/node/barretenberg_wasm/barretenberg-threads.wasm
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm.gz src/barretenberg_wasm/barretenberg-threads.wasm.gz
COPY ../cpp/+preset-wasm/bin/barretenberg.wasm.gz src/barretenberg_wasm/barretenberg.wasm.gz
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm.gz dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz
COPY ../cpp/+preset-wasm-threads/bin/barretenberg.wasm.gz dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz

esm:
FROM +deps
Expand Down
1 change: 1 addition & 0 deletions barretenberg/ts/scripts/build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if [ -z "$SKIP_CPP_BUILD" ]; then
cmake --preset wasm -DCMAKE_MESSAGE_LOG_LEVEL=Warning && cmake --build --preset wasm
fi
./scripts/strip-wasm.sh
./scripts/gzip-wasm.sh
cd ../ts
fi

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion barretenberg/ts/src/barretenberg_wasm/barretenberg.wasm

This file was deleted.

1 change: 1 addition & 0 deletions barretenberg/ts/src/barretenberg_wasm/barretenberg.wasm.gz
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import barretenbergModule from '../../barretenberg.wasm';
import barretenbergThreadsModule from '../../barretenberg-threads.wasm';
import barretenbergModule from '../../barretenberg.wasm.gz';
import barretenbergThreadsModule from '../../barretenberg-threads.wasm.gz';
import pako from 'pako';

// Annoyingly the wasm declares if it's memory is shared or not. So now we need two wasms if we want to be
// able to fallback on "non shared memory" situations.
export async function fetchCode(multithreaded: boolean) {
const res = await fetch(multithreaded ? barretenbergThreadsModule : barretenbergModule);
return await res.arrayBuffer();
const compressedData = await res.arrayBuffer();
const decompressedData = pako.ungzip(new Uint8Array(compressedData));
return decompressedData.buffer;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module '*.wasm' {
declare module '*.wasm.gz' {
const content: string;
export default content;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFile } from 'fs/promises';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import pako from 'pako';

function getCurrentDir() {
if (typeof __dirname !== 'undefined') {
Expand All @@ -14,6 +15,8 @@ function getCurrentDir() {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function fetchCode(multithreaded: boolean) {
const path = getCurrentDir() + '/../../barretenberg-threads.wasm';
return await readFile(path);
const path = getCurrentDir() + '/../../barretenberg-threads.wasm.gz';
const compressedData = await readFile(path);
const decompressedData = pako.ungzip(new Uint8Array(compressedData));
return decompressedData.buffer;
}
6 changes: 3 additions & 3 deletions barretenberg/ts/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
module: {
rules: [
{
test: /\.wasm$/,
test: /\.wasm\.gz$/,
type: 'asset/inline',
},
{
Expand Down Expand Up @@ -53,8 +53,8 @@ export default {
resolve: {
plugins: [new ResolveTypeScriptPlugin()],
fallback: {
"os": false
}
os: false,
},
},
devServer: {
hot: false,
Expand Down
Loading