# Objective Bumps `wasi-sdk` to v34 that is based on LLVM 23.1 which includes [a compile time and memory usage fix](https://github.com/llvm/llvm-project/pull/181755) for tree-sitter grammars. It speeds up every grammar's compile time and reduces compile memory usage unlocking big grammars that were impossible to compile before to be submitted to Zed extensions. Drive-by added additional wasi-sdk targets for the rest of the supported architectures (by wasi-sdk), if riscv is unwanted I can remove it but it should not create any problems (I think). Also noticed the `download-wasi-sdk` script had `OS=mingw` which wasn't even in the artifact name on v25. ## Testing Compiled, ran and compiled my [big grammar](https://github.com/usagi-coffee/tree-sitter-abl) on it, that wouldn't compile at all pre-llvm 23. ## Self-Review Checklist: - [X] I've reviewed my own diff for quality, security, and reliability --- Release Notes: - Fixed compiling dev extensions with big Tree-sitter grammars. - Fixed compiling dev extensions on Windows ARM64. - Added wasi-sdk installation invalidation. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
75 lines
1.8 KiB
Bash
Executable File
75 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
WASI_SDK_VERSION="34"
|
|
WASI_SDK_DIR="./target/wasi-sdk"
|
|
|
|
installed_version=""
|
|
if [ -f "${WASI_SDK_DIR}/VERSION" ]; then
|
|
installed_version=$(head -n 1 "${WASI_SDK_DIR}/VERSION" | tr -d '\r')
|
|
fi
|
|
|
|
if [ "${installed_version}" = "${WASI_SDK_VERSION}.0" ]; then
|
|
echo "WASI SDK v${WASI_SDK_VERSION} already exists at ${WASI_SDK_DIR}"
|
|
exit 0
|
|
fi
|
|
|
|
if [ -d "${WASI_SDK_DIR}" ]; then
|
|
echo "WASI SDK at ${WASI_SDK_DIR} is version '${installed_version}', replacing with v${WASI_SDK_VERSION}..."
|
|
else
|
|
echo "WASI SDK not found, downloading v${WASI_SDK_VERSION}..."
|
|
fi
|
|
|
|
# Determine OS and architecture
|
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
ARCH=$(uname -m)
|
|
|
|
# Map architecture names to WASI SDK format
|
|
case $ARCH in
|
|
x86_64)
|
|
ARCH="x86_64"
|
|
;;
|
|
arm64|aarch64)
|
|
ARCH="arm64"
|
|
;;
|
|
*)
|
|
echo "Unsupported architecture: $ARCH"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Map OS names to WASI SDK format
|
|
case $OS in
|
|
darwin)
|
|
OS="macos"
|
|
;;
|
|
linux)
|
|
OS="linux"
|
|
;;
|
|
mingw*|msys*|cygwin*)
|
|
OS="windows"
|
|
;;
|
|
*)
|
|
echo "Unsupported OS: $OS"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Construct download URL
|
|
WASI_SDK_URL="https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-${ARCH}-${OS}.tar.gz"
|
|
|
|
echo "Downloading from: $WASI_SDK_URL"
|
|
|
|
# Create target directory if it doesn't exist
|
|
mkdir -p ./target
|
|
|
|
# Download and extract
|
|
rm -rf "./target/wasi-sdk-${WASI_SDK_VERSION}.0-${ARCH}-${OS}"
|
|
curl -fL "$WASI_SDK_URL" | tar -xz -C ./target
|
|
|
|
# Rename the extracted directory to wasi-sdk
|
|
rm -rf "${WASI_SDK_DIR}"
|
|
mv "./target/wasi-sdk-${WASI_SDK_VERSION}.0-${ARCH}-${OS}" "${WASI_SDK_DIR}"
|
|
|
|
echo "WASI SDK v${WASI_SDK_VERSION} installed successfully"
|