Add two-phase build with host asyncify transformation
- Move asyncify from Docker to host to avoid memory issues - Auto-download Binaryen v121 (v125 has regression bug) - Use -O1 for debug builds (V8 local count limit) - Remove asyncify flags from linker (handled by wasm-opt) - Document two-phase build in build.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0c48855191
commit
b70f098ae2
6 changed files with 187 additions and 19 deletions
66
scripts/common/get-wasm-opt.sh
Executable file
66
scripts/common/get-wasm-opt.sh
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
# Download and cache Binaryen wasm-opt
|
||||
#
|
||||
# Usage: ./scripts/tools/get-wasm-opt.sh
|
||||
# Output: Prints path to wasm-opt executable
|
||||
#
|
||||
# Binaryen v121 is used because v125 has a regression causing asyncify crashes.
|
||||
# The binary is cached in tools/binaryen-121/
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
||||
|
||||
BINARYEN_VERSION="121"
|
||||
BINARYEN_DIR="${PROJECT_ROOT}/tools/binaryen-${BINARYEN_VERSION}"
|
||||
WASM_OPT="${BINARYEN_DIR}/bin/wasm-opt"
|
||||
|
||||
download_binaryen() {
|
||||
# Detect platform
|
||||
local os=$(uname -s)
|
||||
local arch=$(uname -m)
|
||||
local platform=""
|
||||
|
||||
case "${os}-${arch}" in
|
||||
Darwin-arm64) platform="arm64-macos" ;;
|
||||
Darwin-x86_64) platform="x86_64-macos" ;;
|
||||
Linux-aarch64) platform="aarch64-linux" ;;
|
||||
Linux-x86_64) platform="x86_64-linux" ;;
|
||||
*)
|
||||
echo "ERROR: Unsupported platform: ${os}-${arch}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
local url="https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-${platform}.tar.gz"
|
||||
local tarball="${PROJECT_ROOT}/tools/binaryen-${BINARYEN_VERSION}.tar.gz"
|
||||
|
||||
echo "Downloading Binaryen v${BINARYEN_VERSION} for ${platform}..." >&2
|
||||
mkdir -p "${PROJECT_ROOT}/tools"
|
||||
curl -L -o "${tarball}" "${url}"
|
||||
|
||||
echo "Extracting..." >&2
|
||||
tar -xzf "${tarball}" -C "${PROJECT_ROOT}/tools"
|
||||
mv "${PROJECT_ROOT}/tools/binaryen-version_${BINARYEN_VERSION}" "${BINARYEN_DIR}"
|
||||
rm "${tarball}"
|
||||
|
||||
echo "Binaryen v${BINARYEN_VERSION} installed to ${BINARYEN_DIR}" >&2
|
||||
}
|
||||
|
||||
# Download Binaryen if not cached
|
||||
if [ ! -x "${WASM_OPT}" ]; then
|
||||
download_binaryen
|
||||
fi
|
||||
|
||||
# Verify version
|
||||
INSTALLED_VERSION=$("${WASM_OPT}" --version 2>&1 | grep -o '[0-9]\+' | head -1)
|
||||
if [ "${INSTALLED_VERSION}" != "${BINARYEN_VERSION}" ]; then
|
||||
echo "WARNING: wasm-opt version mismatch (got ${INSTALLED_VERSION}, expected ${BINARYEN_VERSION})" >&2
|
||||
echo "Re-downloading..." >&2
|
||||
rm -rf "${BINARYEN_DIR}"
|
||||
download_binaryen
|
||||
fi
|
||||
|
||||
# Output path to wasm-opt (this is the only stdout output)
|
||||
echo "${WASM_OPT}"
|
||||
Loading…
Reference in a new issue