about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-13T15·21+0300
committertazjin <tazjin@tvl.su>2022-10-13T16·29+0000
commit0f24120a6c13be753e037c8b7f475e476c9de5c6 (patch)
tree5ad5d43fd74b6bf53e3e7e6bbbeb78155a088939
parent78d3d9150b1eb76e0820a254c97976e10a8614d6 (diff)
fix(tvix/eval): fix Compiler::new on wasm r/5121
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 <tazjin@tvl.su>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
-rw-r--r--tvix/eval/src/compiler/mod.rs4
1 files changed, 3 insertions, 1 deletions
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<Self> {
         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,