From 0f24120a6c13be753e037c8b7f475e476c9de5c6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 13 Oct 2022 18:21:29 +0300 Subject: fix(tvix/eval): fix Compiler::new on wasm This path normalisation business causes runtime panics on WebAssembly because those operations are unsupported. Maybe this shouldn't be happening in the compiler anyways, not sure, but for now this commit adds a workaround based on the target to disable the normalisation if we're compiling for wasm. Change-Id: I908a84fbdffc3401f8d443e2c73ec673e9f397ff Reviewed-on: https://cl.tvl.fyi/c/depot/+/7004 Autosubmit: tazjin Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/compiler/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index bf59027c8b4a..e3076246de33 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -112,7 +112,7 @@ impl<'observer> Compiler<'observer> { observer: &'observer mut dyn CompilerObserver, ) -> EvalResult { let mut root_dir = match location { - Some(dir) if dir.is_absolute() => Ok(dir), + Some(dir) if cfg!(target_arch = "wasm32") || dir.is_absolute() => Ok(dir), _ => { let current_dir = std::env::current_dir().map_err(|e| Error { kind: ErrorKind::PathResolution(format!( @@ -138,7 +138,9 @@ impl<'observer> Compiler<'observer> { let globals = globals.borrow(); + #[cfg(not(target_arch = "wasm32"))] debug_assert!(root_dir.is_absolute()); + Ok(Self { root_dir, file, -- cgit 1.4.1