Skip to content

Commit

Permalink
Merge pull request #2249 from wasmerio/unwind-optional
Browse files Browse the repository at this point in the history
Make Cranelift unwind feature optional
  • Loading branch information
syrusakbary authored May 11, 2021
2 parents f2e9a57 + fac052b commit 7d491b4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ test-packages:
cargo test -p wasmer-engine-native --release --no-default-features
cargo test -p wasmer-engine-jit --release --no-default-features
cargo test -p wasmer-compiler --release
cargo test --manifest-path lib/compiler-cranelift/Cargo.toml --release --no-default-features --features=std
cargo test --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std
cargo test --manifest-path lib/cli/Cargo.toml $(compiler_features) --release
cargo test -p wasmer-cache --release
cargo test -p wasmer-engine --release
Expand Down
5 changes: 0 additions & 5 deletions fuzz/Cargo.lock

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

6 changes: 2 additions & 4 deletions lib/compiler-cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,22 @@ cranelift-frontend = { version = "0.70", 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.23", optional = true }
smallvec = "1.6"
loupe = "0.1"

[dev-dependencies]
target-lexicon = { version = "0.11", default-features = false }
cranelift-codegen = { version = "0.70", features = ["enable-serde", "all-arch"] }
cranelift-codegen = { version = "0.70", features = ["all-arch"] }
lazy_static = "1.4"

[badges]
maintenance = { status = "actively-developed" }

[features]
default = ["std", "enable-serde", "unwind"]
default = ["std", "unwind"]
unwind = ["cranelift-codegen/unwind", "gimli"]
enable-serde = ["wasmer-compiler/enable-serde", "wasmer-types/enable-serde", "cranelift-entity/enable-serde"]
std = ["cranelift-codegen/std", "cranelift-frontend/std", "wasmer-compiler/std", "wasmer-types/std"]
core = ["hashbrown", "cranelift-codegen/core", "cranelift-frontend/core"]

Expand Down
17 changes: 15 additions & 2 deletions lib/compiler-cranelift/src/translator/unwind.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
//! A `Compilation` contains the compiled function bodies for a WebAssembly
//! module.
use cranelift_codegen::isa::unwind::systemv::UnwindInfo as DwarfFDE;
use cranelift_codegen::isa::unwind::UnwindInfo;
#[cfg(feature = "unwind")]
use cranelift_codegen::isa::unwind::{systemv::UnwindInfo as DwarfFDE, UnwindInfo};
use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::{isa, Context};
use wasmer_compiler::{CompileError, CompiledFunctionUnwindInfo};

/// Cranelift specific unwind info
pub(crate) enum CraneliftUnwindInfo {
#[cfg(feature = "unwind")]
/// Windows Unwind info
WindowsX64(Vec<u8>),
/// Dwarf FDE
#[cfg(feature = "unwind")]
FDE(DwarfFDE),
/// No Unwind info attached
None,
Expand All @@ -24,6 +26,7 @@ impl CraneliftUnwindInfo {
/// main users of this function)
pub fn maybe_into_to_windows_unwind(self) -> Option<CompiledFunctionUnwindInfo> {
match self {
#[cfg(feature = "unwind")]
Self::WindowsX64(unwind_info) => {
Some(CompiledFunctionUnwindInfo::WindowsX64(unwind_info))
}
Expand All @@ -32,6 +35,7 @@ impl CraneliftUnwindInfo {
}
}

#[cfg(feature = "unwind")]
/// Constructs unwind info object from Cranelift IR
pub(crate) fn compiled_function_unwind_info(
isa: &dyn isa::TargetIsa,
Expand All @@ -52,3 +56,12 @@ pub(crate) fn compiled_function_unwind_info(
Some(_) | None => Ok(CraneliftUnwindInfo::None),
}
}

#[cfg(not(feature = "unwind"))]
/// Constructs unwind info object from Cranelift IR
pub(crate) fn compiled_function_unwind_info(
isa: &dyn isa::TargetIsa,
context: &Context,
) -> Result<CraneliftUnwindInfo, CompileError> {
Ok(CraneliftUnwindInfo::None)
}
6 changes: 2 additions & 4 deletions lib/compiler-singlepass/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ wasmer-vm = { path = "../vm", version = "1.0.2" }
wasmer-types = { path = "../types", version = "1.0.2", default-features = false, features = ["std"] }
rayon = { version = "1.5", optional = true }
hashbrown = { version = "0.9", optional = true }
serde = { version = "1.0", features = ["derive"] }
more-asserts = "0.2"
dynasm = "1.0"
dynasmrt = "1.0"
Expand All @@ -33,7 +32,6 @@ target-lexicon = { version = "0.11", default-features = false }
maintenance = { status = "actively-developed" }

[features]
default = ["std", "enable-serde", "rayon"]
enable-serde = ["wasmer-compiler/enable-serde", "wasmer-types/enable-serde"]
default = ["std", "rayon"]
std = ["wasmer-compiler/std", "wasmer-types/std"]
core = ["hashbrown"]
core = ["hashbrown", "wasmer-types/core"]

0 comments on commit 7d491b4

Please sign in to comment.