From b8240493756ee309cf6a062e513105da3b15e991 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 00:35:02 -0800 Subject: [PATCH 01/40] Improved errors --- lib/vm/src/trap/traphandlers.rs | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index 452e6ed61d9..bc576926aff 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -16,6 +16,17 @@ use std::mem; use std::ptr; use std::sync::Once; +cfg_if::cfg_if! { + if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { + // In Apple Silicon, the page size is 16KiB + const PAGE_SIZE: usize = 16384; + } + else { + // Otherwise, page size is 4KiB + const PAGE_SIZE: usize = 4096; + } +} + extern "C" { fn RegisterSetjmp( jmp_buf: *mut *const u8, @@ -117,8 +128,8 @@ cfg_if::cfg_if! { let (stackaddr, stacksize) = thread_stack(); // The stack and its guard page covers the // range [stackaddr - guard pages .. stackaddr + stacksize). - // We assume the guard page is 1 page, and pages are 4KiB. - if stackaddr - 4096 <= addr && addr < stackaddr + stacksize { + // We assume the guard page is 1 page, and pages are 4KiB (or 16KiB in Apple Silicon) + if stackaddr - PAGE_SIZE <= addr && addr < stackaddr + stacksize { Some(TrapCode::StackOverflow) } else { Some(TrapCode::HeapAccessOutOfBounds) @@ -202,9 +213,16 @@ cfg_if::cfg_if! { } else if #[cfg(all(target_os = "linux", target_arch = "aarch64"))] { let cx = &*(cx as *const libc::ucontext_t); cx.uc_mcontext.pc as *const u8 - } else if #[cfg(target_os = "macos")] { + } else if #[cfg(all(target_os = "macos", target_arch = "x86_64"))] { let cx = &*(cx as *const libc::ucontext_t); (*cx.uc_mcontext).__ss.__rip as *const u8 + } else if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { + // println!("GET PC"); + let cx = &*(cx as *const libc::ucontext_t); + (*cx.uc_mcontext).__ss.__r15 as *const u8 // it holds the program counter - https://interrupt.memfault.com/blog/cortex-m-rtos-context-switching + // (*cx.uc_mcontext).__ss.__rip as *const u8 + // let cx = &*(cx as *const libc::ucontext_t); + // (*cx.uc_mcontext) as *const u8 } else { compile_error!("unsupported platform"); } @@ -602,6 +620,7 @@ impl CallThreadState { signal_trap: Option, call_handler: impl Fn(&SignalHandler) -> bool, ) -> *const u8 { + println!("HANDLING TRAP"); // If we hit a fault while handling a previous trap, that's quite bad, // so bail out and let the system handle this recursive segfault. // @@ -640,7 +659,9 @@ impl CallThreadState { self.handling_trap.set(false); return ptr::null(); } + println!("New unresolved 1"); let backtrace = Backtrace::new_unresolved(); + println!("New unresolved 2"); self.reset_guard_page.set(reset_guard_page); self.unwind.replace(UnwindReason::RuntimeTrap { backtrace, @@ -720,7 +741,7 @@ fn setup_unix_sigaltstack() -> Result<(), Trap> { /// The size of the sigaltstack (not including the guard, which will be /// added). Make this large enough to run our signal handlers. - const MIN_STACK_SIZE: usize = 16 * 4096; + const MIN_STACK_SIZE: usize = 16 * PAGE_SIZE; enum Tls { None, @@ -738,7 +759,7 @@ fn setup_unix_sigaltstack() -> Result<(), Trap> { // already checked _ => return Ok(()), } - + println!("TLS WITH"); // Check to see if the existing sigaltstack, if it exists, is big // enough. If so we don't need to allocate our own. let mut old_stack = mem::zeroed(); @@ -751,7 +772,7 @@ fn setup_unix_sigaltstack() -> Result<(), Trap> { // ... but failing that we need to allocate our own, so do all that // here. - let page_size: usize = libc::sysconf(libc::_SC_PAGESIZE).try_into().unwrap(); + let page_size: usize = dbg!(libc::sysconf(libc::_SC_PAGESIZE).try_into().unwrap()); let guard_size = page_size; let alloc_size = guard_size + MIN_STACK_SIZE; From 7d550ad1edb31151c6008518c0bb6f06876e139b Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 12:47:40 -0800 Subject: [PATCH 02/40] Wasm WAST tests are now working in Apple Silicon (ARM M1 chip) --- lib/vm/src/trap/traphandlers.rs | 39 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index bc576926aff..16107c385d0 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -16,17 +16,6 @@ use std::mem; use std::ptr; use std::sync::Once; -cfg_if::cfg_if! { - if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { - // In Apple Silicon, the page size is 16KiB - const PAGE_SIZE: usize = 16384; - } - else { - // Otherwise, page size is 4KiB - const PAGE_SIZE: usize = 4096; - } -} - extern "C" { fn RegisterSetjmp( jmp_buf: *mut *const u8, @@ -129,7 +118,7 @@ cfg_if::cfg_if! { // The stack and its guard page covers the // range [stackaddr - guard pages .. stackaddr + stacksize). // We assume the guard page is 1 page, and pages are 4KiB (or 16KiB in Apple Silicon) - if stackaddr - PAGE_SIZE <= addr && addr < stackaddr + stacksize { + if stackaddr - region::page::size() <= addr && addr < stackaddr + stacksize { Some(TrapCode::StackOverflow) } else { Some(TrapCode::HeapAccessOutOfBounds) @@ -217,12 +206,20 @@ cfg_if::cfg_if! { let cx = &*(cx as *const libc::ucontext_t); (*cx.uc_mcontext).__ss.__rip as *const u8 } else if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { - // println!("GET PC"); + // We need to submit this upfront in rust/libc + pub struct __darwin_arm_thread_state64 { + pub __x: [u64; 29], /* General purpose registers x0-x28 */ + pub __fp: u64, /* Frame pointer x29 */ + pub __lr: u64, /* Link register x30 */ + pub __sp: u64, /* Stack pointer x31 */ + pub __pc: u64, /* Program counter */ + pub __cpsr: u32, /* Current program status register */ + pub __pad: u32, /* Same size for 32-bit or 64-bit clients */ + }; + let cx = &*(cx as *const libc::ucontext_t); - (*cx.uc_mcontext).__ss.__r15 as *const u8 // it holds the program counter - https://interrupt.memfault.com/blog/cortex-m-rtos-context-switching - // (*cx.uc_mcontext).__ss.__rip as *const u8 - // let cx = &*(cx as *const libc::ucontext_t); - // (*cx.uc_mcontext) as *const u8 + let uc_mcontext = unsafe { std::mem::transmute::<_, *const __darwin_arm_thread_state64>(&(*cx.uc_mcontext).__ss) }; + (*uc_mcontext).__pc as *const u8 } else { compile_error!("unsupported platform"); } @@ -620,7 +617,6 @@ impl CallThreadState { signal_trap: Option, call_handler: impl Fn(&SignalHandler) -> bool, ) -> *const u8 { - println!("HANDLING TRAP"); // If we hit a fault while handling a previous trap, that's quite bad, // so bail out and let the system handle this recursive segfault. // @@ -659,9 +655,7 @@ impl CallThreadState { self.handling_trap.set(false); return ptr::null(); } - println!("New unresolved 1"); let backtrace = Backtrace::new_unresolved(); - println!("New unresolved 2"); self.reset_guard_page.set(reset_guard_page); self.unwind.replace(UnwindReason::RuntimeTrap { backtrace, @@ -741,7 +735,7 @@ fn setup_unix_sigaltstack() -> Result<(), Trap> { /// The size of the sigaltstack (not including the guard, which will be /// added). Make this large enough to run our signal handlers. - const MIN_STACK_SIZE: usize = 16 * PAGE_SIZE; + const MIN_STACK_SIZE: usize = 16 * 4096; enum Tls { None, @@ -759,7 +753,6 @@ fn setup_unix_sigaltstack() -> Result<(), Trap> { // already checked _ => return Ok(()), } - println!("TLS WITH"); // Check to see if the existing sigaltstack, if it exists, is big // enough. If so we don't need to allocate our own. let mut old_stack = mem::zeroed(); @@ -772,7 +765,7 @@ fn setup_unix_sigaltstack() -> Result<(), Trap> { // ... but failing that we need to allocate our own, so do all that // here. - let page_size: usize = dbg!(libc::sysconf(libc::_SC_PAGESIZE).try_into().unwrap()); + let page_size: usize = region::page::size(); let guard_size = page_size; let alloc_size = guard_size + MIN_STACK_SIZE; From c161f01393d4263c64227bcf5b6a7f690d875051 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 13:05:09 -0800 Subject: [PATCH 03/40] Added reference to rust/libc issue --- lib/vm/src/trap/traphandlers.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index 16107c385d0..9c45259e559 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -206,7 +206,8 @@ cfg_if::cfg_if! { let cx = &*(cx as *const libc::ucontext_t); (*cx.uc_mcontext).__ss.__rip as *const u8 } else if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { - // We need to submit this upfront in rust/libc + // This should be integrated into rust/libc + // Related issue: https://github.com/rust-lang/libc/issues/1977 pub struct __darwin_arm_thread_state64 { pub __x: [u64; 29], /* General purpose registers x0-x28 */ pub __fp: u64, /* Frame pointer x29 */ @@ -216,7 +217,7 @@ cfg_if::cfg_if! { pub __cpsr: u32, /* Current program status register */ pub __pad: u32, /* Same size for 32-bit or 64-bit clients */ }; - + let cx = &*(cx as *const libc::ucontext_t); let uc_mcontext = unsafe { std::mem::transmute::<_, *const __darwin_arm_thread_state64>(&(*cx.uc_mcontext).__ss) }; (*uc_mcontext).__pc as *const u8 From eba54b78efba87a5dacf89a058f6b81cfbe47309 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 18:31:44 -0800 Subject: [PATCH 04/40] Improved Native function tests --- tests/compilers/native_functions.rs | 108 ++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/compilers/native_functions.rs b/tests/compilers/native_functions.rs index 66b3fada8f1..0e570286c5e 100644 --- a/tests/compilers/native_functions.rs +++ b/tests/compilers/native_functions.rs @@ -6,6 +6,15 @@ use std::rc::Rc; use wasmer::*; + +fn long_f(a:u32, b:u32, c:u32, d:u32, e:u32, f:u16, g:u64, h:u64, i:u16, j:u32) -> u64 { + j as u64 + i as u64*10 + h*100 + g*1000 + f as u64 *10000 + e as u64 *100000 + d as u64 *1000000 + c as u64 *10000000 + b as u64 * 100000000 + a as u64 * 1000000000 +} + +fn long_f_dynamic(values: &[Value]) -> Result, RuntimeError> { + Ok(vec![Value::I64(values[9].unwrap_i32() as i64 + values[8].unwrap_i32() as i64*10 + values[7].unwrap_i64()*100 + values[6].unwrap_i64()*1000 + values[5].unwrap_i32() as i64 *10000 + values[4].unwrap_i32() as i64 *100000 + values[3].unwrap_i32() as i64 *1000000 + values[2].unwrap_i32() as i64 *10000000 + values[1].unwrap_i32() as i64 * 100000000 + values[0].unwrap_i32() as i64 * 1000000000)]) +} + #[test] fn native_function_works_for_wasm() -> Result<()> { let store = get_store(false); @@ -50,6 +59,93 @@ fn native_function_works_for_wasm() -> Result<()> { Ok(()) } + +// The native ABI for functions fails when defining a function natively in +// macos (Darwin) with the Apple Silicon ARM chip +// TODO: Cranelift should have a good ABI for the ABI +#[test] +#[cfg_attr( + any( + feature = "test-cranelift", + target_os = "macos", + target_arch = "aarch64", + ), + ignore +)] +fn native_function_works_for_wasm_function_manyparams() -> Result<()> { + let store = get_store(false); + let wat = r#"(module + (func $longf (import "env" "longf") (param i32 i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i64)) + (func (export "longf_pure") (param i32 i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i64) + (call $longf (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4) (local.get 5) (local.get 6) (local.get 7) (local.get 8) (local.get 9))) + (func (export "longf") (result i64) + (call $longf (i32.const 1) (i32.const 2) (i32.const 3) (i32.const 4) (i32.const 5) (i32.const 6) (i64.const 7) (i64.const 8) (i32.const 9) (i32.const 0))) +)"#; + let module = Module::new(&store, wat).unwrap(); + + let import_object = imports! { + "env" => { + "longf" => Function::new_native(&store, long_f), + }, + }; + + let instance = Instance::new(&module, &import_object)?; + + { + let dyn_f: &Function = instance.exports.get("longf")?; + let f: NativeFunc<(), i64> = dyn_f.native().unwrap(); + let result = f.call()?; + assert_eq!(result, 1234567890); + } + + { + let dyn_f: &Function = instance.exports.get("longf_pure")?; + let f: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), i64> = dyn_f.native().unwrap(); + let result = f.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)?; + assert_eq!(result, 1234567890); + } + + Ok(()) +} + + +#[test] +fn native_function_works_for_wasm_function_manyparams_dynamic() -> Result<()> { + let store = get_store(false); + let wat = r#"(module + (func $longf (import "env" "longf") (param i32 i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i64)) + (func (export "longf_pure") (param i32 i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i64) + (call $longf (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4) (local.get 5) (local.get 6) (local.get 7) (local.get 8) (local.get 9))) + (func (export "longf") (result i64) + (call $longf (i32.const 1) (i32.const 2) (i32.const 3) (i32.const 4) (i32.const 5) (i32.const 6) (i64.const 7) (i64.const 8) (i32.const 9) (i32.const 0))) +)"#; + let module = Module::new(&store, wat).unwrap(); + + let import_object = imports! { + "env" => { + "longf" => Function::new(&store, &FunctionType::new(vec![ValType::I32, ValType::I32, ValType::I32, ValType::I32, ValType::I32, ValType::I32, ValType::I64 , ValType::I64 ,ValType::I32, ValType::I32], vec![ValType::I64]), long_f_dynamic), + }, + }; + + let instance = Instance::new(&module, &import_object)?; + + { + let dyn_f: &Function = instance.exports.get("longf")?; + let f: NativeFunc<(), i64> = dyn_f.native().unwrap(); + let result = f.call()?; + assert_eq!(result, 1234567890); + } + + { + let dyn_f: &Function = instance.exports.get("longf_pure")?; + let f: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), i64> = dyn_f.native().unwrap(); + let result = f.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)?; + assert_eq!(result, 1234567890); + } + + Ok(()) +} + #[test] fn static_host_function_without_env() -> anyhow::Result<()> { let store = get_store(false); @@ -62,6 +158,10 @@ fn static_host_function_without_env() -> anyhow::Result<()> { Ok((d * 4.0, c * 3.0, b * 2, a * 1)) } + fn long_f(a:u32, b:u32, c:u32, d:u32, e:u32, f:u16, g:u64, h:u64, i:u16, j:u32) -> (u32, u64, u32) { + (a+b*10+c*100+d*1000+e*10000+f as u32*100000, g+h*10, i as u32+j*10) + } + // Native static host function that returns a tuple. { let f = Function::new_native(&store, f); @@ -70,6 +170,14 @@ fn static_host_function_without_env() -> anyhow::Result<()> { assert_eq!(result, (28.0, 15.0, 6, 1)); } + // Native static host function that returns a tuple. + { + let long_f = Function::new_native(&store, long_f); + let long_f_native: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), (u32, u64, u32)> = long_f.native().unwrap(); + let result = long_f_native.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)?; + assert_eq!(result, (654321, 87, 09)); + } + // Native static host function that returns a result of a tuple. { let f = Function::new_native(&store, f_ok); From b9f0d55f2e8a49e715ad207db0c7f2a917f09f81 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 18:33:04 -0800 Subject: [PATCH 05/40] Improved traphandlers --- lib/vm/src/trap/traphandlers.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index 9c45259e559..de6582cf4b6 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -206,8 +206,10 @@ cfg_if::cfg_if! { let cx = &*(cx as *const libc::ucontext_t); (*cx.uc_mcontext).__ss.__rip as *const u8 } else if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { - // This should be integrated into rust/libc + use std::mem; + // TODO: This should be integrated into rust/libc // Related issue: https://github.com/rust-lang/libc/issues/1977 + #[allow(non_camel_case_types)] pub struct __darwin_arm_thread_state64 { pub __x: [u64; 29], /* General purpose registers x0-x28 */ pub __fp: u64, /* Frame pointer x29 */ @@ -219,7 +221,7 @@ cfg_if::cfg_if! { }; let cx = &*(cx as *const libc::ucontext_t); - let uc_mcontext = unsafe { std::mem::transmute::<_, *const __darwin_arm_thread_state64>(&(*cx.uc_mcontext).__ss) }; + let uc_mcontext = mem::transmute::<_, *const __darwin_arm_thread_state64>(&(*cx.uc_mcontext).__ss); (*uc_mcontext).__pc as *const u8 } else { compile_error!("unsupported platform"); @@ -725,7 +727,6 @@ mod tls { #[cfg(unix)] fn setup_unix_sigaltstack() -> Result<(), Trap> { use std::cell::RefCell; - use std::convert::TryInto; use std::ptr::null_mut; thread_local! { From 517fac2c96477857330b201238af5ca95a4e23e3 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 18:35:36 -0800 Subject: [PATCH 06/40] Disallow Native Functions with more than 9 params in Apple Silicon --- lib/engine/src/resolver.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/engine/src/resolver.rs b/lib/engine/src/resolver.rs index 4c36dab3141..e0389e83bed 100644 --- a/lib/engine/src/resolver.rs +++ b/lib/engine/src/resolver.rs @@ -163,7 +163,17 @@ pub fn resolve_imports( // TODO: We should check that the f.vmctx actually matches // the shape of `VMDynamicFunctionImportContext` } - VMFunctionKind::Static => f.address, + VMFunctionKind::Static => { + // The native ABI for functions fails when defining a function natively in + // macos (Darwin) with the Apple Silicon ARM chip, for functions with more than 10 args + // TODO: Cranelift should have a good ABI for the ABI + if cfg!(all(target_os="macos", target_arch="aarch64")) { + let num_params = f.signature.params().len(); + assert!(num_params < 9, "Only native functions with less than 9 arguments are allowed in Apple Silicon (for now). Received {} in the import {}.{}", num_params, module_name, field); + } + + f.address + }, }; function_imports.push(VMFunctionImport { body: address, From 1f66798bed859e5335001d3ba948e4f0528042b1 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 19:25:57 -0800 Subject: [PATCH 07/40] All WASI tests now pass in Apple Silicon --- lib/cli/src/commands/compile.rs | 2 +- lib/engine/src/resolver.rs | 4 +- lib/wasi/src/lib.rs | 34 ++++++++++++++- lib/wasi/src/ptr.rs | 6 +++ lib/wasi/src/syscalls/mod.rs | 29 ++++++++++++- tests/compilers/native_functions.rs | 65 ++++++++++++++++++++++------- 6 files changed, 120 insertions(+), 20 deletions(-) diff --git a/lib/cli/src/commands/compile.rs b/lib/cli/src/commands/compile.rs index 2d4e0c4065a..7e85bce2e74 100644 --- a/lib/cli/src/commands/compile.rs +++ b/lib/cli/src/commands/compile.rs @@ -87,7 +87,7 @@ impl Compile { if ext != recommended_extension { warning!("the output file has a wrong extension. We recommend using `{}.{}` for the chosen target", &output_filename, &recommended_extension) } - }, + } None => { warning!("the output file has no extension. We recommend using `{}.{}` for the chosen target", &output_filename, &recommended_extension) } diff --git a/lib/engine/src/resolver.rs b/lib/engine/src/resolver.rs index e0389e83bed..be3e03e5849 100644 --- a/lib/engine/src/resolver.rs +++ b/lib/engine/src/resolver.rs @@ -167,13 +167,13 @@ pub fn resolve_imports( // The native ABI for functions fails when defining a function natively in // macos (Darwin) with the Apple Silicon ARM chip, for functions with more than 10 args // TODO: Cranelift should have a good ABI for the ABI - if cfg!(all(target_os="macos", target_arch="aarch64")) { + if cfg!(all(target_os = "macos", target_arch = "aarch64")) { let num_params = f.signature.params().len(); assert!(num_params < 9, "Only native functions with less than 9 arguments are allowed in Apple Silicon (for now). Received {} in the import {}.{}", num_params, module_name, field); } f.address - }, + } }; function_imports.push(VMFunctionImport { body: address, diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index cdca70e6ed3..389b0c5deea 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -30,6 +30,8 @@ pub use crate::utils::{get_wasi_version, is_wasi_module, WasiVersion}; use thiserror::Error; use wasmer::{imports, Function, ImportObject, Memory, Module, Store}; +#[cfg(all(target_os = "macos", target_arch = "aarch64",))] +use wasmer::{FunctionType, ValType}; use std::cell::UnsafeCell; use std::fmt; @@ -201,6 +203,34 @@ pub fn generate_import_object_from_env( } } +// Note: we use this wrapper because native functions with more than 9 params +// fail on Apple Silicon (with Cranelift). +fn get_path_open_for_store(store: &Store, env: WasiEnv) -> Function { + #[cfg(not(all(target_os = "macos", target_arch = "aarch64",)))] + let path_open = Function::new_native_with_env(store, env.clone(), path_open); + #[cfg(all(target_os = "macos", target_arch = "aarch64",))] + let path_open = Function::new_with_env( + store, + &FunctionType::new( + vec![ + ValType::I32, + ValType::I32, + ValType::I32, + ValType::I32, + ValType::I32, + ValType::I64, + ValType::I64, + ValType::I32, + ValType::I32, + ], + vec![ValType::I32], + ), + env.clone(), + path_open_dynamic, + ); + path_open +} + /// Combines a state generating function with the import list for legacy WASI fn generate_import_object_snapshot0(store: &Store, env: WasiEnv) -> ImportObject { imports! { @@ -236,7 +266,7 @@ fn generate_import_object_snapshot0(store: &Store, env: WasiEnv) -> ImportObject "path_filestat_get" => Function::new_native_with_env(store, env.clone(), legacy::snapshot0::path_filestat_get), "path_filestat_set_times" => Function::new_native_with_env(store, env.clone(), path_filestat_set_times), "path_link" => Function::new_native_with_env(store, env.clone(), path_link), - "path_open" => Function::new_native_with_env(store, env.clone(), path_open), + "path_open" => get_path_open_for_store(store, env.clone()), "path_readlink" => Function::new_native_with_env(store, env.clone(), path_readlink), "path_remove_directory" => Function::new_native_with_env(store, env.clone(), path_remove_directory), "path_rename" => Function::new_native_with_env(store, env.clone(), path_rename), @@ -289,7 +319,7 @@ fn generate_import_object_snapshot1(store: &Store, env: WasiEnv) -> ImportObject "path_filestat_get" => Function::new_native_with_env(store, env.clone(), path_filestat_get), "path_filestat_set_times" => Function::new_native_with_env(store, env.clone(), path_filestat_set_times), "path_link" => Function::new_native_with_env(store, env.clone(), path_link), - "path_open" => Function::new_native_with_env(store, env.clone(), path_open), + "path_open" => get_path_open_for_store(store, env.clone()), "path_readlink" => Function::new_native_with_env(store, env.clone(), path_readlink), "path_remove_directory" => Function::new_native_with_env(store, env.clone(), path_remove_directory), "path_rename" => Function::new_native_with_env(store, env.clone(), path_rename), diff --git a/lib/wasi/src/ptr.rs b/lib/wasi/src/ptr.rs index a4c76e3e39e..430c2b6ec38 100644 --- a/lib/wasi/src/ptr.rs +++ b/lib/wasi/src/ptr.rs @@ -24,6 +24,12 @@ impl fmt::Debug for WasmPtr { } } +impl From for WasmPtr { + fn from(offset: i32) -> Self { + Self::new(offset as _) + } +} + unsafe impl FromToNativeWasmType for WasmPtr { type Native = as FromToNativeWasmType>::Native; diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 23ecd7b58b4..516115319e6 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -28,7 +28,7 @@ use std::cell::Cell; use std::convert::{Infallible, TryInto}; use std::io::{self, Read, Seek, Write}; use tracing::{debug, trace}; -use wasmer::{Memory, RuntimeError}; +use wasmer::{Memory, RuntimeError, Value}; #[cfg(any( target_os = "freebsd", @@ -1884,6 +1884,33 @@ pub fn path_open( __WASI_ESUCCESS } +// Note: we define path_open_dynamic because native functions with more than 9 params +// fail on Apple Silicon (with Cranelift). +pub fn path_open_dynamic(env: &mut WasiEnv, params: &[Value]) -> Result, RuntimeError> { + let dirfd: __wasi_fd_t = params[0].unwrap_i32() as _; + let dirflags: __wasi_lookupflags_t = params[1].unwrap_i32() as _; + let path: WasmPtr = params[2].unwrap_i32().into(); + let path_len: u32 = params[3].unwrap_i32() as _; + let o_flags: __wasi_oflags_t = params[4].unwrap_i32() as _; + let fs_rights_base: __wasi_rights_t = params[5].unwrap_i64() as _; + let fs_rights_inheriting: __wasi_rights_t = params[6].unwrap_i64() as _; + let fs_flags: __wasi_fdflags_t = params[7].unwrap_i32() as _; + let fd: WasmPtr<__wasi_fd_t> = params[8].unwrap_i32().into(); + + Ok(vec![Value::I32(path_open( + env, + dirfd, + dirflags, + path, + path_len, + o_flags, + fs_rights_base, + fs_rights_inheriting, + fs_flags, + fd, + ) as i32)]) +} + /// ### `path_readlink()` /// Read the value of a symlink /// Inputs: diff --git a/tests/compilers/native_functions.rs b/tests/compilers/native_functions.rs index 0e570286c5e..795c9a7fc74 100644 --- a/tests/compilers/native_functions.rs +++ b/tests/compilers/native_functions.rs @@ -6,13 +6,32 @@ use std::rc::Rc; use wasmer::*; - -fn long_f(a:u32, b:u32, c:u32, d:u32, e:u32, f:u16, g:u64, h:u64, i:u16, j:u32) -> u64 { - j as u64 + i as u64*10 + h*100 + g*1000 + f as u64 *10000 + e as u64 *100000 + d as u64 *1000000 + c as u64 *10000000 + b as u64 * 100000000 + a as u64 * 1000000000 +fn long_f(a: u32, b: u32, c: u32, d: u32, e: u32, f: u16, g: u64, h: u64, i: u16, j: u32) -> u64 { + j as u64 + + i as u64 * 10 + + h * 100 + + g * 1000 + + f as u64 * 10000 + + e as u64 * 100000 + + d as u64 * 1000000 + + c as u64 * 10000000 + + b as u64 * 100000000 + + a as u64 * 1000000000 } fn long_f_dynamic(values: &[Value]) -> Result, RuntimeError> { - Ok(vec![Value::I64(values[9].unwrap_i32() as i64 + values[8].unwrap_i32() as i64*10 + values[7].unwrap_i64()*100 + values[6].unwrap_i64()*1000 + values[5].unwrap_i32() as i64 *10000 + values[4].unwrap_i32() as i64 *100000 + values[3].unwrap_i32() as i64 *1000000 + values[2].unwrap_i32() as i64 *10000000 + values[1].unwrap_i32() as i64 * 100000000 + values[0].unwrap_i32() as i64 * 1000000000)]) + Ok(vec![Value::I64( + values[9].unwrap_i32() as i64 + + values[8].unwrap_i32() as i64 * 10 + + values[7].unwrap_i64() * 100 + + values[6].unwrap_i64() * 1000 + + values[5].unwrap_i32() as i64 * 10000 + + values[4].unwrap_i32() as i64 * 100000 + + values[3].unwrap_i32() as i64 * 1000000 + + values[2].unwrap_i32() as i64 * 10000000 + + values[1].unwrap_i32() as i64 * 100000000 + + values[0].unwrap_i32() as i64 * 1000000000, + )]) } #[test] @@ -59,13 +78,12 @@ fn native_function_works_for_wasm() -> Result<()> { Ok(()) } - // The native ABI for functions fails when defining a function natively in // macos (Darwin) with the Apple Silicon ARM chip -// TODO: Cranelift should have a good ABI for the ABI +// TODO: Cranelift should have a good ABI for the ABI #[test] #[cfg_attr( - any( + all( feature = "test-cranelift", target_os = "macos", target_arch = "aarch64", @@ -100,7 +118,8 @@ fn native_function_works_for_wasm_function_manyparams() -> Result<()> { { let dyn_f: &Function = instance.exports.get("longf_pure")?; - let f: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), i64> = dyn_f.native().unwrap(); + let f: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), i64> = + dyn_f.native().unwrap(); let result = f.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)?; assert_eq!(result, 1234567890); } @@ -108,7 +127,6 @@ fn native_function_works_for_wasm_function_manyparams() -> Result<()> { Ok(()) } - #[test] fn native_function_works_for_wasm_function_manyparams_dynamic() -> Result<()> { let store = get_store(false); @@ -138,7 +156,8 @@ fn native_function_works_for_wasm_function_manyparams_dynamic() -> Result<()> { { let dyn_f: &Function = instance.exports.get("longf_pure")?; - let f: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), i64> = dyn_f.native().unwrap(); + let f: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), i64> = + dyn_f.native().unwrap(); let result = f.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)?; assert_eq!(result, 1234567890); } @@ -158,10 +177,25 @@ fn static_host_function_without_env() -> anyhow::Result<()> { Ok((d * 4.0, c * 3.0, b * 2, a * 1)) } - fn long_f(a:u32, b:u32, c:u32, d:u32, e:u32, f:u16, g:u64, h:u64, i:u16, j:u32) -> (u32, u64, u32) { - (a+b*10+c*100+d*1000+e*10000+f as u32*100000, g+h*10, i as u32+j*10) + fn long_f( + a: u32, + b: u32, + c: u32, + d: u32, + e: u32, + f: u16, + g: u64, + h: u64, + i: u16, + j: u32, + ) -> (u32, u64, u32) { + ( + a + b * 10 + c * 100 + d * 1000 + e * 10000 + f as u32 * 100000, + g + h * 10, + i as u32 + j * 10, + ) } - + // Native static host function that returns a tuple. { let f = Function::new_native(&store, f); @@ -173,7 +207,10 @@ fn static_host_function_without_env() -> anyhow::Result<()> { // Native static host function that returns a tuple. { let long_f = Function::new_native(&store, long_f); - let long_f_native: NativeFunc<(u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), (u32, u64, u32)> = long_f.native().unwrap(); + let long_f_native: NativeFunc< + (u32, u32, u32, u32, u32, u16, u64, u64, u16, u32), + (u32, u64, u32), + > = long_f.native().unwrap(); let result = long_f_native.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)?; assert_eq!(result, (654321, 87, 09)); } From f1d0840987bd4331d29984e4b8c92dc021c0df0c Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 20:29:12 -0800 Subject: [PATCH 08/40] Improved Makefile --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 3a564329ac3..724d5448675 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,10 @@ ifeq ($(ARCH), aarch64) endif endif +ifeq ($(ARCH), arm64) + test_compilers_engines += cranelift-jit +endif + compilers := $(filter-out ,$(compilers)) test_compilers_engines := $(filter-out ,$(test_compilers_engines)) From debd76babec15566315839038eb8ac6c190198f1 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 20:29:46 -0800 Subject: [PATCH 09/40] Updated Cargo.lock in runtime-core,runtime --- lib/deprecated/runtime-core/Cargo.lock | 145 ++++++++++++------------- lib/deprecated/runtime/Cargo.lock | 145 ++++++++++++------------- 2 files changed, 144 insertions(+), 146 deletions(-) diff --git a/lib/deprecated/runtime-core/Cargo.lock b/lib/deprecated/runtime-core/Cargo.lock index 8b2331c5743..d971b374ec1 100644 --- a/lib/deprecated/runtime-core/Cargo.lock +++ b/lib/deprecated/runtime-core/Cargo.lock @@ -120,6 +120,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -128,18 +134,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", "cranelift-bforest", @@ -149,7 +155,6 @@ dependencies = [ "gimli 0.21.0", "log", "regalloc", - "serde", "smallvec", "target-lexicon", "thiserror", @@ -157,9 +162,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -167,24 +172,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" +checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" [[package]] name = "cranelift-entity" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ "cranelift-codegen", "log", @@ -202,50 +207,49 @@ dependencies = [ ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ - "crossbeam-epoch", + "cfg-if 1.0.0", "crossbeam-utils", - "maybe-uninit", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "crossbeam-deque" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "crossbeam-epoch", "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.3" +name = "crossbeam-epoch" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", - "maybe-uninit", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" dependencies = [ "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "lazy_static", ] @@ -570,12 +574,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.3.3" @@ -637,19 +635,19 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" -dependencies = [ - "crc32fast", - "indexmap", -] +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" [[package]] name = "object" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] name = "once_cell" @@ -793,9 +791,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque", @@ -805,12 +803,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -824,9 +822,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.26" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", @@ -1011,9 +1009,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" [[package]] name = "tempfile" @@ -1115,7 +1113,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1137,7 +1135,7 @@ dependencies = [ [[package]] name = "wasmer-cache" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "blake3", "hex", @@ -1148,7 +1146,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "enumset", "raw-cpuid", @@ -1164,7 +1162,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1172,6 +1170,7 @@ dependencies = [ "more-asserts", "rayon", "serde", + "smallvec", "tracing", "wasmer-compiler", "wasmer-types", @@ -1180,7 +1179,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-llvm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "cc", @@ -1202,7 +1201,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "dynasm", @@ -1219,7 +1218,7 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "bincode", @@ -1237,7 +1236,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1253,7 +1252,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1272,9 +1271,9 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ - "object 0.19.0", + "object 0.21.1", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1300,7 +1299,7 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-entity", "serde", @@ -1308,7 +1307,7 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "cc", @@ -1326,9 +1325,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" diff --git a/lib/deprecated/runtime/Cargo.lock b/lib/deprecated/runtime/Cargo.lock index e4cfe71133e..a3584c5886e 100644 --- a/lib/deprecated/runtime/Cargo.lock +++ b/lib/deprecated/runtime/Cargo.lock @@ -120,6 +120,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -128,18 +134,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", "cranelift-bforest", @@ -149,7 +155,6 @@ dependencies = [ "gimli 0.21.0", "log", "regalloc", - "serde", "smallvec", "target-lexicon", "thiserror", @@ -157,9 +162,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -167,24 +172,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" +checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" [[package]] name = "cranelift-entity" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.65.0" +version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" dependencies = [ "cranelift-codegen", "log", @@ -202,50 +207,49 @@ dependencies = [ ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ - "crossbeam-epoch", + "cfg-if 1.0.0", "crossbeam-utils", - "maybe-uninit", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "crossbeam-deque" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "crossbeam-epoch", "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.3" +name = "crossbeam-epoch" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "crossbeam-utils", - "maybe-uninit", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" dependencies = [ "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "const_fn", "lazy_static", ] @@ -570,12 +574,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.3.3" @@ -637,19 +635,19 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" -dependencies = [ - "crc32fast", - "indexmap", -] +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" [[package]] name = "object" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] name = "once_cell" @@ -793,9 +791,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque", @@ -805,12 +803,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -824,9 +822,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.26" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", @@ -1011,9 +1009,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9" [[package]] name = "tempfile" @@ -1115,7 +1113,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasmer" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cfg-if 0.1.10", "indexmap", @@ -1137,7 +1135,7 @@ dependencies = [ [[package]] name = "wasmer-cache" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "blake3", "hex", @@ -1148,7 +1146,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "enumset", "raw-cpuid", @@ -1164,7 +1162,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -1172,6 +1170,7 @@ dependencies = [ "more-asserts", "rayon", "serde", + "smallvec", "tracing", "wasmer-compiler", "wasmer-types", @@ -1180,7 +1179,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-llvm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "cc", @@ -1202,7 +1201,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "byteorder", "dynasm", @@ -1219,7 +1218,7 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "bincode", @@ -1237,7 +1236,7 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1253,7 +1252,7 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -1272,9 +1271,9 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ - "object 0.19.0", + "object 0.21.1", "thiserror", "wasmer-compiler", "wasmer-types", @@ -1307,7 +1306,7 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "cranelift-entity", "serde", @@ -1315,7 +1314,7 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha4" +version = "1.0.0-alpha5" dependencies = [ "backtrace", "cc", @@ -1333,9 +1332,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" From 47c958dc4399554a8500dc2c864e9e32cea98edc Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 20:31:26 -0800 Subject: [PATCH 10/40] Improved Native support --- examples/engine_cross_compilation.rs | 6 +++++- lib/engine-native/src/artifact.rs | 17 ++++++++++++++--- lib/object/src/module.rs | 6 ++++++ tests/compilers/traps.rs | 3 ++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/examples/engine_cross_compilation.rs b/examples/engine_cross_compilation.rs index 272da2cfcee..7396bf0f9d1 100644 --- a/examples/engine_cross_compilation.rs +++ b/examples/engine_cross_compilation.rs @@ -99,7 +99,11 @@ fn main() -> Result<(), Box> { } #[test] -#[cfg(not(windows))] +#[cfg(not(any( + windows, + // We don't support yet crosscompilation in macOS with Apple Silicon + all(target_os = "macos", target_arch = "aarch64") +)))] fn test_cross_compilation() -> Result<(), Box> { main() } diff --git a/lib/engine-native/src/artifact.rs b/lib/engine-native/src/artifact.rs index 80971347441..277e702a53e 100644 --- a/lib/engine-native/src/artifact.rs +++ b/lib/engine-native/src/artifact.rs @@ -254,15 +254,26 @@ impl NativeArtifact { }; let is_cross_compiling = engine_inner.is_cross_compiling(); + let target_triple_str = { + let into_str = target_triple.to_string(); + // We have to adapt the target triple string, because otherwise + // Apple's clang will not recognize it. + if into_str == "aarch64-apple-darwin" { + "arm64-apple-darwin".to_string() + } else { + into_str + } + }; + let cross_compiling_args: Vec = if is_cross_compiling { vec![ - format!("--target={}", target_triple), + format!("--target={}", target_triple_str), "-fuse-ld=lld".to_string(), "-nodefaultlibs".to_string(), "-nostdlib".to_string(), ] } else { - vec![] + vec![format!("--target={}", target_triple_str)] }; let target_args = match (target_triple.operating_system, is_cross_compiling) { (OperatingSystem::Windows, true) => vec!["-Wl,/force:unresolved,/noentry"], @@ -271,7 +282,7 @@ impl NativeArtifact { }; trace!( "Compiling for target {} from host {}", - target_triple.to_string(), + target_triple_str, Triple::host().to_string(), ); diff --git a/lib/object/src/module.rs b/lib/object/src/module.rs index fa7c3c53f21..5b1f84391b3 100644 --- a/lib/object/src/module.rs +++ b/lib/object/src/module.rs @@ -209,6 +209,12 @@ pub fn emit_compilation( RelocationKind::PltRelative, RelocationEncoding::X86Branch, ), + // Object doesn't fully support it yet + // Architecture::Aarch64(_) => ( + // 32, + // RelocationKind::PltRelative, + // RelocationEncoding::Generic, + // ), architecture => { return Err(ObjectError::UnsupportedArchitecture( architecture.to_string(), diff --git a/tests/compilers/traps.rs b/tests/compilers/traps.rs index e84d98a9aea..1b7674abe37 100644 --- a/tests/compilers/traps.rs +++ b/tests/compilers/traps.rs @@ -421,7 +421,8 @@ fn mismatched_arguments() -> Result<()> { any( feature = "test-singlepass", feature = "test-llvm", - feature = "test-native" + feature = "test-native", + all(target_os = "macos", target_arch = "aarch64") ), ignore )] From 99737abec4bf5a80c85e6e34c9e51b7d86e72a40 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 21:12:41 -0800 Subject: [PATCH 11/40] Build wasmer release for Apple silicon --- .github/workflows/main.yaml | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ad894739228..4030abdc50c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -55,6 +55,11 @@ jobs: artifact_name: 'wasmer-macos-amd64' cross_compilation_artifact_name: 'cross_compiled_from_mac' run_integration_tests: true + - build: macos + os: macos-latest + rust: nightly + target: aarch64-apple-darwin + artifact_name: 'wasmer-macos-arm64' - build: windows os: windows-latest rust: 1.46.0 @@ -83,7 +88,12 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} override: true + - name: Setup Rust target + run: + echo "\n[build]\ntarget = \"aarch64-apple-darwin\"" >> .cargo/config.toml + if: matrix.target != 'aarch64-apple-darwin' # we just build - name: Configure cargo data directory # After this point, all cargo registry and crate data is stored in # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files @@ -131,7 +141,7 @@ jobs: # echo "LLVM_SYS_100_PREFIX=C:/llvm-10" >> $GITHUB_ENV # echo "LIBCLANG_PATH=C:/llvm-10/bin/libclang.dll" >> $GITHUB_ENV - name: Install LLVM (Unix) - if: matrix.os != 'windows-latest' + if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' run: | curl --proto '=https' --tlsv1.2 -sSf ${{ matrix.llvm_url }} -L -o llvm.tar.xz mkdir -p ${{ env.LLVM_DIR }} @@ -141,12 +151,19 @@ jobs: env: LLVM_DIR: ${{ github.workspace }}/llvm-10 - name: Set up dependencies for Mac OS - run: brew install automake + run: | + brew install automake if: matrix.os == 'macos-latest' - - run: make test - - name: Build and Test C API + - name: Test + run: | + make test + if: matrix.target != 'aarch64-apple-darwin' + - name: Test C API run: | make test-capi + if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' # we can't test yet on Apple Silicon or Windows + - name: Build C API + run: | make build-capi if: matrix.os != 'windows-latest' - name: Build C API on Windows @@ -313,7 +330,7 @@ jobs: asset_path: artifacts/wasmer-linux-amd64/wasmer-linux-amd64.tar.gz asset_name: wasmer-linux-amd64.tar.gz asset_content_type: application/gzip - - name: Upload Release Asset Mac + - name: Upload Release Asset Mac amd64 id: upload-release-asset-mac uses: actions/upload-release-asset@v1 env: @@ -323,6 +340,16 @@ jobs: asset_path: artifacts/wasmer-macos-amd64/wasmer-darwin-amd64.tar.gz asset_name: wasmer-darwin-amd64.tar.gz asset_content_type: application/gzip + - name: Upload Release Asset Mac arm64 + id: upload-release-asset-mac + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/wasmer-macos-amd64/wasmer-darwin-arm64.tar.gz + asset_name: wasmer-darwin-arm64.tar.gz + asset_content_type: application/gzip - name: Upload Release Asset Linux aarch64 id: upload-release-asset-linux-aarch64 uses: actions/upload-release-asset@v1 From a6492ed806e89cce27e4f35d891dbc74387fbe2b Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 21:30:19 -0800 Subject: [PATCH 12/40] Fixed Github Actions workflow --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4030abdc50c..ec238cfb726 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -331,7 +331,7 @@ jobs: asset_name: wasmer-linux-amd64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Mac amd64 - id: upload-release-asset-mac + id: upload-release-asset-mac-amd64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -341,7 +341,7 @@ jobs: asset_name: wasmer-darwin-amd64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Mac arm64 - id: upload-release-asset-mac + id: upload-release-asset-mac-arm64 uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 95314cf6453244446522c555c7113aac01797e5a Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 21:38:30 -0800 Subject: [PATCH 13/40] Fixing Github Actions workflow --- .github/workflows/main.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ec238cfb726..b8e80ff5f35 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,7 +38,7 @@ jobs: strategy: fail-fast: false matrix: - build: [linux, macos, windows, linux-aarch64] + build: [linux, macos, macos-arm64, windows, linux-aarch64] include: - build: linux os: ubuntu-18.04 @@ -55,7 +55,7 @@ jobs: artifact_name: 'wasmer-macos-amd64' cross_compilation_artifact_name: 'cross_compiled_from_mac' run_integration_tests: true - - build: macos + - build: macos-arm64 os: macos-latest rust: nightly target: aarch64-apple-darwin @@ -93,7 +93,7 @@ jobs: - name: Setup Rust target run: echo "\n[build]\ntarget = \"aarch64-apple-darwin\"" >> .cargo/config.toml - if: matrix.target != 'aarch64-apple-darwin' # we just build + if: matrix.target == 'aarch64-apple-darwin' # we just build - name: Configure cargo data directory # After this point, all cargo registry and crate data is stored in # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files From 8b956dcb8682ea694e0a4dfe03518e2699d6da21 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 21:42:41 -0800 Subject: [PATCH 14/40] Fix new line in GA --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b8e80ff5f35..2268bac2235 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -92,7 +92,7 @@ jobs: override: true - name: Setup Rust target run: - echo "\n[build]\ntarget = \"aarch64-apple-darwin\"" >> .cargo/config.toml + echo "[build]\\ntarget = \"aarch64-apple-darwin\"" >> .cargo/config.toml if: matrix.target == 'aarch64-apple-darwin' # we just build - name: Configure cargo data directory # After this point, all cargo registry and crate data is stored in From 735e4d7ef50cb11112459bbcca454e2f6c0cbe12 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 21:46:09 -0800 Subject: [PATCH 15/40] Fix Cargo workspace command new line --- .github/workflows/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2268bac2235..5f9b02a519f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -92,7 +92,8 @@ jobs: override: true - name: Setup Rust target run: - echo "[build]\\ntarget = \"aarch64-apple-darwin\"" >> .cargo/config.toml + echo "[build]" >> .cargo/config.toml + echo "target = \"aarch64-apple-darwin\"" >> .cargo/config.toml if: matrix.target == 'aarch64-apple-darwin' # we just build - name: Configure cargo data directory # After this point, all cargo registry and crate data is stored in From f60b6a212f324378f669f67ea09f3fcc132cb7fc Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 21:54:13 -0800 Subject: [PATCH 16/40] Improved cargo config --- .cargo/config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 5ae061b86c3..ab88af7613f 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,3 +2,4 @@ rustflags = [ "-C", "link-arg=-Wl,-E" ] + From 18abb4934730654c391edfc2e8f4eb06b1471477 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 22:00:19 -0800 Subject: [PATCH 17/40] Trying to fix toml format --- .cargo/config.toml | 1 - .github/workflows/main.yaml | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ab88af7613f..5ae061b86c3 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,4 +2,3 @@ rustflags = [ "-C", "link-arg=-Wl,-E" ] - diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 5f9b02a519f..4aa9a6f3ba6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -91,10 +91,12 @@ jobs: target: ${{ matrix.target }} override: true - name: Setup Rust target - run: - echo "[build]" >> .cargo/config.toml - echo "target = \"aarch64-apple-darwin\"" >> .cargo/config.toml - if: matrix.target == 'aarch64-apple-darwin' # we just build + run: | + cat << EOF > cargo/config.toml + [build] + target = "aarch64-apple-darwin" + EOF + if: matrix.target == 'aarch64-apple-darwin' - name: Configure cargo data directory # After this point, all cargo registry and crate data is stored in # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files From 25a3d739d177bd47e487913272782e01d6a75b6f Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 22:04:35 -0800 Subject: [PATCH 18/40] Fix cargo config location --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4aa9a6f3ba6..9102697d050 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -92,7 +92,7 @@ jobs: override: true - name: Setup Rust target run: | - cat << EOF > cargo/config.toml + cat << EOF > .cargo/config.toml [build] target = "aarch64-apple-darwin" EOF From dc6ef8d99608ff994e37025d020603a63fb9b0f9 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 22:11:24 -0800 Subject: [PATCH 19/40] Use macOS big sur for building for Apple Silicon --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9102697d050..a783e42deb7 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -56,7 +56,7 @@ jobs: cross_compilation_artifact_name: 'cross_compiled_from_mac' run_integration_tests: true - build: macos-arm64 - os: macos-latest + os: macos-11.0 rust: nightly target: aarch64-apple-darwin artifact_name: 'wasmer-macos-arm64' From 8587d365cba02cc13bc2a7f57ab70aea9942f138 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 22:22:34 -0800 Subject: [PATCH 20/40] Use system libffi --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 724d5448675..649945b86a2 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ build-docs-capi: cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,jit,object-file,native,cranelift,wasi # We use cranelift as the default backend for the capi for now -build-capi: build-capi-cranelift +build-capi: build-capi-cranelift-system-libffi build-capi-singlepass: cargo build --manifest-path lib/c-api/Cargo.toml --release \ From d79c71ff105199bef6c5dc3c16d5758ecf94fcac Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 22:34:08 -0800 Subject: [PATCH 21/40] Improved build --- .github/workflows/main.yaml | 8 ++++++-- Makefile | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a783e42deb7..f8c20a4299f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -155,7 +155,7 @@ jobs: LLVM_DIR: ${{ github.workspace }}/llvm-10 - name: Set up dependencies for Mac OS run: | - brew install automake + brew install automake libffi if: matrix.os == 'macos-latest' - name: Test run: | @@ -168,7 +168,11 @@ jobs: - name: Build C API run: | make build-capi - if: matrix.os != 'windows-latest' + if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' + - name: Build C API + run: | + make build-capi-cranelift-system-libffi + if: matrix.target == 'aarch64-apple-darwin' - name: Build C API on Windows run: make build-capi if: matrix.os == 'windows-latest' diff --git a/Makefile b/Makefile index 649945b86a2..724d5448675 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ build-docs-capi: cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,jit,object-file,native,cranelift,wasi # We use cranelift as the default backend for the capi for now -build-capi: build-capi-cranelift-system-libffi +build-capi: build-capi-cranelift build-capi-singlepass: cargo build --manifest-path lib/c-api/Cargo.toml --release \ From e7bee71ca783e77d02c4d8fdba3d12b3e3ea67f7 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 19 Nov 2020 22:39:50 -0800 Subject: [PATCH 22/40] Fix dependencies in macos --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f8c20a4299f..550a7179f01 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -156,7 +156,7 @@ jobs: - name: Set up dependencies for Mac OS run: | brew install automake libffi - if: matrix.os == 'macos-latest' + if: matrix.os == 'macos-latest' || matrix.os == 'macos-11.0' - name: Test run: | make test @@ -171,7 +171,7 @@ jobs: if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' - name: Build C API run: | - make build-capi-cranelift-system-libffi + make build-capi if: matrix.target == 'aarch64-apple-darwin' - name: Build C API on Windows run: make build-capi From 6cc18ef7caf754da493042e939d2f9956ab90dc6 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 07:59:15 -0800 Subject: [PATCH 23/40] Try using libffi system --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 550a7179f01..a802ce3c5f3 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -171,7 +171,7 @@ jobs: if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' - name: Build C API run: | - make build-capi + make build-capi-cranelift-system-libffi if: matrix.target == 'aarch64-apple-darwin' - name: Build C API on Windows run: make build-capi From 74e64b5889da6e5c8d984739f02a7f7a93c78bcd Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 08:10:50 -0800 Subject: [PATCH 24/40] Update libffi --- Cargo.lock | 160 ++++--------------------------------------- lib/c-api/Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 149 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e0b100d90a..4d54b510223 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,30 +129,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c85344eb535a31b62f0af37be84441ba9e7f0f4111eb0530f43d15e513fe57" -dependencies = [ - "bitflags", - "cexpr", - "cfg-if 0.1.10", - "clang-sys", - "clap", - "env_logger", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "which 3.1.1", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -247,15 +223,6 @@ version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" -[[package]] -name = "cexpr" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" -dependencies = [ - "nom 4.2.3", -] - [[package]] name = "cfg-if" version = "0.1.10" @@ -268,17 +235,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "clang-sys" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" -dependencies = [ - "glob", - "libc", - "libloading 0.5.2", -] - [[package]] name = "clap" version = "2.33.3" @@ -670,19 +626,6 @@ dependencies = [ "syn", ] -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "erased-serde" version = "0.3.12" @@ -746,7 +689,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -865,15 +808,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -1004,12 +938,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "leb128" version = "0.2.4" @@ -1024,9 +952,9 @@ checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] name = "libffi" -version = "0.9.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c18efe55925cc7f83bf60a61394696a734ae90e668d1f2bbd954354416fec6f2" +checksum = "bafef83ee22d51c27348aaf6b2da007a32b9f5004809d09271432e5ea2a795dd" dependencies = [ "abort_on_panic", "libc", @@ -1035,24 +963,12 @@ dependencies = [ [[package]] name = "libffi-sys" -version = "0.9.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f00e48ce437c5741a4da3b51738498343b5158c37bfa02bcb969efcc44e4e06" +checksum = "3b6d65142f1c3b06ca3f4216da4d32b3124d14d932cef8dfd8792037acd2160b" dependencies = [ - "bindgen", "cc", "make-cmd", - "pkg-config", -] - -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi", ] [[package]] @@ -1190,16 +1106,6 @@ dependencies = [ "void", ] -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -dependencies = [ - "memchr", - "version_check 0.1.5", -] - [[package]] name = "nom" version = "5.1.2" @@ -1207,7 +1113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ "memchr", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1350,12 +1256,6 @@ dependencies = [ "proc-macro-hack", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "pest" version = "2.1.3" @@ -1440,7 +1340,7 @@ dependencies = [ "proc-macro2", "quote", "syn", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1451,7 +1351,7 @@ checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", "quote", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1469,12 +1369,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.7" @@ -1934,12 +1828,6 @@ dependencies = [ "serde", ] -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" - [[package]] name = "smallvec" version = "1.4.2" @@ -2025,15 +1913,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" -dependencies = [ - "winapi-util", -] - [[package]] name = "test-generator" version = "0.1.0" @@ -2209,12 +2088,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.2" @@ -2553,7 +2426,7 @@ dependencies = [ "bincode", "cfg-if 0.1.10", "leb128", - "libloading 0.6.5", + "libloading", "serde", "tempfile", "tracing", @@ -2562,7 +2435,7 @@ dependencies = [ "wasmer-object", "wasmer-types", "wasmer-vm", - "which 4.0.2", + "which", ] [[package]] @@ -2572,7 +2445,7 @@ dependencies = [ "bincode", "cfg-if 0.1.10", "leb128", - "libloading 0.6.5", + "libloading", "serde", "tempfile", "tracing", @@ -2814,15 +2687,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "which" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" -dependencies = [ - "libc", -] - [[package]] name = "which" version = "4.0.2" @@ -2882,7 +2746,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3a481cfdefd35e1c50073ae33a8000d695c98039544659f5dc5dd71311b0d01" dependencies = [ - "nom 5.1.2", + "nom", ] [[package]] diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index b3d904c8c26..b355db4495a 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -30,7 +30,7 @@ wasmer-types = { version = "1.0.0-alpha5", path = "../wasmer-types" } cfg-if = "1.0" lazy_static = "1" libc = { version = "^0.2", default-features = false } -libffi = { version = "0.9", optional = true } +libffi = { version = "1.0", optional = true } serde = { version = "1", optional = true, features = ["derive"] } thiserror = "1" typetag = { version = "0.1", optional = true } From 85701c362e131a33272199f9c84a49ba5d45989d Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 08:34:19 -0800 Subject: [PATCH 25/40] Testing build for a given target and package --- .github/workflows/main.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a802ce3c5f3..a4dd365485a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -155,7 +155,7 @@ jobs: LLVM_DIR: ${{ github.workspace }}/llvm-10 - name: Set up dependencies for Mac OS run: | - brew install automake libffi + brew install automake if: matrix.os == 'macos-latest' || matrix.os == 'macos-11.0' - name: Test run: | @@ -182,14 +182,23 @@ jobs: - name: Build Wapm binary run: | make build-wapm - if: needs.setup.outputs.DOING_RELEASE == '1' + # if: needs.setup.outputs.DOING_RELEASE == '1' + - name: Copy target binaries for packaging + run: | + mkdir -p target/release + cp target/${{matrix.target}}/release/wasmer* target/release + cp target/${{matrix.target}}/release/libwasmer* target/release + mkdir -p wapm/target/release + cp wapm/target/${{matrix.target}}/release/wapm* wapm/target/release + if: matrix.target + # if: needs.setup.outputs.DOING_RELEASE == '1' - name: Package Wasmer for integration tests run: make package-without-wapm-for-integration-tests if: needs.setup.outputs.DOING_RELEASE != '1' - name: Package Wasmer run: | make package - if: needs.setup.outputs.DOING_RELEASE == '1' + # if: needs.setup.outputs.DOING_RELEASE == '1' - name: Run integration tests (Windows) shell: cmd run: | From d161d4a8747e2886ee2e35c0eb118963654de24b Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 08:35:46 -0800 Subject: [PATCH 26/40] Fixed engine native in non Apple Silicon --- lib/engine-native/src/artifact.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/engine-native/src/artifact.rs b/lib/engine-native/src/artifact.rs index 277e702a53e..fef24463bd6 100644 --- a/lib/engine-native/src/artifact.rs +++ b/lib/engine-native/src/artifact.rs @@ -273,7 +273,14 @@ impl NativeArtifact { "-nostdlib".to_string(), ] } else { - vec![format!("--target={}", target_triple_str)] + // We are explicit on the target when the host system is + // Apple Silicon, otherwise compilation fails. + if target_triple_str == "arm64-apple-darwin" { + vec![format!("--target={}", target_triple_str)] + } + else { + vec![] + } }; let target_args = match (target_triple.operating_system, is_cross_compiling) { (OperatingSystem::Windows, true) => vec!["-Wl,/force:unresolved,/noentry"], From da0d29f00b66d8c8db9eb5a28f96bf94577fa7ab Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 08:37:45 -0800 Subject: [PATCH 27/40] Fixed linting --- lib/engine-native/src/artifact.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/engine-native/src/artifact.rs b/lib/engine-native/src/artifact.rs index fef24463bd6..3ddb0f93ebf 100644 --- a/lib/engine-native/src/artifact.rs +++ b/lib/engine-native/src/artifact.rs @@ -277,8 +277,7 @@ impl NativeArtifact { // Apple Silicon, otherwise compilation fails. if target_triple_str == "arm64-apple-darwin" { vec![format!("--target={}", target_triple_str)] - } - else { + } else { vec![] } }; From a52c3c59c7e800559e24547463a58ccc553c7cf2 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 21:12:36 -0800 Subject: [PATCH 28/40] Updated wapm build --- .github/workflows/main.yaml | 4 ++-- Makefile | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a4dd365485a..f18dfe721ed 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -188,8 +188,8 @@ jobs: mkdir -p target/release cp target/${{matrix.target}}/release/wasmer* target/release cp target/${{matrix.target}}/release/libwasmer* target/release - mkdir -p wapm/target/release - cp wapm/target/${{matrix.target}}/release/wapm* wapm/target/release + mkdir -p wapm-cli/target/release + cp wapm-cli/target/${{matrix.target}}/release/wapm* wapm-cli/target/release if: matrix.target # if: needs.setup.outputs.DOING_RELEASE == '1' - name: Package Wasmer for integration tests diff --git a/Makefile b/Makefile index 724d5448675..3559c739aec 100644 --- a/Makefile +++ b/Makefile @@ -86,10 +86,17 @@ build-wasmer: build-wasmer-debug: cargo build --manifest-path lib/cli/Cargo.toml $(compiler_features) -WAPM_VERSION = v0.5.0 -build-wapm: - git clone --branch $(WAPM_VERSION) https://github.com/wasmerio/wapm-cli.git +WAPM_VERSION = master # v0.5.0 +get-wapm: + [ -d "wapm-cli" ] || git clone --branch $(WAPM_VERSION) https://github.com/wasmerio/wapm-cli.git + +build-wapm: get-wapm +ifeq ($(UNAME_S), Darwin) + # We build it without bundling sqlite, as is included by default in macos + cargo build --release --manifest-path wapm-cli/Cargo.toml --no-default-features --features "packagesigning telemetry update-notifications" +else cargo build --release --manifest-path wapm-cli/Cargo.toml --features "telemetry update-notifications" +endif build-docs: cargo doc --release $(compiler_features) --document-private-items --no-deps --workspace From af4993cea624d8a72cf65c75e5d49038f9523ee2 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 21:23:05 -0800 Subject: [PATCH 29/40] Updated Cranelift to latest version --- lib/compiler-cranelift/Cargo.toml | 6 +++--- lib/compiler-cranelift/src/translator/unwind.rs | 2 +- lib/wasmer-types/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/compiler-cranelift/Cargo.toml b/lib/compiler-cranelift/Cargo.toml index a32658c9193..3b4ccf7de61 100644 --- a/lib/compiler-cranelift/Cargo.toml +++ b/lib/compiler-cranelift/Cargo.toml @@ -15,14 +15,14 @@ edition = "2018" wasmer-compiler = { path = "../compiler", version = "1.0.0-alpha5", features = ["translator"], default-features = false } wasmer-vm = { path = "../vm", version = "1.0.0-alpha5" } wasmer-types = { path = "../wasmer-types", version = "1.0.0-alpha5", default-features = false, features = ["std"] } -cranelift-codegen = { version = "0.67", default-features = false, features = ["x86", "arm64"] } -cranelift-frontend = { version = "0.67", default-features = false } +cranelift-codegen = { version = "0.68", default-features = false, features = ["x86", "arm64"] } +cranelift-frontend = { version = "0.68", default-features = false } tracing = "0.1" hashbrown = { version = "0.9", optional = true } rayon = "1.5" serde = { version = "1.0", features = ["derive"] } more-asserts = "0.2" -gimli = { version = "0.21", optional = true } +gimli = { version = "0.22", optional = true } smallvec = "1.0.0" [dev-dependencies] diff --git a/lib/compiler-cranelift/src/translator/unwind.rs b/lib/compiler-cranelift/src/translator/unwind.rs index 50b61b0e9af..052ea85923e 100644 --- a/lib/compiler-cranelift/src/translator/unwind.rs +++ b/lib/compiler-cranelift/src/translator/unwind.rs @@ -49,6 +49,6 @@ pub(crate) fn compiled_function_unwind_info( Ok(CraneliftUnwindInfo::WindowsX64(data)) } Some(UnwindInfo::SystemV(unwind)) => Ok(CraneliftUnwindInfo::FDE(unwind)), - None => Ok(CraneliftUnwindInfo::None), + Some(_) | None => Ok(CraneliftUnwindInfo::None), } } diff --git a/lib/wasmer-types/Cargo.toml b/lib/wasmer-types/Cargo.toml index 2f0c2008e88..6e6e2a72d70 100644 --- a/lib/wasmer-types/Cargo.toml +++ b/lib/wasmer-types/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" [dependencies] # We use `cranelift-entity` here because it's a lightweight dependency and it contains # some useful data structures -cranelift-entity = "0.67" +cranelift-entity = "0.68" serde = { version = "1.0", features = ["derive"], optional = true, default-features = false } [features] From e027370eb2c131823570faf8bbb3383aa0c88783 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 21:23:43 -0800 Subject: [PATCH 30/40] Fixed syntax error --- lib/wasi/src/syscalls/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index b0a2b862255..d174af20caf 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -1886,7 +1886,7 @@ pub fn path_open( // Note: we define path_open_dynamic because native functions with more than 9 params // fail on Apple Silicon (with Cranelift). -pub fn path_open_dynamic(env: &mut WasiEnv, params: &[Value]) -> Result, RuntimeError> { +pub fn path_open_dynamic(env: &WasiEnv, params: &[Value]) -> Result, RuntimeError> { let dirfd: __wasi_fd_t = params[0].unwrap_i32() as _; let dirflags: __wasi_lookupflags_t = params[1].unwrap_i32() as _; let path: WasmPtr = params[2].unwrap_i32().into(); From 0daa0e4a3ab4f76d428726d485e01c6a839a13f3 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 21:55:10 -0800 Subject: [PATCH 31/40] Updated workflow --- .github/workflows/main.yaml | 6 +- Cargo.lock | 102 +++++++++++++++++++++---- lib/deprecated/runtime-core/Cargo.lock | 44 +++++------ lib/deprecated/runtime/Cargo.lock | 44 +++++------ 4 files changed, 130 insertions(+), 66 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ffac4191d3f..fb68bad1f0f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -199,6 +199,10 @@ jobs: run: | make package # if: needs.setup.outputs.DOING_RELEASE == '1' + - name: Package Wasmer (${{ matrix.target }}) + run: | + mv ./dist/$(shell ./scripts/binary-name.sh) ./dist/{{ matrix.artifact_name }}.tar.gz + if: matrix.target && matrix.os != 'windows-latest' - name: Run integration tests (Windows) shell: cmd run: | @@ -253,7 +257,7 @@ jobs: path: cross - name: Upload Artifacts uses: actions/upload-artifact@v2 - if: needs.setup.outputs.DOING_RELEASE == '1' + # if: needs.setup.outputs.DOING_RELEASE == '1' with: name: ${{ matrix.artifact_name }} path: dist diff --git a/Cargo.lock b/Cargo.lock index 4d54b510223..4bed42bb8db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,7 +308,16 @@ version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" dependencies = [ - "cranelift-entity", + "cranelift-entity 0.67.0", +] + +[[package]] +name = "cranelift-bforest" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" +dependencies = [ + "cranelift-entity 0.68.0", ] [[package]] @@ -318,28 +327,58 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" dependencies = [ "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-bforest 0.67.0", + "cranelift-codegen-meta 0.67.0", + "cranelift-codegen-shared 0.67.0", + "cranelift-entity 0.67.0", "gimli 0.21.0", "hashbrown 0.7.2", "log", - "regalloc", + "regalloc 0.0.30", "serde", "smallvec", "target-lexicon", "thiserror", ] +[[package]] +name = "cranelift-codegen" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" +dependencies = [ + "byteorder", + "cranelift-bforest 0.68.0", + "cranelift-codegen-meta 0.68.0", + "cranelift-codegen-shared 0.68.0", + "cranelift-entity 0.68.0", + "gimli 0.22.0", + "hashbrown 0.9.1", + "log", + "regalloc 0.0.31", + "smallvec", + "target-lexicon", + "thiserror", +] + [[package]] name = "cranelift-codegen-meta" version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-codegen-shared 0.67.0", + "cranelift-entity 0.67.0", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" +dependencies = [ + "cranelift-codegen-shared 0.68.0", + "cranelift-entity 0.68.0", ] [[package]] @@ -348,23 +387,35 @@ version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" +[[package]] +name = "cranelift-codegen-shared" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" + [[package]] name = "cranelift-entity" version = "0.67.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" + +[[package]] +name = "cranelift-entity" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ - "cranelift-codegen", - "hashbrown 0.7.2", + "cranelift-codegen 0.68.0", + "hashbrown 0.9.1", "log", "smallvec", "target-lexicon", @@ -730,6 +781,15 @@ name = "gimli" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +dependencies = [ + "indexmap", +] + +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -1602,6 +1662,17 @@ dependencies = [ "smallvec", ] +[[package]] +name = "regalloc" +version = "0.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +dependencies = [ + "log", + "rustc-hash", + "smallvec", +] + [[package]] name = "regex" version = "1.4.2" @@ -2303,9 +2374,10 @@ dependencies = [ name = "wasmer-compiler-cranelift" version = "1.0.0-alpha5" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.67.0", + "cranelift-codegen 0.68.0", "cranelift-frontend", - "gimli 0.21.0", + "gimli 0.22.0", "hashbrown 0.9.1", "lazy_static", "more-asserts", @@ -2478,7 +2550,7 @@ dependencies = [ name = "wasmer-types" version = "1.0.0-alpha5" dependencies = [ - "cranelift-entity", + "cranelift-entity 0.68.0", "serde", ] diff --git a/lib/deprecated/runtime-core/Cargo.lock b/lib/deprecated/runtime-core/Cargo.lock index d971b374ec1..c686070e50c 100644 --- a/lib/deprecated/runtime-core/Cargo.lock +++ b/lib/deprecated/runtime-core/Cargo.lock @@ -6,7 +6,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" dependencies = [ - "gimli 0.22.0", + "gimli", ] [[package]] @@ -134,25 +134,25 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.21.0", + "gimli", "log", "regalloc", "smallvec", @@ -162,9 +162,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -172,24 +172,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -396,21 +396,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" - [[package]] name = "goblin" version = "0.2.3" @@ -822,9 +816,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.30" +version = "0.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", @@ -1166,7 +1160,7 @@ version = "1.0.0-alpha5" dependencies = [ "cranelift-codegen", "cranelift-frontend", - "gimli 0.21.0", + "gimli", "more-asserts", "rayon", "serde", diff --git a/lib/deprecated/runtime/Cargo.lock b/lib/deprecated/runtime/Cargo.lock index a3584c5886e..b7baa2a4ba9 100644 --- a/lib/deprecated/runtime/Cargo.lock +++ b/lib/deprecated/runtime/Cargo.lock @@ -6,7 +6,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" dependencies = [ - "gimli 0.22.0", + "gimli", ] [[package]] @@ -134,25 +134,25 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cranelift-bforest" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", - "gimli 0.21.0", + "gimli", "log", "regalloc", "smallvec", @@ -162,9 +162,9 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -172,24 +172,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ "cranelift-codegen", "log", @@ -396,21 +396,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" - [[package]] name = "goblin" version = "0.2.3" @@ -822,9 +816,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "regalloc" -version = "0.0.30" +version = "0.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", @@ -1166,7 +1160,7 @@ version = "1.0.0-alpha5" dependencies = [ "cranelift-codegen", "cranelift-frontend", - "gimli 0.21.0", + "gimli", "more-asserts", "rayon", "serde", From 8981b25e10c66ebc92f54d23e3adb95e3dfc2c9c Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 21:56:47 -0800 Subject: [PATCH 32/40] Added changes into CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7996cd9356..2819a3b6781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Added +- [#1831](https://github.com/wasmerio/wasmer/pull/1831) Added support for Apple Silicon chips (`arm64-apple-darwin`) - [#1649](https://github.com/wasmerio/wasmer/pull/1649) Add outline of migration to 1.0.0 docs. ### Changed From cf142635a20d2396638f2d68ab044b877fce4b58 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 22:09:25 -0800 Subject: [PATCH 33/40] Add version to caching --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fb68bad1f0f..dc725d630fb 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -115,9 +115,9 @@ jobs: target/*/.* target/*/build target/*/deps - key: ${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }} + key: v1-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }} restore-keys: | - ${{ matrix.os }}-${{ matrix.rust }}- + v1-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }} # # Install sccache # - uses: actions/cache@master # with: From 812e6f2f68d8068fbfe0d97210e5d485493fca0b Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 22:29:51 -0800 Subject: [PATCH 34/40] Improved release script --- .github/workflows/main.yaml | 14 +++++------- Makefile | 4 ++-- scripts/binary-name.sh | 45 ------------------------------------- 3 files changed, 7 insertions(+), 56 deletions(-) delete mode 100755 scripts/binary-name.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index dc725d630fb..29069d2b4de 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -199,10 +199,6 @@ jobs: run: | make package # if: needs.setup.outputs.DOING_RELEASE == '1' - - name: Package Wasmer (${{ matrix.target }}) - run: | - mv ./dist/$(shell ./scripts/binary-name.sh) ./dist/{{ matrix.artifact_name }}.tar.gz - if: matrix.target && matrix.os != 'windows-latest' - name: Run integration tests (Windows) shell: cmd run: | @@ -337,7 +333,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: artifacts/wasmer-windows-amd64/wasmer-windows.exe + asset_path: artifacts/wasmer-windows-amd64/WasmerInstaller.exe asset_name: wasmer-windows.exe asset_content_type: application/vnd.microsoft.portable-executable - name: Upload Release Asset Linux amd64 @@ -347,7 +343,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: artifacts/wasmer-linux-amd64/wasmer-linux-amd64.tar.gz + asset_path: artifacts/wasmer-linux-amd64/wasmer.tar.gz asset_name: wasmer-linux-amd64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Mac amd64 @@ -357,7 +353,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: artifacts/wasmer-macos-amd64/wasmer-darwin-amd64.tar.gz + asset_path: artifacts/wasmer-macos-amd64/wasmer.tar.gz asset_name: wasmer-darwin-amd64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Mac arm64 @@ -367,7 +363,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: artifacts/wasmer-macos-amd64/wasmer-darwin-arm64.tar.gz + asset_path: artifacts/wasmer-macos-amd64/wasmer.tar.gz asset_name: wasmer-darwin-arm64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Linux aarch64 @@ -377,7 +373,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: artifacts/wasmer-linux-aarch64/wasmer-linux-aarch64.tar.gz + asset_path: artifacts/wasmer-linux-aarch64/wasmer.tar.gz asset_name: wasmer-linux-aarch64.tar.gz asset_content_type: application/gzip diff --git a/Makefile b/Makefile index 3559c739aec..f955eafb9e2 100644 --- a/Makefile +++ b/Makefile @@ -323,12 +323,12 @@ package: package-wapm package-wasmer package-capi mkdir -p dist ifeq ($(OS), Windows_NT) iscc scripts/windows-installer/wasmer.iss - cp scripts/windows-installer/WasmerInstaller.exe dist/wasmer-windows.exe + cp scripts/windows-installer/WasmerInstaller.exe dist/ else cp LICENSE package/LICENSE cp ATTRIBUTIONS.md package/ATTRIBUTIONS tar -C package -zcvf wasmer.tar.gz bin lib include LICENSE ATTRIBUTIONS - cp ./wasmer.tar.gz ./dist/$(shell ./scripts/binary-name.sh) + mv wasmer.tar.gz dist/ endif # command for simulating installing Wasmer without wapm. diff --git a/scripts/binary-name.sh b/scripts/binary-name.sh deleted file mode 100755 index af7f63c470b..00000000000 --- a/scripts/binary-name.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -initArch() { - ARCH=$(uname -m) - if [ -n "$WASMER_ARCH" ]; then - ARCH="$WASMER_ARCH" - fi - # If you modify this list, please also modify install.sh - case $ARCH in - amd64|x86_64) ARCH="amd64";; - aarch64) ARCH="aarch64";; - # i386) ARCH="386";; - *) echo "Architecture ${ARCH} is not supported by this installation script"; exit 1;; - esac -} - -initOS() { - OS=$(uname | tr '[:upper:]' '[:lower:]') - if [ -n "$WASMER_OS" ]; then - echo "Using WASMER_OS (${WASMER_OS})" - OS="$WASMER_OS" - fi - case "$OS" in - darwin) OS='darwin';; - linux) OS='linux';; - freebsd) OS='freebsd';; - # mingw*) OS='windows';; - # msys*) OS='windows';; - *) echo "OS ${OS} is not supported by this installation script"; exit 1;; - esac -} - -# identify platform based on uname output -initArch -initOS - -# determine install directory if required -BINARY="wasmer-${OS}-${ARCH}.tar.gz" - -# add .exe if on windows -# if [ "$OS" = "windows" ]; then -# BINARY="$BINARY.exe" -# fi - -echo "${BINARY}" From 79232251a020184def2ee216d528aca2d6bbbb6c Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 22:56:28 -0800 Subject: [PATCH 35/40] Improved build script --- .github/workflows/main.yaml | 18 +++++++----------- Makefile | 17 ++++++++--------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 29069d2b4de..c1b8853fd0f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -183,22 +183,19 @@ jobs: run: | make build-wapm # if: needs.setup.outputs.DOING_RELEASE == '1' - - name: Copy target binaries for packaging + - name: Copy target binaries run: | mkdir -p target/release cp target/${{matrix.target}}/release/wasmer* target/release cp target/${{matrix.target}}/release/libwasmer* target/release - mkdir -p wapm-cli/target/release - cp wapm-cli/target/${{matrix.target}}/release/wapm* wapm-cli/target/release + if [ -d "wapm-cli" ]; then + mkdir -p wapm-cli/target/release + wapm-cli/target/${{matrix.target}}/release/wapm* wapm-cli/target/release + fi if: matrix.target - # if: needs.setup.outputs.DOING_RELEASE == '1' - - name: Package Wasmer for integration tests - run: make package-without-wapm-for-integration-tests - if: needs.setup.outputs.DOING_RELEASE != '1' - - name: Package Wasmer + - name: Dist run: | - make package - # if: needs.setup.outputs.DOING_RELEASE == '1' + make distribution - name: Run integration tests (Windows) shell: cmd run: | @@ -253,7 +250,6 @@ jobs: path: cross - name: Upload Artifacts uses: actions/upload-artifact@v2 - # if: needs.setup.outputs.DOING_RELEASE == '1' with: name: ${{ matrix.artifact_name }} path: dist diff --git a/Makefile b/Makefile index f955eafb9e2..a138e0bda7d 100644 --- a/Makefile +++ b/Makefile @@ -268,13 +268,13 @@ test-integration: ############# package-wapm: +ifneq ($(OS), Windows_NT) mkdir -p "package/bin" - cp ./wapm-cli/target/release/wapm package/bin/ -ifeq ($(OS), Windows_NT) - echo "" -else - echo "#!/bin/bash\nwapm execute \"\$$@\"" > package/bin/wax - chmod +x package/bin/wax + if [ -d "wapm-cli" ]; then \ + cp wapm-cli/target/release/wapm package/bin/; \ + echo "#!/bin/bash\nwapm execute \"\$$@\"" > package/bin/wax; \ + chmod +x package/bin/wax; \ + fi endif package-wasmer: @@ -318,6 +318,8 @@ package-docs: build-docs build-docs-capi echo '' > package/docs/crates/index.html package: package-wapm package-wasmer package-capi + +distribution: package cp LICENSE package/LICENSE cp ATTRIBUTIONS.md package/ATTRIBUTIONS mkdir -p dist @@ -331,9 +333,6 @@ else mv wasmer.tar.gz dist/ endif -# command for simulating installing Wasmer without wapm. -package-without-wapm-for-integration-tests: package-wasmer package-capi - ################# # Miscellaneous # ################# From f2beb34320519b6b0601570a3b02e02e7393102d Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Fri, 20 Nov 2020 23:15:00 -0800 Subject: [PATCH 36/40] Improved cache, fixed target binaries in ci --- .github/workflows/main.yaml | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c1b8853fd0f..36a793d6a42 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -97,6 +97,7 @@ jobs: target = "aarch64-apple-darwin" EOF if: matrix.target == 'aarch64-apple-darwin' + - uses: Swatinem/rust-cache@v1 - name: Configure cargo data directory # After this point, all cargo registry and crate data is stored in # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files @@ -104,34 +105,6 @@ jobs: # around a bug in the 'cache' action that causes directories outside of # the workspace dir to be saved/restored incorrectly. run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV - - name: Cache - uses: actions/cache@master - with: - # Note: crates from the git repo always get rebuilt - # so we cache only those subdirectories of target/{debug|release} that - # contain the build output for crates that come from the registry. - path: |- - .cargo_home - target/*/.* - target/*/build - target/*/deps - key: v1-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - v1-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }} - # # Install sccache - # - uses: actions/cache@master - # with: - # path: ${{ runner.tool_cache }}/cargo-sccache - # key: cargo-sccache-bin-${{ env.CARGO_SCCACHE_VERSION }} - # - name: Install sccache - # run: | - # echo "${{ runner.tool_cache }}/cargo-sccache/bin" >> $GITHUB_PATH - # cargo install sccache --version ${{ env.CARGO_SCCACHE_VERSION }} --root ${{ runner.tool_cache }}/cargo-sccache - # - name: Start sccache - # run: | - # ${{ runner.tool_cache }}/cargo-sccache/bin/sccache --start-server - # ${{ runner.tool_cache }}/cargo-sccache/bin/sscache -s - # echo "RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache" >> $GITHUB_ENV - name: Install LLVM (Windows) if: matrix.os == 'windows-latest' shell: cmd @@ -190,7 +163,7 @@ jobs: cp target/${{matrix.target}}/release/libwasmer* target/release if [ -d "wapm-cli" ]; then mkdir -p wapm-cli/target/release - wapm-cli/target/${{matrix.target}}/release/wapm* wapm-cli/target/release + cp wapm-cli/target/${{matrix.target}}/release/wapm* wapm-cli/target/release fi if: matrix.target - name: Dist From 1ece92b13486faa329a5df15cd4200f15b8b5321 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 21 Nov 2020 00:13:44 -0800 Subject: [PATCH 37/40] Improved cache more --- .github/workflows/main.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 36a793d6a42..0c03532f9f8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -98,13 +98,6 @@ jobs: EOF if: matrix.target == 'aarch64-apple-darwin' - uses: Swatinem/rust-cache@v1 - - name: Configure cargo data directory - # After this point, all cargo registry and crate data is stored in - # $GITHUB_WORKSPACE/.cargo_home. This allows us to cache only the files - # that are needed during the build process. Additionally, this works - # around a bug in the 'cache' action that causes directories outside of - # the workspace dir to be saved/restored incorrectly. - run: echo "CARGO_HOME=$(pwd)/.cargo_home" >> $GITHUB_ENV - name: Install LLVM (Windows) if: matrix.os == 'windows-latest' shell: cmd From 7d4853b2a6c5850a12700d5d853f2604dbe433ac Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 21 Nov 2020 00:15:50 -0800 Subject: [PATCH 38/40] Improved rust target --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0c03532f9f8..e7a7c31632d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -94,9 +94,9 @@ jobs: run: | cat << EOF > .cargo/config.toml [build] - target = "aarch64-apple-darwin" + target = "${{ matrix.target }}" EOF - if: matrix.target == 'aarch64-apple-darwin' + if: matrix.target - uses: Swatinem/rust-cache@v1 - name: Install LLVM (Windows) if: matrix.os == 'windows-latest' From 32e1a54ca735ceb7e206d71c6600372ff657b9c4 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 21 Nov 2020 00:19:55 -0800 Subject: [PATCH 39/40] Build wapm only on release --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e7a7c31632d..f1d99c3d412 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -148,7 +148,7 @@ jobs: - name: Build Wapm binary run: | make build-wapm - # if: needs.setup.outputs.DOING_RELEASE == '1' + if: needs.setup.outputs.DOING_RELEASE == '1' - name: Copy target binaries run: | mkdir -p target/release From 64a39e51e5e122e4838457f22c5390aa516ab525 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 21 Nov 2020 01:09:11 -0800 Subject: [PATCH 40/40] Use wasmer-darwin instead of wasmer-macos --- .github/workflows/main.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f1d99c3d412..26efbdc09fe 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -52,14 +52,14 @@ jobs: os: macos-latest rust: 1.47.0 llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz' - artifact_name: 'wasmer-macos-amd64' + artifact_name: 'wasmer-darwin-amd64' cross_compilation_artifact_name: 'cross_compiled_from_mac' run_integration_tests: true - build: macos-arm64 os: macos-11.0 rust: nightly target: aarch64-apple-darwin - artifact_name: 'wasmer-macos-arm64' + artifact_name: 'wasmer-darwin-arm64' - build: windows os: windows-latest rust: 1.47.0 @@ -315,7 +315,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: artifacts/wasmer-macos-amd64/wasmer.tar.gz + asset_path: artifacts/wasmer-darwin-amd64/wasmer.tar.gz asset_name: wasmer-darwin-amd64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Mac arm64 @@ -325,7 +325,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: artifacts/wasmer-macos-amd64/wasmer.tar.gz + asset_path: artifacts/wasmer-darwin-amd64/wasmer.tar.gz asset_name: wasmer-darwin-arm64.tar.gz asset_content_type: application/gzip - name: Upload Release Asset Linux aarch64