mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-09 18:18:49 +00:00
Closes #1159 This uses the binaryen tool wasm2js to compile the Anubis WASM blobs to JavaScript. This produces biblically large (520Ki) outputs when you inline both hashx and sha256 solvers, but this is a tradeoff that I'm willing to accept. The performance is good enough in my testing with JIT enabled. I fear that this may end up being terrible with JIT disabled. I have no idea if this will work on big endian or not. Signed-off-by: Xe Iaso <me@xeiaso.net>
24 lines
939 B
Bash
Executable File
24 lines
939 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
mkdir -p ./web/static/wasm/{simd128,baseline}
|
|
|
|
cargo clean
|
|
|
|
# With simd128
|
|
RUSTFLAGS='-C target-feature=+simd128' cargo build --release --target wasm32-unknown-unknown
|
|
cp -vf ./target/wasm32-unknown-unknown/release/*.wasm ./web/static/wasm/simd128
|
|
|
|
cargo clean
|
|
|
|
# Without simd128
|
|
cargo build --release --target wasm32-unknown-unknown
|
|
cp -vf ./target/wasm32-unknown-unknown/release/*.wasm ./web/static/wasm/baseline
|
|
|
|
for file in ./web/static/wasm/baseline/*.wasm; do
|
|
echo $file
|
|
rm -f ${file%.*}.wasmjs
|
|
wasm2js $file -all -O4 --strip-debug --rse --rereloop --optimize-for-js --flatten --dce --dfo --fpcast-emu --denan --dealign --remove-imports --remove-unused-names --remove-unused-brs --reorder-functions --reorder-locals --strip-target-features --untee --vacuum -s 4 -ffm -lmu -tnh -iit -n -o ${file%.*}.mjs
|
|
sed -i '1s$.*$const anubis_update_nonce = (_ignored) => { };$' ${file%.*}.mjs
|
|
done |