mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
Merge branch 'master' into feature/fix-singlepass-panic-no-functions
This commit is contained in:
commit
7b7f55306c
33
CONTRIBUTING.md
Normal file
33
CONTRIBUTING.md
Normal file
@ -0,0 +1,33 @@
|
||||
# How to Contribute to Wasmer
|
||||
|
||||
Thank you for your interest in contributing to Wasmer. This document outlines some recommendations on how to contribute.
|
||||
|
||||
## Issues & Feature Requests
|
||||
Please use the issue template and provide a failing example if possible to help us recreate the issue.
|
||||
|
||||
## Pull Requests
|
||||
For large changes, please try reaching the Wasmer using Github Issues or Spectrum Chat to ensure we can accept the change once it is ready.
|
||||
|
||||
We recommend trying the following commands before sending a pull request to ensure code quality:
|
||||
- `cargo fmt --all` Ensures all code is correctly formatted.
|
||||
- Run `cargo test` in the crates that you are modifying.
|
||||
- Run `cargo build --all` (nightly) or `cargo build --all --exclude wasmer-singlepass-backend`
|
||||
|
||||
A comprehensive CI test suite will be run by a Wasmer team member after the PR has been created.
|
||||
|
||||
### Common Build Issues
|
||||
|
||||
**LLVM Dependency**
|
||||
|
||||
The LLVM backend requires LLVM to be installed to compile.
|
||||
|
||||
So, you may run into the following error:
|
||||
```
|
||||
Didn't find usable system-wide LLVM.
|
||||
No suitable version of LLVM was found system-wide or pointed
|
||||
```
|
||||
|
||||
**Singlepass Nightly Only**
|
||||
|
||||
The singlepass crate depends on nightly so you may need to add the `+nightly` cargo flag to compile this crate.
|
||||
`error[E0554]: #![feature] may not be used on the stable release channel`
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -42,7 +42,7 @@ macro_rules! assert_emscripten_output {
|
||||
|
||||
// let module = compile(&wasm_bytes[..])
|
||||
// .map_err(|err| format!("Can't create the WebAssembly module: {}", err)).unwrap(); // NOTE: Need to figure what the unwrap is for ??
|
||||
let mut emscripten_globals = EmscriptenGlobals::new(&module);
|
||||
let mut emscripten_globals = EmscriptenGlobals::new(&module).expect("globals are valid");
|
||||
let import_object = generate_emscripten_env(&mut emscripten_globals);
|
||||
|
||||
let mut instance = module.instantiate(&import_object)
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
@ -14,7 +16,7 @@ use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::{f64, ffi::c_void};
|
||||
use wasmer_runtime_core::{
|
||||
error::CallResult,
|
||||
error::{CallError, CallResult, ResolveError},
|
||||
export::Export,
|
||||
func,
|
||||
global::Global,
|
||||
@ -371,10 +373,11 @@ pub fn run_emscripten_instance(
|
||||
0 => {
|
||||
instance.call(func_name, &[])?;
|
||||
}
|
||||
_ => panic!(
|
||||
"The emscripten main function has received an incorrect number of params {}",
|
||||
num_params
|
||||
),
|
||||
_ => {
|
||||
return Err(CallError::Resolve(ResolveError::ExportWrongType {
|
||||
name: "main".to_string(),
|
||||
}))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -434,7 +437,7 @@ pub struct EmscriptenGlobals {
|
||||
}
|
||||
|
||||
impl EmscriptenGlobals {
|
||||
pub fn new(module: &Module /*, static_bump: u32 */) -> Self {
|
||||
pub fn new(module: &Module /*, static_bump: u32 */) -> Result<Self, String> {
|
||||
let mut use_old_abort_on_cannot_grow_memory = false;
|
||||
for (
|
||||
index,
|
||||
@ -456,8 +459,8 @@ impl EmscriptenGlobals {
|
||||
}
|
||||
}
|
||||
|
||||
let (table_min, table_max) = get_emscripten_table_size(&module);
|
||||
let (memory_min, memory_max, shared) = get_emscripten_memory_size(&module);
|
||||
let (table_min, table_max) = get_emscripten_table_size(&module)?;
|
||||
let (memory_min, memory_max, shared) = get_emscripten_memory_size(&module)?;
|
||||
|
||||
// Memory initialization
|
||||
let memory_type = MemoryDescriptor {
|
||||
@ -528,14 +531,14 @@ impl EmscriptenGlobals {
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
Ok(Self {
|
||||
data,
|
||||
memory,
|
||||
table,
|
||||
memory_min,
|
||||
memory_max,
|
||||
null_func_names,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,22 +33,20 @@ pub fn is_emscripten_module(module: &Module) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn get_emscripten_table_size(module: &Module) -> (u32, Option<u32>) {
|
||||
assert!(
|
||||
module.info().imported_tables.len() > 0,
|
||||
"Emscripten requires at least one imported table"
|
||||
);
|
||||
pub fn get_emscripten_table_size(module: &Module) -> Result<(u32, Option<u32>), String> {
|
||||
if module.info().imported_tables.len() == 0 {
|
||||
return Err("Emscripten requires at least one imported table".to_string());
|
||||
}
|
||||
let (_, table) = &module.info().imported_tables[ImportedTableIndex::new(0)];
|
||||
(table.minimum, table.maximum)
|
||||
Ok((table.minimum, table.maximum))
|
||||
}
|
||||
|
||||
pub fn get_emscripten_memory_size(module: &Module) -> (Pages, Option<Pages>, bool) {
|
||||
assert!(
|
||||
module.info().imported_tables.len() > 0,
|
||||
"Emscripten requires at least one imported memory"
|
||||
);
|
||||
pub fn get_emscripten_memory_size(module: &Module) -> Result<(Pages, Option<Pages>, bool), String> {
|
||||
if module.info().imported_memories.len() == 0 {
|
||||
return Err("Emscripten requires at least one imported memory".to_string());
|
||||
}
|
||||
let (_, memory) = &module.info().imported_memories[ImportedMemoryIndex::new(0)];
|
||||
(memory.minimum, memory.maximum, memory.shared)
|
||||
Ok((memory.minimum, memory.maximum, memory.shared))
|
||||
}
|
||||
|
||||
/// Reads values written by `-s EMIT_EMSCRIPTEN_METADATA=1`
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
@ -542,7 +544,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
|
||||
// TODO: refactor this
|
||||
if wasmer_emscripten::is_emscripten_module(&module) {
|
||||
let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module);
|
||||
let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module)?;
|
||||
let import_object = wasmer_emscripten::generate_emscripten_env(&mut emscripten_globals);
|
||||
let mut instance = module
|
||||
.instantiate(&import_object)
|
||||
|
@ -1,6 +1,8 @@
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
unused_imports,
|
||||
unused_mut,
|
||||
unused_variables,
|
||||
unused_unsafe,
|
||||
unreachable_patterns
|
||||
|
Loading…
Reference in New Issue
Block a user