fix(loader): write Wasm lib directly to lib dir

Problem: `fs::rename` fails if the parser directory and the Tree-sitter
library directory are on different file systems.

Solution: Write the library file directly to the final directory.
This commit is contained in:
ObserverOfTime 2025-11-23 01:23:16 +02:00 committed by Christian Clason
parent dcef0cc0ee
commit 14b4708018

View file

@ -1306,11 +1306,10 @@ impl Loader {
) -> LoaderResult<()> {
let clang_executable = self.ensure_wasi_sdk_exists()?;
let output_name = "output.wasm";
let mut command = Command::new(&clang_executable);
command.current_dir(src_path).args([
"-o",
output_name,
output_path.to_str().unwrap(),
"-fPIC",
"-shared",
if self.debug_build { "-g" } else { "-Os" },
@ -1337,10 +1336,6 @@ impl Loader {
));
}
let current_path = src_path.join(output_name);
fs::rename(&current_path, output_path)
.map_err(|e| LoaderError::IO(IoError::new(e, Some(current_path.as_path()))))?;
Ok(())
}