Skip to content

Commit

Permalink
Merge branch 'libcall_trampolines' of github.com:wasmerio/wasmer into…
Browse files Browse the repository at this point in the history
… libcall_trampolines

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	lib/engine-dylib/src/artifact.rs
  • Loading branch information
syrusakbary committed Jan 18, 2022
2 parents cbcf233 + e188807 commit 1be3c73
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -296,4 +296,4 @@ path = "examples/features.rs"
required-features = ["cranelift"]

[patch.crates-io]
object = { git = "https://github.com/Amanieu/object", branch = "wasmer" }
object = { git = "https://github.com/gimli-rs/object" }
24 changes: 15 additions & 9 deletions lib/engine-dylib/src/artifact.rs
Expand Up @@ -176,6 +176,8 @@ impl DylibArtifact {
data: &[u8],
tunables: &dyn Tunables,
) -> Result<Self, CompileError> {
use object::{write::CoffExportStyle, BinaryFormat};

let mut engine_inner = engine.inner_mut();
let target = engine.target();
let compiler = engine_inner.compiler()?;
Expand Down Expand Up @@ -241,6 +243,9 @@ impl DylibArtifact {
let mut obj =
get_object_for_target(&target_triple).map_err(to_compile_error)?;
emit_trampolines(&mut obj, engine.target());
if obj.format() == BinaryFormat::Coff {
obj.add_coff_exports(CoffExportStyle::Gnu);
}
let file = tempfile::Builder::new()
.prefix("wasmer_dylib_")
.suffix(".o")
Expand Down Expand Up @@ -285,6 +290,9 @@ impl DylibArtifact {
.map_err(to_compile_error)?;
emit_compilation(&mut obj, compilation, &symbol_registry, &target_triple)
.map_err(to_compile_error)?;
if obj.format() == BinaryFormat::Coff {
obj.add_coff_exports(CoffExportStyle::Gnu);
}
let file = tempfile::Builder::new()
.prefix("wasmer_dylib_")
.suffix(".o")
Expand Down Expand Up @@ -481,6 +489,13 @@ impl DylibArtifact {
dylib_path: PathBuf,
lib: Library,
) -> Result<Self, CompileError> {
unsafe {
let trampolines_symbol: LibrarySymbol<usize> = lib
.get(WASMER_TRAMPOLINES_SYMBOL)
.expect("missing WASMER_TRAMPOLINES symbol");
fill_trampoline_table(trampolines_symbol.into_raw().into_raw() as *mut usize);
}

let mut finished_functions: PrimaryMap<LocalFunctionIndex, FunctionBodyPtr> =
PrimaryMap::new();
for (function_local_index, _function_len) in metadata.function_body_lengths.iter() {
Expand Down Expand Up @@ -665,15 +680,6 @@ impl DylibArtifact {

let metadata = ModuleMetadata::deserialize(metadata_slice)?;

let trampolines_symbol: LibrarySymbol<usize> =
lib.get(WASMER_TRAMPOLINES_SYMBOL).map_err(|e| {
DeserializeError::CorruptedBinary(format!(
"The provided object file doesn't seem to be generated by Wasmer: {}",
e
))
})?;
fill_trampoline_table(trampolines_symbol.into_raw().into_raw() as *mut usize);

let mut engine_inner = engine.inner_mut();

Self::from_parts(&mut engine_inner, metadata, shared_path, lib)
Expand Down
2 changes: 1 addition & 1 deletion tests/ignores.txt
Expand Up @@ -32,7 +32,6 @@ llvm traps::start_trap_pretty
dylib traps::start_trap_pretty
aarch64 traps::start_trap_pretty

cranelift multi_value_imports::dylib # Needs investigation
singlepass multi_value_imports::dylib # Singlepass doesn't support multivalue
singlepass multi_value_imports::dynamic # Singlepass doesn't support multivalue

Expand All @@ -45,6 +44,7 @@ singlepass+windows spec::skip_stack_guard_page # Needs investigation.
cranelift+windows spec::skip_stack_guard_page # Needs investigation. Issue: `STATUS_ACCESS_VIOLATION` trap happened
cranelift+macos spec::skip_stack_guard_page # Needs investigation. process didn't exit successfully: (signal: 6, SIGABRT: process abort signal)
llvm+macos spec::skip_stack_guard_page # Needs investigation. process didn't exit successfully: (signal: 6, SIGABRT: process abort signal)
dylib spec::skip_stack_guard_page # Missing trap information in dylibs


# TODO(https://github.com/wasmerio/wasmer/issues/1727): Traps in dylib engine
Expand Down

0 comments on commit 1be3c73

Please sign in to comment.