fix(wasm): pass target triple to clang (#5385)

Problem: The `clang` binary contained in the WASI-SDK releases downloaded from Github does not work on all platforms (e.g., Alpine/MUSL), but a custom (LLVM) `clang` built for the platform will default to that target, making it impossible to build wasm parsers.

Solution: Always pass `wasm32` target triple when calling clang to compile to wasm.

Notes:
* This assumes the custom `clang` is (installed or linked) to `$TREE_SITTER_WASI_SDK_PATH/bin`.
* This requires a full LLVM clang; Apple clang does not support `wasm` targets. 
* Tree-sitter expects a specified version of WASI-SDK, including a specific `clang` version. Other versions may but are not guaranteed to work.
This commit is contained in:
Marian Buschsieweke 2026-02-28 10:59:56 +01:00 committed by GitHub
parent 146ea6e12b
commit a3bca3bc45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1388,6 +1388,7 @@ impl Loader {
let mut compile_command = Command::new(&clang_exe);
compile_command.current_dir(src_path).args([
"--target=wasm32-unknown-wasi",
"-o",
output_path,
"-fPIC",