diff --git a/lib/emscripten/src/exception.rs b/lib/emscripten/src/exception.rs index 9044aff2a..1f2b098d8 100644 --- a/lib/emscripten/src/exception.rs +++ b/lib/emscripten/src/exception.rs @@ -23,3 +23,8 @@ pub fn ___cxa_begin_catch(_ctx: &mut Ctx, _exception_object_ptr: u32) -> i32 { pub fn ___cxa_end_catch(_ctx: &mut Ctx) { debug!("emscripten::___cxa_end_catch"); } + +pub fn ___cxa_uncaught_exception(_ctx: &mut Ctx) -> i32 { + debug!("emscripten::___cxa_uncaught_exception"); + -1 +} diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 958202c7a..9a11e9e5a 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -607,6 +607,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "___cxa_throw" => func!(crate::exception::___cxa_throw), "___cxa_begin_catch" => func!(crate::exception::___cxa_begin_catch), "___cxa_end_catch" => func!(crate::exception::___cxa_end_catch), + "___cxa_uncaught_exception" => func!(crate::exception::___cxa_uncaught_exception), // Time "_gettimeofday" => func!(crate::time::_gettimeofday), @@ -619,6 +620,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_localtime" => func!(crate::time::_localtime), "_time" => func!(crate::time::_time), "_strftime" => func!(crate::time::_strftime), + "_strftime_l" => func!(crate::time::_strftime_l), "_localtime_r" => func!(crate::time::_localtime_r), "_gmtime_r" => func!(crate::time::_gmtime_r), "_mktime" => func!(crate::time::_mktime), diff --git a/lib/emscripten/src/time.rs b/lib/emscripten/src/time.rs index 28a60ec34..1f93f3894 100644 --- a/lib/emscripten/src/time.rs +++ b/lib/emscripten/src/time.rs @@ -310,3 +310,20 @@ pub fn _strftime( ); 0 } + +/// emscripten: _strftime_l +pub fn _strftime_l( + ctx: &mut Ctx, + s_ptr: c_int, + maxsize: u32, + format_ptr: c_int, + tm_ptr: c_int, + _last: c_int, +) -> i32 { + debug!( + "emscripten::_strftime_l {} {} {} {}", + s_ptr, maxsize, format_ptr, tm_ptr + ); + + _strftime(ctx, s_ptr, maxsize, format_ptr, tm_ptr) +} diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 6964d7ce1..345503558 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -17,6 +17,20 @@ use wasmer_runtime_core::{self, backend::CompilerConfig}; #[cfg(feature = "wasi")] use wasmer_wasi; +// stub module to make conditional compilation happy +#[cfg(not(feature = "wasi"))] +mod wasmer_wasi { + use wasmer_runtime_core::{import::ImportObject, module::Module}; + + pub fn is_wasi_module(_module: &Module) -> bool { + false + } + + pub fn generate_import_object(_args: Vec>, _envs: Vec>) -> ImportObject { + unimplemented!() + } +} + #[derive(Debug, StructOpt)] #[structopt(name = "wasmer", about = "Wasm execution runtime.")] /// The options for the wasmer Command Line Interface @@ -213,7 +227,6 @@ fn execute_wasm(options: &Run) -> Result<(), String> { }; // TODO: refactor this - #[cfg(not(feature = "wasi"))] let (abi, import_object, _em_globals) = if wasmer_emscripten::is_emscripten_module(&module) { let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module); ( @@ -222,34 +235,29 @@ fn execute_wasm(options: &Run) -> Result<(), String> { Some(emscripten_globals), // TODO Em Globals is here to extend, lifetime, find better solution ) } else { - ( - InstanceABI::None, - wasmer_runtime_core::import::ImportObject::new(), - None, - ) - }; - - #[cfg(feature = "wasi")] - let (abi, import_object) = if wasmer_wasi::is_wasi_module(&module) { - ( - InstanceABI::WASI, - wasmer_wasi::generate_import_object( - [options.path.to_str().unwrap().to_owned()] - .iter() - .chain(options.args.iter()) - .cloned() - .map(|arg| arg.into_bytes()) - .collect(), - env::vars() - .map(|(k, v)| format!("{}={}", k, v).into_bytes()) - .collect(), - ), - ) - } else { - ( - InstanceABI::None, - wasmer_runtime_core::import::ImportObject::new(), - ) + if cfg!(feature = "wasi") && wasmer_wasi::is_wasi_module(&module) { + ( + InstanceABI::WASI, + wasmer_wasi::generate_import_object( + [options.path.to_str().unwrap().to_owned()] + .iter() + .chain(options.args.iter()) + .cloned() + .map(|arg| arg.into_bytes()) + .collect(), + env::vars() + .map(|(k, v)| format!("{}={}", k, v).into_bytes()) + .collect(), + ), + None, + ) + } else { + ( + InstanceABI::None, + wasmer_runtime_core::import::ImportObject::new(), + None, + ) + } }; let mut instance = module