mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-23 00:45:32 +00:00
feat: Rename wasmer-engine-native
to wasmer-engine-dylib
.
This commit is contained in:
52
Cargo.lock
generated
52
Cargo.lock
generated
@ -2437,7 +2437,7 @@ dependencies = [
|
|||||||
"wasmer-compiler-singlepass",
|
"wasmer-compiler-singlepass",
|
||||||
"wasmer-derive",
|
"wasmer-derive",
|
||||||
"wasmer-engine",
|
"wasmer-engine",
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
@ -2456,7 +2456,7 @@ dependencies = [
|
|||||||
"wasmer-compiler-cranelift",
|
"wasmer-compiler-cranelift",
|
||||||
"wasmer-compiler-llvm",
|
"wasmer-compiler-llvm",
|
||||||
"wasmer-compiler-singlepass",
|
"wasmer-compiler-singlepass",
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-middlewares",
|
"wasmer-middlewares",
|
||||||
"wasmprinter",
|
"wasmprinter",
|
||||||
@ -2484,8 +2484,8 @@ dependencies = [
|
|||||||
"wasmer-compiler-singlepass",
|
"wasmer-compiler-singlepass",
|
||||||
"wasmer-emscripten",
|
"wasmer-emscripten",
|
||||||
"wasmer-engine",
|
"wasmer-engine",
|
||||||
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-object-file",
|
"wasmer-engine-object-file",
|
||||||
"wasmer-engine-shared-object",
|
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-middlewares",
|
"wasmer-middlewares",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
@ -2504,7 +2504,7 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-compiler-singlepass",
|
"wasmer-compiler-singlepass",
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2530,8 +2530,8 @@ dependencies = [
|
|||||||
"wasmer-compiler-singlepass",
|
"wasmer-compiler-singlepass",
|
||||||
"wasmer-emscripten",
|
"wasmer-emscripten",
|
||||||
"wasmer-engine",
|
"wasmer-engine",
|
||||||
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-object-file",
|
"wasmer-engine-object-file",
|
||||||
"wasmer-engine-shared-object",
|
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
@ -2680,26 +2680,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-engine-object-file"
|
name = "wasmer-engine-dylib"
|
||||||
version = "1.0.2"
|
|
||||||
dependencies = [
|
|
||||||
"bincode",
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"leb128",
|
|
||||||
"libloading",
|
|
||||||
"loupe",
|
|
||||||
"serde",
|
|
||||||
"tempfile",
|
|
||||||
"tracing",
|
|
||||||
"wasmer-compiler",
|
|
||||||
"wasmer-engine",
|
|
||||||
"wasmer-object",
|
|
||||||
"wasmer-types",
|
|
||||||
"wasmer-vm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasmer-engine-shared-object"
|
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
@ -2718,6 +2699,25 @@ dependencies = [
|
|||||||
"which 4.1.0",
|
"which 4.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-engine-object-file"
|
||||||
|
version = "1.0.2"
|
||||||
|
dependencies = [
|
||||||
|
"bincode",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"leb128",
|
||||||
|
"libloading",
|
||||||
|
"loupe",
|
||||||
|
"serde",
|
||||||
|
"tempfile",
|
||||||
|
"tracing",
|
||||||
|
"wasmer-compiler",
|
||||||
|
"wasmer-engine",
|
||||||
|
"wasmer-object",
|
||||||
|
"wasmer-types",
|
||||||
|
"wasmer-vm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-engine-universal"
|
name = "wasmer-engine-universal"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@ -2863,8 +2863,8 @@ dependencies = [
|
|||||||
"wasmer-emscripten",
|
"wasmer-emscripten",
|
||||||
"wasmer-engine",
|
"wasmer-engine",
|
||||||
"wasmer-engine-dummy",
|
"wasmer-engine-dummy",
|
||||||
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-object-file",
|
"wasmer-engine-object-file",
|
||||||
"wasmer-engine-shared-object",
|
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-middlewares",
|
"wasmer-middlewares",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
|
22
Cargo.toml
22
Cargo.toml
@ -18,7 +18,7 @@ wasmer-compiler-llvm = { version = "1.0.2", path = "lib/compiler-llvm", optional
|
|||||||
wasmer-emscripten = { version = "1.0.2", path = "lib/emscripten", optional = true }
|
wasmer-emscripten = { version = "1.0.2", path = "lib/emscripten", optional = true }
|
||||||
wasmer-engine = { version = "1.0.2", path = "lib/engine" }
|
wasmer-engine = { version = "1.0.2", path = "lib/engine" }
|
||||||
wasmer-engine-universal = { version = "1.0.2", path = "lib/engine-universal", optional = true }
|
wasmer-engine-universal = { version = "1.0.2", path = "lib/engine-universal", optional = true }
|
||||||
wasmer-engine-shared-object = { version = "1.0.2", path = "lib/engine-shared-object", optional = true }
|
wasmer-engine-dylib = { version = "1.0.2", path = "lib/engine-dylib", optional = true }
|
||||||
wasmer-engine-object-file = { version = "1.0.2", path = "lib/engine-object-file", optional = true }
|
wasmer-engine-object-file = { version = "1.0.2", path = "lib/engine-object-file", optional = true }
|
||||||
wasmer-wasi = { version = "1.0.2", path = "lib/wasi", optional = true }
|
wasmer-wasi = { version = "1.0.2", path = "lib/wasi", optional = true }
|
||||||
wasmer-wast = { version = "1.0.2", path = "tests/lib/wast", optional = true }
|
wasmer-wast = { version = "1.0.2", path = "tests/lib/wast", optional = true }
|
||||||
@ -41,7 +41,7 @@ members = [
|
|||||||
"lib/emscripten",
|
"lib/emscripten",
|
||||||
"lib/engine",
|
"lib/engine",
|
||||||
"lib/engine-universal",
|
"lib/engine-universal",
|
||||||
"lib/engine-shared-object",
|
"lib/engine-dylib",
|
||||||
"lib/engine-object-file",
|
"lib/engine-object-file",
|
||||||
"lib/object",
|
"lib/object",
|
||||||
"lib/vm",
|
"lib/vm",
|
||||||
@ -82,7 +82,7 @@ default = [
|
|||||||
"wat",
|
"wat",
|
||||||
"wast",
|
"wast",
|
||||||
"universal",
|
"universal",
|
||||||
"shared-object",
|
"dylib",
|
||||||
"object-file",
|
"object-file",
|
||||||
"cache",
|
"cache",
|
||||||
"wasi",
|
"wasi",
|
||||||
@ -94,8 +94,8 @@ universal = [
|
|||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"engine",
|
"engine",
|
||||||
]
|
]
|
||||||
shared-object = [
|
dylib = [
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"engine",
|
"engine",
|
||||||
]
|
]
|
||||||
object-file = [
|
object-file = [
|
||||||
@ -111,7 +111,7 @@ compiler = [
|
|||||||
"wasmer/compiler",
|
"wasmer/compiler",
|
||||||
"wasmer-compiler/translator",
|
"wasmer-compiler/translator",
|
||||||
"wasmer-engine-universal/compiler",
|
"wasmer-engine-universal/compiler",
|
||||||
"wasmer-engine-shared-object/compiler",
|
"wasmer-engine-dylib/compiler",
|
||||||
"wasmer-engine-object-file/compiler",
|
"wasmer-engine-object-file/compiler",
|
||||||
]
|
]
|
||||||
singlepass = [
|
singlepass = [
|
||||||
@ -139,9 +139,9 @@ test-llvm = [
|
|||||||
"llvm",
|
"llvm",
|
||||||
]
|
]
|
||||||
|
|
||||||
test-shared-object = [
|
test-dylib = [
|
||||||
"shared-object",
|
"dylib",
|
||||||
"test-generator/test-shared-object",
|
"test-generator/test-dylib",
|
||||||
]
|
]
|
||||||
test-universal = [
|
test-universal = [
|
||||||
"universal",
|
"universal",
|
||||||
@ -170,8 +170,8 @@ path = "examples/engine_universal.rs"
|
|||||||
required-features = ["cranelift"]
|
required-features = ["cranelift"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "engine-shared-object"
|
name = "engine-dylib"
|
||||||
path = "examples/engine_shared_object.rs"
|
path = "examples/engine_dylib.rs"
|
||||||
required-features = ["cranelift"]
|
required-features = ["cranelift"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
81
Makefile
81
Makefile
@ -9,33 +9,32 @@ SHELL=/bin/bash
|
|||||||
|
|
||||||
# The matrix is the product of the following columns:
|
# The matrix is the product of the following columns:
|
||||||
#
|
#
|
||||||
# |------------|---------------|----------|--------------|-------|
|
# |------------|-----------|----------|--------------|-------|
|
||||||
# | Compiler ⨯ Engine ⨯ Platform ⨯ Architecture ⨯ libc |
|
# | Compiler ⨯ Engine ⨯ Platform ⨯ Architecture ⨯ libc |
|
||||||
# |------------|---------------|----------|--------------|-------|
|
# |------------|-----------|----------|--------------|-------|
|
||||||
# | Cranelift | Universal | Linux | amd64 | glibc |
|
# | Cranelift | Universal | Linux | amd64 | glibc |
|
||||||
# | LLVM | Shared Object | Darwin | aarch64 | musl |
|
# | LLVM | Dylib | Darwin | aarch64 | musl |
|
||||||
# | Singlepass | | Windows | | |
|
# | Singlepass | | Windows | | |
|
||||||
# |------------|---------------|----------|--------------|-------|
|
# |------------|-----------|----------|--------------|-------|
|
||||||
#
|
#
|
||||||
# Here is what works and what doesn't:
|
# Here is what works and what doesn't:
|
||||||
#
|
#
|
||||||
# * Cranelift with the Universal engine works everywhere,
|
# * Cranelift with the Universal engine works everywhere,
|
||||||
#
|
#
|
||||||
# * Cranelift with the Shared Object engine works on
|
# * Cranelift with the Dylib engine works on Linux+Darwin/`amd64`, but
|
||||||
# Linux+Darwin/`amd64`, but it doesn't work on */`aarch64` or
|
# it doesn't work on */`aarch64` or Windows/*.
|
||||||
# Windows/*.
|
|
||||||
#
|
#
|
||||||
# * LLVM with the Universal engine works on Linux+Darwin/`amd64`,
|
# * LLVM with the Universal engine works on Linux+Darwin/`amd64`,
|
||||||
# but it doesn't work on */`aarch64` or Windows/*.
|
# but it doesn't work on */`aarch64` or Windows/*.
|
||||||
#
|
#
|
||||||
# * LLVM with the Shared Object engine works on
|
# * LLVM with the Dylib engine works on
|
||||||
# Linux+Darwin/`amd64`+`aarch64`, but it doesn't work on Windows/*.
|
# Linux+Darwin/`amd64`+`aarch64`, but it doesn't work on Windows/*.
|
||||||
#
|
#
|
||||||
# * Singlepass with the Universal engine works on Linux+Darwin/`amd64`, but
|
# * Singlepass with the Universal engine works on Linux+Darwin/`amd64`, but
|
||||||
# it doesn't work on */`aarch64` or Windows/*.
|
# it doesn't work on */`aarch64` or Windows/*.
|
||||||
#
|
#
|
||||||
# * Singlepass with the Shared Object engine doesn't work because it
|
# * Singlepass with the Dylib engine doesn't work because it doesn't
|
||||||
# doesn't know how to output object files for the moment.
|
# know how to output object files for the moment.
|
||||||
#
|
#
|
||||||
# * Windows isn't tested on `aarch64`, that's why we consider it's not
|
# * Windows isn't tested on `aarch64`, that's why we consider it's not
|
||||||
# working, but it might possibly be.
|
# working, but it might possibly be.
|
||||||
@ -211,12 +210,12 @@ ifeq ($(ENABLE_CRANELIFT), 1)
|
|||||||
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX)))
|
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX)))
|
||||||
ifeq ($(IS_AMD64), 1)
|
ifeq ($(IS_AMD64), 1)
|
||||||
ifneq ($(LIBC), musl)
|
ifneq ($(LIBC), musl)
|
||||||
compilers_engines += cranelift-shared-object
|
compilers_engines += cranelift-dylib
|
||||||
endif
|
endif
|
||||||
else ifeq ($(IS_AARCH64), 1)
|
else ifeq ($(IS_AARCH64), 1)
|
||||||
# The object crate doesn't support yet Darwin + Aarch64 relocations
|
# The object crate doesn't support yet Darwin + Aarch64 relocations
|
||||||
ifneq ($(IS_DARWIN), 1)
|
ifneq ($(IS_DARWIN), 1)
|
||||||
compilers_engines += cranelift-shared-object
|
compilers_engines += cranelift-dylib
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -230,9 +229,9 @@ ifeq ($(ENABLE_LLVM), 1)
|
|||||||
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX)))
|
ifneq (, $(filter 1, $(IS_DARWIN) $(IS_LINUX)))
|
||||||
ifeq ($(IS_AMD64), 1)
|
ifeq ($(IS_AMD64), 1)
|
||||||
compilers_engines += llvm-universal
|
compilers_engines += llvm-universal
|
||||||
compilers_engines += llvm-shared-object
|
compilers_engines += llvm-dylib
|
||||||
else ifeq ($(IS_AARCH64), 1)
|
else ifeq ($(IS_AARCH64), 1)
|
||||||
compilers_engines += llvm-shared-object
|
compilers_engines += llvm-dylib
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -301,7 +300,7 @@ capi_compilers_engines_exclude :=
|
|||||||
# LLVM for the moment because it causes the linker to fail since LLVM is not statically linked.
|
# LLVM for the moment because it causes the linker to fail since LLVM is not statically linked.
|
||||||
# TODO: Reenable LLVM in C-API
|
# TODO: Reenable LLVM in C-API
|
||||||
capi_compiler_features := --features $(subst $(space),$(comma),$(filter-out llvm, $(compilers)))
|
capi_compiler_features := --features $(subst $(space),$(comma),$(filter-out llvm, $(compilers)))
|
||||||
capi_compilers_engines_exclude += llvm-universal llvm-shared-object
|
capi_compilers_engines_exclude += llvm-universal llvm-dylib
|
||||||
|
|
||||||
# We exclude singlepass-universal because it doesn't support multivalue (required in wasm-c-api tests)
|
# We exclude singlepass-universal because it doesn't support multivalue (required in wasm-c-api tests)
|
||||||
capi_compilers_engines_exclude += singlepass-universal
|
capi_compilers_engines_exclude += singlepass-universal
|
||||||
@ -424,23 +423,23 @@ endif
|
|||||||
|
|
||||||
build-docs-capi: capi-setup
|
build-docs-capi: capi-setup
|
||||||
cd lib/c-api/doc/deprecated/ && doxygen doxyfile
|
cd lib/c-api/doc/deprecated/ && doxygen doxyfile
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,universal,object-file,shared-object,cranelift,wasi $(capi_default_features)
|
RUSTFLAGS="${RUSTFLAGS}" cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,universal,object-file,dylib,cranelift,wasi $(capi_default_features)
|
||||||
|
|
||||||
build-capi: capi-setup
|
build-capi: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,shared-object,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features)
|
--no-default-features --features deprecated,wat,universal,dylib,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features)
|
||||||
|
|
||||||
build-capi-singlepass: capi-setup
|
build-capi-singlepass: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,shared-object,object-file,singlepass,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,dylib,object-file,singlepass,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-singlepass-universal: capi-setup
|
build-capi-singlepass-universal: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,singlepass,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,singlepass,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-singlepass-shared-object: capi-setup
|
build-capi-singlepass-dylib: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,shared-object,singlepass,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,dylib,singlepass,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-singlepass-object-file: capi-setup
|
build-capi-singlepass-object-file: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
@ -448,35 +447,35 @@ build-capi-singlepass-object-file: capi-setup
|
|||||||
|
|
||||||
build-capi-cranelift: capi-setup
|
build-capi-cranelift: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,shared-object,object-file,cranelift,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,dylib,object-file,cranelift,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-cranelift-system-libffi: capi-setup
|
build-capi-cranelift-system-libffi: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,shared-object,object-file,cranelift,wasi,middlewares,system-libffi $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,dylib,object-file,cranelift,wasi,middlewares,system-libffi $(capi_default_features)
|
||||||
|
|
||||||
build-capi-cranelift-universal: capi-setup
|
build-capi-cranelift-universal: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,cranelift,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,cranelift,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-cranelift-shared-object: capi-setup
|
build-capi-cranelift-dylib: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,shared-object,cranelift,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,dylib,cranelift,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-cranelift-object-file: capi-setup
|
build-capi-cranelift-object-file: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,shared-object,object-file,cranelift,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,dylib,object-file,cranelift,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-llvm: capi-setup
|
build-capi-llvm: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,shared-object,object-file,llvm,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,dylib,object-file,llvm,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-llvm-universal: capi-setup
|
build-capi-llvm-universal: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,llvm,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,universal,llvm,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-llvm-shared-object: capi-setup
|
build-capi-llvm-dylib: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,shared-object,llvm,wasi,middlewares $(capi_default_features)
|
--no-default-features --features deprecated,wat,dylib,llvm,wasi,middlewares $(capi_default_features)
|
||||||
|
|
||||||
build-capi-llvm-object-file: capi-setup
|
build-capi-llvm-object-file: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
@ -488,9 +487,9 @@ build-capi-headless-universal: capi-setup
|
|||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features universal,wasi
|
--no-default-features --features universal,wasi
|
||||||
|
|
||||||
build-capi-headless-shared-object: capi-setup
|
build-capi-headless-dylib: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features shared-object,wasi
|
--no-default-features --features dylib,wasi
|
||||||
|
|
||||||
build-capi-headless-object-file: capi-setup
|
build-capi-headless-object-file: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
@ -498,7 +497,7 @@ build-capi-headless-object-file: capi-setup
|
|||||||
|
|
||||||
build-capi-headless-all: capi-setup
|
build-capi-headless-all: capi-setup
|
||||||
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
RUSTFLAGS="${RUSTFLAGS}" cargo build --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features universal,shared-object,object-file,wasi
|
--no-default-features --features universal,dylib,object-file,wasi
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Testing #
|
# Testing #
|
||||||
@ -521,20 +520,20 @@ test-packages:
|
|||||||
|
|
||||||
test-compilers-compat: $(foreach compiler,$(compilers),test-$(compiler))
|
test-compilers-compat: $(foreach compiler,$(compilers),test-$(compiler))
|
||||||
|
|
||||||
test-singlepass-shared-object:
|
test-singlepass-dylib:
|
||||||
cargo test --release --tests $(compiler_features) -- singlepass::shared-object
|
cargo test --release --tests $(compiler_features) -- singlepass::dylib
|
||||||
|
|
||||||
test-singlepass-universal:
|
test-singlepass-universal:
|
||||||
cargo test --release --tests $(compiler_features) -- singlepass::universal
|
cargo test --release --tests $(compiler_features) -- singlepass::universal
|
||||||
|
|
||||||
test-cranelift-shared-object:
|
test-cranelift-dylib:
|
||||||
cargo test --release --tests $(compiler_features) -- cranelift::shared-object
|
cargo test --release --tests $(compiler_features) -- cranelift::dylib
|
||||||
|
|
||||||
test-cranelift-universal:
|
test-cranelift-universal:
|
||||||
cargo test --release --tests $(compiler_features) -- cranelift::universal
|
cargo test --release --tests $(compiler_features) -- cranelift::universal
|
||||||
|
|
||||||
test-llvm-shared-object:
|
test-llvm-dylib:
|
||||||
cargo test --release --tests $(compiler_features) -- llvm::shared-object
|
cargo test --release --tests $(compiler_features) -- llvm::dylib
|
||||||
|
|
||||||
test-llvm-universal:
|
test-llvm-universal:
|
||||||
cargo test --release --tests $(compiler_features) -- llvm::universal
|
cargo test --release --tests $(compiler_features) -- llvm::universal
|
||||||
@ -551,7 +550,7 @@ test-capi: build-capi package-capi $(foreach compiler_engine,$(capi_compilers_en
|
|||||||
|
|
||||||
test-capi-crate-%:
|
test-capi-crate-%:
|
||||||
WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) cargo test --manifest-path lib/c-api/Cargo.toml --release \
|
WASMER_CAPI_CONFIG=$(shell echo $@ | sed -e s/test-capi-crate-//) cargo test --manifest-path lib/c-api/Cargo.toml --release \
|
||||||
--no-default-features --features deprecated,wat,universal,shared-object,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features) -- --nocapture
|
--no-default-features --features deprecated,wat,universal,dylib,object-file,wasi,middlewares $(capi_default_features) $(capi_compiler_features) -- --nocapture
|
||||||
|
|
||||||
test-capi-integration-%:
|
test-capi-integration-%:
|
||||||
# Test the Wasmer C API tests for C
|
# Test the Wasmer C API tests for C
|
||||||
|
@ -5,7 +5,7 @@ digraph dependencies {
|
|||||||
n1 [label="wasmer-compiler", color=orange];
|
n1 [label="wasmer-compiler", color=orange];
|
||||||
n5 [label="wasmer-engine", color=orange];
|
n5 [label="wasmer-engine", color=orange];
|
||||||
n6 [label="wasmer-engine-universal", color=orange];
|
n6 [label="wasmer-engine-universal", color=orange];
|
||||||
n7 [label="wasmer-engine-shared-object", color=orange];
|
n7 [label="wasmer-engine-dylib", color=orange];
|
||||||
n8 [label="wasmer-types", color=orange];
|
n8 [label="wasmer-types", color=orange];
|
||||||
n9 [label="wasmer-vm", color=orange];
|
n9 [label="wasmer-vm", color=orange];
|
||||||
n10 [label="wasmer-c-api", color=orange];
|
n10 [label="wasmer-c-api", color=orange];
|
||||||
@ -29,7 +29,7 @@ digraph dependencies {
|
|||||||
color=brown;
|
color=brown;
|
||||||
|
|
||||||
n6 [label="wasmer-engine-universal", color=orange];
|
n6 [label="wasmer-engine-universal", color=orange];
|
||||||
n7 [label="wasmer-engine-shared-object", color=orange];
|
n7 [label="wasmer-engine-dylib", color=orange];
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4,241 +4,241 @@
|
|||||||
<!-- Generated by graphviz version 2.47.1 (20210417.1919)
|
<!-- Generated by graphviz version 2.47.1 (20210417.1919)
|
||||||
-->
|
-->
|
||||||
<!-- Title: dependencies Pages: 1 -->
|
<!-- Title: dependencies Pages: 1 -->
|
||||||
<svg width="1169pt" height="554pt"
|
<svg width="1111pt" height="554pt"
|
||||||
viewBox="0.00 0.00 1169.00 554.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
viewBox="0.00 0.00 1111.00 554.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 550)">
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 550)">
|
||||||
<title>dependencies</title>
|
<title>dependencies</title>
|
||||||
<polygon fill="white" stroke="transparent" points="-4,4 -4,-550 1165,-550 1165,4 -4,4"/>
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-550 1107,-550 1107,4 -4,4"/>
|
||||||
<g id="clust1" class="cluster">
|
<g id="clust1" class="cluster">
|
||||||
<title>cluster_compiler</title>
|
<title>cluster_compiler</title>
|
||||||
<polygon fill="none" stroke="brown" points="480,-280 480,-355 1153,-355 1153,-280 480,-280"/>
|
<polygon fill="none" stroke="brown" points="422,-280 422,-355 1095,-355 1095,-280 422,-280"/>
|
||||||
<text text-anchor="middle" x="816.5" y="-339.8" font-family="Times,serif" font-size="14.00">Compilers</text>
|
<text text-anchor="middle" x="758.5" y="-339.8" font-family="Times,serif" font-size="14.00">Compilers</text>
|
||||||
</g>
|
</g>
|
||||||
<g id="clust2" class="cluster">
|
<g id="clust2" class="cluster">
|
||||||
<title>cluster_engine</title>
|
<title>cluster_engine</title>
|
||||||
<polygon fill="none" stroke="brown" points="8,-280 8,-355 472,-355 472,-280 8,-280"/>
|
<polygon fill="none" stroke="brown" points="8,-280 8,-355 414,-355 414,-280 8,-280"/>
|
||||||
<text text-anchor="middle" x="240" y="-339.8" font-family="Times,serif" font-size="14.00">Engines</text>
|
<text text-anchor="middle" x="211" y="-339.8" font-family="Times,serif" font-size="14.00">Engines</text>
|
||||||
</g>
|
</g>
|
||||||
<g id="clust4" class="cluster">
|
<g id="clust4" class="cluster">
|
||||||
<title>cluster_abi</title>
|
<title>cluster_abi</title>
|
||||||
<polygon fill="none" stroke="brown" points="359,-427 359,-502 670,-502 670,-427 359,-427"/>
|
<polygon fill="none" stroke="brown" points="301,-427 301,-502 612,-502 612,-427 301,-427"/>
|
||||||
<text text-anchor="middle" x="514.5" y="-486.8" font-family="Times,serif" font-size="14.00">Provided ABIs</text>
|
<text text-anchor="middle" x="456.5" y="-486.8" font-family="Times,serif" font-size="14.00">Provided ABIs</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n0 -->
|
<!-- n0 -->
|
||||||
<g id="node1" class="node">
|
<g id="node1" class="node">
|
||||||
<title>n0</title>
|
<title>n0</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="581" cy="-381" rx="38.19" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="523" cy="-381" rx="38.19" ry="18"/>
|
||||||
<text text-anchor="middle" x="581" y="-377.3" font-family="Times,serif" font-size="14.00">wasmer</text>
|
<text text-anchor="middle" x="523" y="-377.3" font-family="Times,serif" font-size="14.00">wasmer</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n6 -->
|
<!-- n6 -->
|
||||||
<g id="node4" class="node">
|
<g id="node4" class="node">
|
||||||
<title>n6</title>
|
<title>n6</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="364" cy="-306" rx="100.18" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="306" cy="-306" rx="100.18" ry="18"/>
|
||||||
<text text-anchor="middle" x="364" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-engine-universal</text>
|
<text text-anchor="middle" x="306" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-engine-universal</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n0->n6 -->
|
<!-- n0->n6 -->
|
||||||
<g id="edge12" class="edge">
|
<g id="edge12" class="edge">
|
||||||
<title>n0->n6</title>
|
<title>n0->n6</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M546.06,-373.25C525.43,-368.88 498.95,-362.59 476,-355 452.49,-347.23 427.06,-336.52 406.38,-327.2"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M488.06,-373.25C467.43,-368.88 440.95,-362.59 418,-355 394.49,-347.23 369.06,-336.52 348.38,-327.2"/>
|
||||||
<polygon fill="orange" stroke="orange" points="407.79,-323.99 397.24,-323.02 404.88,-330.36 407.79,-323.99"/>
|
<polygon fill="orange" stroke="orange" points="349.79,-323.99 339.24,-323.02 346.88,-330.36 349.79,-323.99"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n7 -->
|
<!-- n7 -->
|
||||||
<g id="node5" class="node">
|
<g id="node5" class="node">
|
||||||
<title>n7</title>
|
<title>n7</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="131" cy="-306" rx="115.08" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="102" cy="-306" rx="85.59" ry="18"/>
|
||||||
<text text-anchor="middle" x="131" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-engine-shared-object</text>
|
<text text-anchor="middle" x="102" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-engine-dylib</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n0->n7 -->
|
<!-- n0->n7 -->
|
||||||
<g id="edge13" class="edge">
|
<g id="edge13" class="edge">
|
||||||
<title>n0->n7</title>
|
<title>n0->n7</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M542.32,-380.66C480.71,-380.9 356.86,-378.09 255,-355 227.3,-348.72 197.58,-337.39 174.18,-327.31"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M484.8,-378.93C410.73,-376.56 250.17,-369.84 197,-355 175.78,-349.08 153.72,-338.26 136.21,-328.39"/>
|
||||||
<polygon fill="orange" stroke="orange" points="175.46,-324.05 164.89,-323.23 172.64,-330.46 175.46,-324.05"/>
|
<polygon fill="orange" stroke="orange" points="137.9,-325.33 127.49,-323.35 134.39,-331.39 137.9,-325.33"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n2 -->
|
<!-- n2 -->
|
||||||
<g id="node13" class="node">
|
<g id="node13" class="node">
|
||||||
<title>n2</title>
|
<title>n2</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="1040" cy="-306" rx="105.08" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="982" cy="-306" rx="105.08" ry="18"/>
|
||||||
<text text-anchor="middle" x="1040" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-compiler-cranelift</text>
|
<text text-anchor="middle" x="982" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-compiler-cranelift</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n0->n2 -->
|
<!-- n0->n2 -->
|
||||||
<g id="edge9" class="edge">
|
<g id="edge9" class="edge">
|
||||||
<title>n0->n2</title>
|
<title>n0->n2</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M619.13,-378.78C696.16,-376.05 867.84,-368.62 925,-355 950.67,-348.88 977.98,-337.7 999.54,-327.67"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M561.13,-378.78C638.16,-376.05 809.84,-368.62 867,-355 892.67,-348.88 919.98,-337.7 941.54,-327.67"/>
|
||||||
<polygon fill="orange" stroke="orange" points="1001.18,-330.76 1008.71,-323.31 998.18,-324.44 1001.18,-330.76"/>
|
<polygon fill="orange" stroke="orange" points="943.18,-330.76 950.71,-323.31 940.18,-324.44 943.18,-330.76"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n3 -->
|
<!-- n3 -->
|
||||||
<g id="node14" class="node">
|
<g id="node14" class="node">
|
||||||
<title>n3</title>
|
<title>n3</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="581" cy="-306" rx="92.88" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="523" cy="-306" rx="92.88" ry="18"/>
|
||||||
<text text-anchor="middle" x="581" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-compiler-llvm</text>
|
<text text-anchor="middle" x="523" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-compiler-llvm</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n0->n3 -->
|
<!-- n0->n3 -->
|
||||||
<g id="edge10" class="edge">
|
<g id="edge10" class="edge">
|
||||||
<title>n0->n3</title>
|
<title>n0->n3</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M581,-362.7C581,-354.25 581,-343.87 581,-334.37"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M523,-362.7C523,-354.25 523,-343.87 523,-334.37"/>
|
||||||
<polygon fill="orange" stroke="orange" points="584.5,-334.18 581,-324.18 577.5,-334.18 584.5,-334.18"/>
|
<polygon fill="orange" stroke="orange" points="526.5,-334.18 523,-324.18 519.5,-334.18 526.5,-334.18"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n4 -->
|
<!-- n4 -->
|
||||||
<g id="node15" class="node">
|
<g id="node15" class="node">
|
||||||
<title>n4</title>
|
<title>n4</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="804" cy="-306" rx="112.38" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="746" cy="-306" rx="112.38" ry="18"/>
|
||||||
<text text-anchor="middle" x="804" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-compiler-singlepass</text>
|
<text text-anchor="middle" x="746" y="-302.3" font-family="Times,serif" font-size="14.00">wasmer-compiler-singlepass</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n0->n4 -->
|
<!-- n0->n4 -->
|
||||||
<g id="edge11" class="edge">
|
<g id="edge11" class="edge">
|
||||||
<title>n0->n4</title>
|
<title>n0->n4</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M615.33,-372.82C635.27,-368.35 660.77,-362.1 683,-355 708.24,-346.94 735.75,-336.2 758.14,-326.91"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M557.33,-372.82C577.27,-368.35 602.77,-362.1 625,-355 650.24,-346.94 677.75,-336.2 700.14,-326.91"/>
|
||||||
<polygon fill="orange" stroke="orange" points="759.53,-330.13 767.41,-323.04 756.83,-323.67 759.53,-330.13"/>
|
<polygon fill="orange" stroke="orange" points="701.53,-330.13 709.41,-323.04 698.83,-323.67 701.53,-330.13"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n1 -->
|
<!-- n1 -->
|
||||||
<g id="node2" class="node">
|
<g id="node2" class="node">
|
||||||
<title>n1</title>
|
<title>n1</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="692" cy="-162" rx="73.39" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="634" cy="-162" rx="73.39" ry="18"/>
|
||||||
<text text-anchor="middle" x="692" y="-158.3" font-family="Times,serif" font-size="14.00">wasmer-compiler</text>
|
<text text-anchor="middle" x="634" y="-158.3" font-family="Times,serif" font-size="14.00">wasmer-compiler</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n9 -->
|
<!-- n9 -->
|
||||||
<g id="node7" class="node">
|
<g id="node7" class="node">
|
||||||
<title>n9</title>
|
<title>n9</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="692" cy="-90" rx="53.09" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="634" cy="-90" rx="53.09" ry="18"/>
|
||||||
<text text-anchor="middle" x="692" y="-86.3" font-family="Times,serif" font-size="14.00">wasmer-vm</text>
|
<text text-anchor="middle" x="634" y="-86.3" font-family="Times,serif" font-size="14.00">wasmer-vm</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n1->n9 -->
|
<!-- n1->n9 -->
|
||||||
<g id="edge20" class="edge">
|
<g id="edge20" class="edge">
|
||||||
<title>n1->n9</title>
|
<title>n1->n9</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M692,-143.7C692,-135.98 692,-126.71 692,-118.11"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M634,-143.7C634,-135.98 634,-126.71 634,-118.11"/>
|
||||||
<polygon fill="orange" stroke="orange" points="695.5,-118.1 692,-108.1 688.5,-118.1 695.5,-118.1"/>
|
<polygon fill="orange" stroke="orange" points="637.5,-118.1 634,-108.1 630.5,-118.1 637.5,-118.1"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n5 -->
|
<!-- n5 -->
|
||||||
<g id="node3" class="node">
|
<g id="node3" class="node">
|
||||||
<title>n5</title>
|
<title>n5</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="364" cy="-234" rx="64.99" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="306" cy="-234" rx="64.99" ry="18"/>
|
||||||
<text text-anchor="middle" x="364" y="-230.3" font-family="Times,serif" font-size="14.00">wasmer-engine</text>
|
<text text-anchor="middle" x="306" y="-230.3" font-family="Times,serif" font-size="14.00">wasmer-engine</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n5->n1 -->
|
<!-- n5->n1 -->
|
||||||
<g id="edge19" class="edge">
|
<g id="edge19" class="edge">
|
||||||
<title>n5->n1</title>
|
<title>n5->n1</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M413.82,-222.37C471.2,-210.12 565.6,-189.98 628.28,-176.6"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M355.82,-222.37C413.2,-210.12 507.6,-189.98 570.28,-176.6"/>
|
||||||
<polygon fill="orange" stroke="orange" points="629.39,-179.94 638.44,-174.43 627.93,-173.09 629.39,-179.94"/>
|
<polygon fill="orange" stroke="orange" points="571.39,-179.94 580.44,-174.43 569.93,-173.09 571.39,-179.94"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n6->n5 -->
|
<!-- n6->n5 -->
|
||||||
<g id="edge17" class="edge">
|
<g id="edge17" class="edge">
|
||||||
<title>n6->n5</title>
|
<title>n6->n5</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M364,-287.7C364,-279.98 364,-270.71 364,-262.11"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M306,-287.7C306,-279.98 306,-270.71 306,-262.11"/>
|
||||||
<polygon fill="orange" stroke="orange" points="367.5,-262.1 364,-252.1 360.5,-262.1 367.5,-262.1"/>
|
<polygon fill="orange" stroke="orange" points="309.5,-262.1 306,-252.1 302.5,-262.1 309.5,-262.1"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n7->n5 -->
|
<!-- n7->n5 -->
|
||||||
<g id="edge18" class="edge">
|
<g id="edge18" class="edge">
|
||||||
<title>n7->n5</title>
|
<title>n7->n5</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M181.56,-289.81C220.18,-278.21 273.21,-262.28 312.15,-250.58"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M144.77,-290.33C177.52,-279.09 222.74,-263.57 256.96,-251.83"/>
|
||||||
<polygon fill="orange" stroke="orange" points="313.16,-253.93 321.73,-247.7 311.14,-247.23 313.16,-253.93"/>
|
<polygon fill="orange" stroke="orange" points="258.42,-255.03 266.75,-248.47 256.15,-248.4 258.42,-255.03"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n8 -->
|
<!-- n8 -->
|
||||||
<g id="node6" class="node">
|
<g id="node6" class="node">
|
||||||
<title>n8</title>
|
<title>n8</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="692" cy="-18" rx="59.59" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="634" cy="-18" rx="59.59" ry="18"/>
|
||||||
<text text-anchor="middle" x="692" y="-14.3" font-family="Times,serif" font-size="14.00">wasmer-types</text>
|
<text text-anchor="middle" x="634" y="-14.3" font-family="Times,serif" font-size="14.00">wasmer-types</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n9->n8 -->
|
<!-- n9->n8 -->
|
||||||
<g id="edge21" class="edge">
|
<g id="edge21" class="edge">
|
||||||
<title>n9->n8</title>
|
<title>n9->n8</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M692,-71.7C692,-63.98 692,-54.71 692,-46.11"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M634,-71.7C634,-63.98 634,-54.71 634,-46.11"/>
|
||||||
<polygon fill="orange" stroke="orange" points="695.5,-46.1 692,-36.1 688.5,-46.1 695.5,-46.1"/>
|
<polygon fill="orange" stroke="orange" points="637.5,-46.1 634,-36.1 630.5,-46.1 637.5,-46.1"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n10 -->
|
<!-- n10 -->
|
||||||
<g id="node8" class="node">
|
<g id="node8" class="node">
|
||||||
<title>n10</title>
|
<title>n10</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="440" cy="-528" rx="59.29" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="382" cy="-528" rx="59.29" ry="18"/>
|
||||||
<text text-anchor="middle" x="440" y="-524.3" font-family="Times,serif" font-size="14.00">wasmer-c-api</text>
|
<text text-anchor="middle" x="382" y="-524.3" font-family="Times,serif" font-size="14.00">wasmer-c-api</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n11 -->
|
<!-- n11 -->
|
||||||
<g id="node9" class="node">
|
<g id="node9" class="node">
|
||||||
<title>n11</title>
|
<title>n11</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="581" cy="-453" rx="80.69" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="523" cy="-453" rx="80.69" ry="18"/>
|
||||||
<text text-anchor="middle" x="581" y="-449.3" font-family="Times,serif" font-size="14.00">wasmer-emscripten</text>
|
<text text-anchor="middle" x="523" y="-449.3" font-family="Times,serif" font-size="14.00">wasmer-emscripten</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n10->n11 -->
|
<!-- n10->n11 -->
|
||||||
<g id="edge5" class="edge">
|
<g id="edge5" class="edge">
|
||||||
<title>n10->n11</title>
|
<title>n10->n11</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M470.64,-512.56C477.69,-509.16 485.13,-505.5 492,-502 509,-493.34 527.6,-483.38 543.39,-474.79"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M412.64,-512.56C419.69,-509.16 427.13,-505.5 434,-502 451,-493.34 469.6,-483.38 485.39,-474.79"/>
|
||||||
<polygon fill="orange" stroke="orange" points="545.22,-477.77 552.32,-469.91 541.87,-471.63 545.22,-477.77"/>
|
<polygon fill="orange" stroke="orange" points="487.22,-477.77 494.32,-469.91 483.87,-471.63 487.22,-477.77"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n12 -->
|
<!-- n12 -->
|
||||||
<g id="node10" class="node">
|
<g id="node10" class="node">
|
||||||
<title>n12</title>
|
<title>n12</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="425" cy="-453" rx="57.69" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="367" cy="-453" rx="57.69" ry="18"/>
|
||||||
<text text-anchor="middle" x="425" y="-449.3" font-family="Times,serif" font-size="14.00">wasmer-wasi</text>
|
<text text-anchor="middle" x="367" y="-449.3" font-family="Times,serif" font-size="14.00">wasmer-wasi</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n10->n12 -->
|
<!-- n10->n12 -->
|
||||||
<g id="edge6" class="edge">
|
<g id="edge6" class="edge">
|
||||||
<title>n10->n12</title>
|
<title>n10->n12</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M436.45,-509.7C434.69,-501.15 432.53,-490.65 430.56,-481.07"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M378.45,-509.7C376.69,-501.15 374.53,-490.65 372.56,-481.07"/>
|
||||||
<polygon fill="orange" stroke="orange" points="433.97,-480.27 428.53,-471.18 427.11,-481.68 433.97,-480.27"/>
|
<polygon fill="orange" stroke="orange" points="375.97,-480.27 370.53,-471.18 369.11,-481.68 375.97,-480.27"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n11->n0 -->
|
<!-- n11->n0 -->
|
||||||
<g id="edge7" class="edge">
|
<g id="edge7" class="edge">
|
||||||
<title>n11->n0</title>
|
<title>n11->n0</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M581,-434.7C581,-426.98 581,-417.71 581,-409.11"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M523,-434.7C523,-426.98 523,-417.71 523,-409.11"/>
|
||||||
<polygon fill="orange" stroke="orange" points="584.5,-409.1 581,-399.1 577.5,-409.1 584.5,-409.1"/>
|
<polygon fill="orange" stroke="orange" points="526.5,-409.1 523,-399.1 519.5,-409.1 526.5,-409.1"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n12->n0 -->
|
<!-- n12->n0 -->
|
||||||
<g id="edge8" class="edge">
|
<g id="edge8" class="edge">
|
||||||
<title>n12->n0</title>
|
<title>n12->n0</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M456.57,-437.83C482.1,-426.38 518.07,-410.24 544.77,-398.26"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M398.57,-437.83C424.1,-426.38 460.07,-410.24 486.77,-398.26"/>
|
||||||
<polygon fill="orange" stroke="orange" points="546.46,-401.33 554.15,-394.05 543.6,-394.95 546.46,-401.33"/>
|
<polygon fill="orange" stroke="orange" points="488.46,-401.33 496.15,-394.05 485.6,-394.95 488.46,-401.33"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n13 -->
|
<!-- n13 -->
|
||||||
<g id="node11" class="node">
|
<g id="node11" class="node">
|
||||||
<title>n13</title>
|
<title>n13</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="741" cy="-453" rx="61.99" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="683" cy="-453" rx="61.99" ry="18"/>
|
||||||
<text text-anchor="middle" x="741" y="-449.3" font-family="Times,serif" font-size="14.00">wasmer-cache</text>
|
<text text-anchor="middle" x="683" y="-449.3" font-family="Times,serif" font-size="14.00">wasmer-cache</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n13->n0 -->
|
<!-- n13->n0 -->
|
||||||
<g id="edge4" class="edge">
|
<g id="edge4" class="edge">
|
||||||
<title>n13->n0</title>
|
<title>n13->n0</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M708.24,-437.67C681.82,-426.11 644.7,-409.87 617.37,-397.91"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M650.24,-437.67C623.82,-426.11 586.7,-409.87 559.37,-397.91"/>
|
||||||
<polygon fill="orange" stroke="orange" points="618.71,-394.68 608.14,-393.87 615.9,-401.09 618.71,-394.68"/>
|
<polygon fill="orange" stroke="orange" points="560.71,-394.68 550.14,-393.87 557.9,-401.09 560.71,-394.68"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n14 -->
|
<!-- n14 -->
|
||||||
<g id="node12" class="node">
|
<g id="node12" class="node">
|
||||||
<title>n14</title>
|
<title>n14</title>
|
||||||
<ellipse fill="none" stroke="orange" cx="581" cy="-528" rx="50.09" ry="18"/>
|
<ellipse fill="none" stroke="orange" cx="523" cy="-528" rx="50.09" ry="18"/>
|
||||||
<text text-anchor="middle" x="581" y="-524.3" font-family="Times,serif" font-size="14.00">wasmer-cli</text>
|
<text text-anchor="middle" x="523" y="-524.3" font-family="Times,serif" font-size="14.00">wasmer-cli</text>
|
||||||
</g>
|
</g>
|
||||||
<!-- n14->n11 -->
|
<!-- n14->n11 -->
|
||||||
<g id="edge3" class="edge">
|
<g id="edge3" class="edge">
|
||||||
<title>n14->n11</title>
|
<title>n14->n11</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M581,-509.7C581,-501.25 581,-490.87 581,-481.37"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M523,-509.7C523,-501.25 523,-490.87 523,-481.37"/>
|
||||||
<polygon fill="orange" stroke="orange" points="584.5,-481.18 581,-471.18 577.5,-481.18 584.5,-481.18"/>
|
<polygon fill="orange" stroke="orange" points="526.5,-481.18 523,-471.18 519.5,-481.18 526.5,-481.18"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n14->n12 -->
|
<!-- n14->n12 -->
|
||||||
<g id="edge2" class="edge">
|
<g id="edge2" class="edge">
|
||||||
<title>n14->n12</title>
|
<title>n14->n12</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M538.19,-518.44C522.87,-514.52 505.75,-509.12 491,-502 477.04,-495.26 462.95,-485.51 451.4,-476.55"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M480.19,-518.44C464.87,-514.52 447.75,-509.12 433,-502 419.04,-495.26 404.95,-485.51 393.4,-476.55"/>
|
||||||
<polygon fill="orange" stroke="orange" points="453.47,-473.73 443.47,-470.23 449.11,-479.2 453.47,-473.73"/>
|
<polygon fill="orange" stroke="orange" points="395.47,-473.73 385.47,-470.23 391.11,-479.2 395.47,-473.73"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n14->n13 -->
|
<!-- n14->n13 -->
|
||||||
<g id="edge1" class="edge">
|
<g id="edge1" class="edge">
|
||||||
<title>n14->n13</title>
|
<title>n14->n13</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M624.27,-518.78C640.34,-514.85 658.44,-509.37 674,-502 688.15,-495.3 702.45,-485.56 714.18,-476.6"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M566.27,-518.78C582.34,-514.85 600.44,-509.37 616,-502 630.15,-495.3 644.45,-485.56 656.18,-476.6"/>
|
||||||
<polygon fill="orange" stroke="orange" points="716.53,-479.2 722.23,-470.26 712.21,-473.7 716.53,-479.2"/>
|
<polygon fill="orange" stroke="orange" points="658.53,-479.2 664.23,-470.26 654.21,-473.7 658.53,-479.2"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n2->n1 -->
|
<!-- n2->n1 -->
|
||||||
<g id="edge14" class="edge">
|
<g id="edge14" class="edge">
|
||||||
<title>n2->n1</title>
|
<title>n2->n1</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M1001.09,-289.12C936.21,-262.65 806.27,-209.63 737.35,-181.5"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M943.09,-289.12C878.21,-262.65 748.27,-209.63 679.35,-181.5"/>
|
||||||
<polygon fill="orange" stroke="orange" points="738.62,-178.24 728.04,-177.71 735.98,-184.72 738.62,-178.24"/>
|
<polygon fill="orange" stroke="orange" points="680.62,-178.24 670.04,-177.71 677.98,-184.72 680.62,-178.24"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n3->n1 -->
|
<!-- n3->n1 -->
|
||||||
<g id="edge15" class="edge">
|
<g id="edge15" class="edge">
|
||||||
<title>n3->n1</title>
|
<title>n3->n1</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M594.17,-288.15C613.61,-263.28 650.12,-216.57 672.62,-187.79"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M536.17,-288.15C555.61,-263.28 592.12,-216.57 614.62,-187.79"/>
|
||||||
<polygon fill="orange" stroke="orange" points="675.45,-189.86 678.85,-179.82 669.93,-185.55 675.45,-189.86"/>
|
<polygon fill="orange" stroke="orange" points="617.45,-189.86 620.85,-179.82 611.93,-185.55 617.45,-189.86"/>
|
||||||
</g>
|
</g>
|
||||||
<!-- n4->n1 -->
|
<!-- n4->n1 -->
|
||||||
<g id="edge16" class="edge">
|
<g id="edge16" class="edge">
|
||||||
<title>n4->n1</title>
|
<title>n4->n1</title>
|
||||||
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M790.49,-287.87C770.79,-262.9 734.08,-216.35 711.46,-187.68"/>
|
<path fill="none" stroke="orange" stroke-dasharray="5,2" d="M732.49,-287.87C712.79,-262.9 676.08,-216.35 653.46,-187.68"/>
|
||||||
<polygon fill="orange" stroke="orange" points="714.15,-185.43 705.21,-179.75 708.65,-189.77 714.15,-185.43"/>
|
<polygon fill="orange" stroke="orange" points="656.15,-185.43 647.21,-179.75 650.65,-189.77 656.15,-185.43"/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -236,7 +236,7 @@ example.
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
2. [**Native engine**][engine-shared-object], explains what a native engine
|
2. [**Dylib engine**][engine-dylib], explains what a Dylib engine
|
||||||
is, and how to set it up. The example completes itself with the
|
is, and how to set it up. The example completes itself with the
|
||||||
compilation of the Wasm module, its instantiation, and finally, by
|
compilation of the Wasm module, its instantiation, and finally, by
|
||||||
calling an exported function.
|
calling an exported function.
|
||||||
@ -248,7 +248,7 @@ example.
|
|||||||
<summary><em>Execute the example</em></summary>
|
<summary><em>Execute the example</em></summary>
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ cargo run --example engine-shared-object --release --features "cranelift"
|
$ cargo run --example engine-dylib --release --features "cranelift"
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@ -376,7 +376,7 @@ example.
|
|||||||
|
|
||||||
[hello-world]: ./hello_world.rs
|
[hello-world]: ./hello_world.rs
|
||||||
[engine-universal]: ./engine_universal.rs
|
[engine-universal]: ./engine_universal.rs
|
||||||
[engine-shared-object]: ./engine_shared_object.rs
|
[engine-dylib]: ./engine_dylib.rs
|
||||||
[engine-headless]: ./engine_headless.rs
|
[engine-headless]: ./engine_headless.rs
|
||||||
[compiler-singlepass]: ./compiler_singlepass.rs
|
[compiler-singlepass]: ./compiler_singlepass.rs
|
||||||
[compiler-cranelift]: ./compiler_cranelift.rs
|
[compiler-cranelift]: ./compiler_cranelift.rs
|
||||||
|
@ -22,7 +22,7 @@ use std::str::FromStr;
|
|||||||
use wasmer::{wat2wasm, Module, RuntimeError, Store};
|
use wasmer::{wat2wasm, Module, RuntimeError, Store};
|
||||||
use wasmer_compiler::{CpuFeature, Target, Triple};
|
use wasmer_compiler::{CpuFeature, Target, Triple};
|
||||||
use wasmer_compiler_cranelift::Cranelift;
|
use wasmer_compiler_cranelift::Cranelift;
|
||||||
use wasmer_engine_shared_object::SharedObject;
|
use wasmer_engine_dylib::Dylib;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// Let's declare the Wasm module with the text representation.
|
// Let's declare the Wasm module with the text representation.
|
||||||
@ -67,12 +67,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
// Define the engine that will drive everything.
|
// Define the engine that will drive everything.
|
||||||
//
|
//
|
||||||
// In this case, the engine is `wasmer_engine_shared_object` which means
|
// In this case, the engine is `wasmer_engine_dylib` which means
|
||||||
// that a native object is going to be generated.
|
// that a shared object is going to be generated.
|
||||||
//
|
//
|
||||||
// That's where we specify the target for the compiler.
|
// That's where we specify the target for the compiler.
|
||||||
// Use the native engine.
|
//
|
||||||
let engine = Native::new(compiler_config)
|
// Use the Dylib engine.
|
||||||
|
let engine = Dylib::new(compiler_config)
|
||||||
// Here we go.
|
// Here we go.
|
||||||
// Pass the target to the engine! The engine will share
|
// Pass the target to the engine! The engine will share
|
||||||
// this information with the compiler.
|
// this information with the compiler.
|
||||||
|
@ -1,27 +1,26 @@
|
|||||||
//! Defining an engine in Wasmer is one of the fundamental steps.
|
//! Defining an engine in Wasmer is one of the fundamental steps.
|
||||||
//!
|
//!
|
||||||
//! This example illustrates how to use the `wasmer_engine_shared_object`,
|
//! This example illustrates how to use the `wasmer_engine_dylib`,
|
||||||
//! aka the native engine. An engine applies roughly 2 steps:
|
//! aka the Dylib engine. An engine applies roughly 2 steps:
|
||||||
//!
|
//!
|
||||||
//! 1. It compiles the Wasm module bytes to executable code, through
|
//! 1. It compiles the Wasm module bytes to executable code, through
|
||||||
//! the intervention of a compiler,
|
//! the intervention of a compiler,
|
||||||
//! 2. It stores the executable code somewhere.
|
//! 2. It stores the executable code somewhere.
|
||||||
//!
|
//!
|
||||||
//! In the particular context of the native engine, the executable
|
//! In the particular context of the Dylib engine, the executable code
|
||||||
//! code is stored in a native object, more precisely in a dynamic
|
//! is stored in a shared object (`.dylib`, `.so` or `.dll` file).
|
||||||
//! library.
|
|
||||||
//!
|
//!
|
||||||
//! You can run the example directly by executing in Wasmer root:
|
//! You can run the example directly by executing in Wasmer root:
|
||||||
//!
|
//!
|
||||||
//! ```shell
|
//! ```shell
|
||||||
//! cargo run --example engine-shared-object --release --features "cranelift"
|
//! cargo run --example engine-dylib --release --features "cranelift"
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Ready?
|
//! Ready?
|
||||||
|
|
||||||
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
|
||||||
use wasmer_compiler_cranelift::Cranelift;
|
use wasmer_compiler_cranelift::Cranelift;
|
||||||
use wasmer_engine_shared_object::SharedObject;
|
use wasmer_engine_dylib::Dylib;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// Let's declare the Wasm module with the text representation.
|
// Let's declare the Wasm module with the text representation.
|
||||||
@ -45,12 +44,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// compile the Wasm module into executable code.
|
// compile the Wasm module into executable code.
|
||||||
let compiler_config = Cranelift::default();
|
let compiler_config = Cranelift::default();
|
||||||
|
|
||||||
println!("Creating Native engine...");
|
println!("Creating Dylib engine...");
|
||||||
// Define the engine that will drive everything.
|
// Define the engine that will drive everything.
|
||||||
//
|
//
|
||||||
// In this case, the engine is `wasmer_engine_shared_object` which means
|
// In this case, the engine is `wasmer_engine_dylib` which means
|
||||||
// that a native object is going to be generated.
|
// that a shared object is going to be generated.
|
||||||
let engine = Native::new(compiler_config).engine();
|
let engine = Dylib::new(compiler_config).engine();
|
||||||
|
|
||||||
// Create a store, that holds the engine.
|
// Create a store, that holds the engine.
|
||||||
let store = Store::new(&engine);
|
let store = Store::new(&engine);
|
||||||
@ -61,7 +60,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Let's compile the Wasm module. It is at this step that the Wasm
|
// Let's compile the Wasm module. It is at this step that the Wasm
|
||||||
// text is transformed into Wasm bytes (if necessary), and then
|
// text is transformed into Wasm bytes (if necessary), and then
|
||||||
// compiled to executable code by the compiler, which is then
|
// compiled to executable code by the compiler, which is then
|
||||||
// stored into a native object by the engine.
|
// stored into a shared object by the engine.
|
||||||
let module = Module::new(&store, wasm_bytes)?;
|
let module = Module::new(&store, wasm_bytes)?;
|
||||||
|
|
||||||
// Congrats, the Wasm module is compiled! Now let's execute it for
|
// Congrats, the Wasm module is compiled! Now let's execute it for
|
||||||
@ -88,6 +87,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(any(target_arch = "aarch64", target_env = "musl")))]
|
#[cfg(not(any(target_arch = "aarch64", target_env = "musl")))]
|
||||||
fn test_engine_shared_object() -> Result<(), Box<dyn std::error::Error>> {
|
fn test_engine_dylib() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
main()
|
main()
|
||||||
}
|
}
|
@ -8,9 +8,10 @@
|
|||||||
//! What problem does it solve, and what does it mean?
|
//! What problem does it solve, and what does it mean?
|
||||||
//!
|
//!
|
||||||
//! Once a Wasm module is compiled into executable code and stored
|
//! Once a Wasm module is compiled into executable code and stored
|
||||||
//! somewhere (e.g. in memory with the Universal engine, or in a native
|
//! somewhere (e.g. in memory with the Universal engine, or in a
|
||||||
//! shared object file with the native engine), the module can be instantiated and
|
//! shared object file with the Dylib engine), the module can be
|
||||||
//! executed. But imagine for a second the following scenario:
|
//! instantiated and executed. But imagine for a second the following
|
||||||
|
//! scenario:
|
||||||
//!
|
//!
|
||||||
//! * Modules are compiled ahead of time, to be instantiated later
|
//! * Modules are compiled ahead of time, to be instantiated later
|
||||||
//! on.
|
//! on.
|
||||||
@ -52,7 +53,7 @@ use wasmer::Module;
|
|||||||
use wasmer::Store;
|
use wasmer::Store;
|
||||||
use wasmer::Value;
|
use wasmer::Value;
|
||||||
use wasmer_compiler_cranelift::Cranelift;
|
use wasmer_compiler_cranelift::Cranelift;
|
||||||
use wasmer_engine_shared_object::SharedObject;
|
use wasmer_engine_dylib::Dylib;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// First step, let's compile the Wasm module and serialize it.
|
// First step, let's compile the Wasm module and serialize it.
|
||||||
@ -79,16 +80,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// compile the Wasm module into executable code.
|
// compile the Wasm module into executable code.
|
||||||
let compiler_config = Cranelift::default();
|
let compiler_config = Cranelift::default();
|
||||||
|
|
||||||
println!("Creating Native engine...");
|
println!("Creating Dylib engine...");
|
||||||
// Define the engine that will drive everything.
|
// Define the engine that will drive everything.
|
||||||
//
|
//
|
||||||
// In this case, the engine is `wasmer_engine_shared_object` which
|
// In this case, the engine is `wasmer_engine_dylib` which
|
||||||
// means that a native object is going to be generated. So
|
// means that a shared object is going to be generated. So
|
||||||
// when we are going to serialize the compiled Wasm module, we
|
// when we are going to serialize the compiled Wasm module, we
|
||||||
// are going to store it in a file with the `.so` extension
|
// are going to store it in a file with the `.so` extension
|
||||||
// for example (or `.dylib`, or `.dll` depending of the
|
// for example (or `.dylib`, or `.dll` depending of the
|
||||||
// platform).
|
// platform).
|
||||||
let engine = Native::new(compiler_config).engine();
|
let engine = Dylib::new(compiler_config).engine();
|
||||||
|
|
||||||
// Create a store, that holds the engine.
|
// Create a store, that holds the engine.
|
||||||
let store = Store::new(&engine);
|
let store = Store::new(&engine);
|
||||||
@ -109,9 +110,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Second step, deserialize the compiled Wasm module, and execute
|
// Second step, deserialize the compiled Wasm module, and execute
|
||||||
// it, for example with Wasmer without a compiler.
|
// it, for example with Wasmer without a compiler.
|
||||||
{
|
{
|
||||||
println!("Creating headless Native engine...");
|
println!("Creating headless Dylib engine...");
|
||||||
// We create a headless Native engine.
|
// We create a headless Dylib engine.
|
||||||
let engine = Native::headless().engine();
|
let engine = Dylib::headless().engine();
|
||||||
let store = Store::new(&engine);
|
let store = Store::new(&engine);
|
||||||
|
|
||||||
println!("Deserializing module...");
|
println!("Deserializing module...");
|
||||||
|
@ -17,7 +17,7 @@ wasmer-compiler-cranelift = { path = "../lib/compiler-cranelift", optional = tru
|
|||||||
wasmer-compiler-llvm = { path = "../lib/compiler-llvm", optional = true }
|
wasmer-compiler-llvm = { path = "../lib/compiler-llvm", optional = true }
|
||||||
wasmer-compiler-singlepass = { path = "../lib/compiler-singlepass", optional = true }
|
wasmer-compiler-singlepass = { path = "../lib/compiler-singlepass", optional = true }
|
||||||
wasmer-engine-universal = { path = "../lib/engine-universal", optional = true }
|
wasmer-engine-universal = { path = "../lib/engine-universal", optional = true }
|
||||||
wasmer-engine-shared-object = { path = "../lib/engine-shared-object", optional = true }
|
wasmer-engine-dylib = { path = "../lib/engine-dylib", optional = true }
|
||||||
wasmer-middlewares = { path = "../lib/middlewares" }
|
wasmer-middlewares = { path = "../lib/middlewares" }
|
||||||
wasmprinter = "0.2"
|
wasmprinter = "0.2"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ cranelift = [ "wasmer-compiler-cranelift" ]
|
|||||||
llvm = [ "wasmer-compiler-llvm" ]
|
llvm = [ "wasmer-compiler-llvm" ]
|
||||||
singlepass = [ "wasmer-compiler-singlepass" ]
|
singlepass = [ "wasmer-compiler-singlepass" ]
|
||||||
universal = [ "wasmer-engine-universal" ]
|
universal = [ "wasmer-engine-universal" ]
|
||||||
shared-object = [ "wasmer-engine-shared-object" ]
|
dylib = [ "wasmer-engine-dylib" ]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "equivalence_universal"
|
name = "equivalence_universal"
|
||||||
@ -54,6 +54,6 @@ path = "fuzz_targets/metering.rs"
|
|||||||
required-features = ["universal", "cranelift"]
|
required-features = ["universal", "cranelift"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "shared_object_cranelift"
|
name = "dylib_cranelift"
|
||||||
path = "fuzz_targets/shared_object_cranelift.rs"
|
path = "fuzz_targets/dylib_cranelift.rs"
|
||||||
required-features = ["shared-object", "cranelift"]
|
required-features = ["dylib", "cranelift"]
|
||||||
|
@ -13,7 +13,7 @@ $ cargo install cargo-fuzz
|
|||||||
`cargo-fuzz` is documented in the [Rust Fuzz
|
`cargo-fuzz` is documented in the [Rust Fuzz
|
||||||
Book](https://rust-fuzz.github.io/book/cargo-fuzz.html).
|
Book](https://rust-fuzz.github.io/book/cargo-fuzz.html).
|
||||||
|
|
||||||
## Running a fuzzer (`validate`, `universal_llvm`, `shared_object_cranelift`…)
|
## Running a fuzzer (`validate`, `universal_llvm`, `dylib_cranelift`…)
|
||||||
|
|
||||||
Once `cargo-fuzz` is installed, you can run the `validate` fuzzer with
|
Once `cargo-fuzz` is installed, you can run the `validate` fuzzer with
|
||||||
```sh
|
```sh
|
||||||
|
@ -4,7 +4,7 @@ use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
|
|||||||
use wasm_smith::{Config, ConfiguredModule};
|
use wasm_smith::{Config, ConfiguredModule};
|
||||||
use wasmer::{imports, Instance, Module, Store};
|
use wasmer::{imports, Instance, Module, Store};
|
||||||
use wasmer_compiler_cranelift::Cranelift;
|
use wasmer_compiler_cranelift::Cranelift;
|
||||||
use wasmer_engine_shared_object::SharedObject;
|
use wasmer_engine_dylib::Dylib;
|
||||||
|
|
||||||
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
|
||||||
struct NoImportsConfig;
|
struct NoImportsConfig;
|
||||||
@ -41,12 +41,12 @@ fuzz_target!(|module: WasmSmithModule| {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let compiler = Cranelift::default();
|
let compiler = Cranelift::default();
|
||||||
let store = Store::new(&SharedObject::new(compiler).engine());
|
let store = Store::new(&Dylib::new(compiler).engine());
|
||||||
let module = Module::new(&store, &wasm_bytes).unwrap();
|
let module = Module::new(&store, &wasm_bytes).unwrap();
|
||||||
module.serialize().unwrap()
|
module.serialize().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let engine = SharedObject::headless().engine();
|
let engine = Dylib::headless().engine();
|
||||||
let store = Store::new(&engine);
|
let store = Store::new(&engine);
|
||||||
let module = unsafe { Module::deserialize(&store, serialized.as_slice()) }.unwrap();
|
let module = unsafe { Module::deserialize(&store, serialized.as_slice()) }.unwrap();
|
||||||
match Instance::new(&module, &imports! {}) {
|
match Instance::new(&module, &imports! {}) {
|
@ -19,7 +19,7 @@ wasmer-compiler = { path = "../compiler", version = "1.0.2" }
|
|||||||
wasmer-derive = { path = "../derive", version = "1.0.2" }
|
wasmer-derive = { path = "../derive", version = "1.0.2" }
|
||||||
wasmer-engine = { path = "../engine", version = "1.0.2" }
|
wasmer-engine = { path = "../engine", version = "1.0.2" }
|
||||||
wasmer-engine-universal = { path = "../engine-universal", version = "1.0.2", optional = true }
|
wasmer-engine-universal = { path = "../engine-universal", version = "1.0.2", optional = true }
|
||||||
wasmer-engine-shared-object = { path = "../engine-shared-object", version = "1.0.2", optional = true }
|
wasmer-engine-dylib = { path = "../engine-dylib", version = "1.0.2", optional = true }
|
||||||
wasmer-types = { path = "../types", version = "1.0.2" }
|
wasmer-types = { path = "../types", version = "1.0.2" }
|
||||||
indexmap = { version = "1.6", features = ["serde-1"] }
|
indexmap = { version = "1.6", features = ["serde-1"] }
|
||||||
cfg-if = "1.0"
|
cfg-if = "1.0"
|
||||||
@ -47,15 +47,15 @@ default = ["wat", "default-cranelift", "default-universal"]
|
|||||||
compiler = [
|
compiler = [
|
||||||
"wasmer-compiler/translator",
|
"wasmer-compiler/translator",
|
||||||
"wasmer-engine-universal/compiler",
|
"wasmer-engine-universal/compiler",
|
||||||
"wasmer-engine-shared-object/compiler",
|
"wasmer-engine-dylib/compiler",
|
||||||
]
|
]
|
||||||
engine = []
|
engine = []
|
||||||
universal = [
|
universal = [
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"engine"
|
"engine"
|
||||||
]
|
]
|
||||||
shared-object = [
|
dylib = [
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"engine"
|
"engine"
|
||||||
]
|
]
|
||||||
singlepass = [
|
singlepass = [
|
||||||
@ -91,8 +91,8 @@ default-universal = [
|
|||||||
"universal",
|
"universal",
|
||||||
"default-engine"
|
"default-engine"
|
||||||
]
|
]
|
||||||
default-shared-object = [
|
default-dylib = [
|
||||||
"shared-object",
|
"dylib",
|
||||||
"default-engine"
|
"default-engine"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@
|
|||||||
//! [wasmer-emscripten]: https://docs.rs/wasmer-emscripten/*/wasmer_emscripten/
|
//! [wasmer-emscripten]: https://docs.rs/wasmer-emscripten/*/wasmer_emscripten/
|
||||||
//! [wasmer-engine]: https://docs.rs/wasmer-engine/*/wasmer_engine/
|
//! [wasmer-engine]: https://docs.rs/wasmer-engine/*/wasmer_engine/
|
||||||
//! [wasmer-universal]: https://docs.rs/wasmer-engine-universal/*/wasmer_engine_universal/
|
//! [wasmer-universal]: https://docs.rs/wasmer-engine-universal/*/wasmer_engine_universal/
|
||||||
//! [wasmer-native]: https://docs.rs/wasmer-engine-shared-object/*/wasmer_engine_shared_object/
|
//! [wasmer-native]: https://docs.rs/wasmer-engine-dylib/*/wasmer_engine_dylib/
|
||||||
//! [wasmer-singlepass]: https://docs.rs/wasmer-compiler-singlepass/*/wasmer_compiler_singlepass/
|
//! [wasmer-singlepass]: https://docs.rs/wasmer-compiler-singlepass/*/wasmer_compiler_singlepass/
|
||||||
//! [wasmer-llvm]: https://docs.rs/wasmer-compiler-llvm/*/wasmer_compiler_llvm/
|
//! [wasmer-llvm]: https://docs.rs/wasmer-compiler-llvm/*/wasmer_compiler_llvm/
|
||||||
//! [wasmer-wasi]: https://docs.rs/wasmer-wasi/*/wasmer_wasi/
|
//! [wasmer-wasi]: https://docs.rs/wasmer-wasi/*/wasmer_wasi/
|
||||||
@ -367,8 +367,8 @@ pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM};
|
|||||||
#[cfg(feature = "universal")]
|
#[cfg(feature = "universal")]
|
||||||
pub use wasmer_engine_universal::{Universal, UniversalArtifact, UniversalEngine};
|
pub use wasmer_engine_universal::{Universal, UniversalArtifact, UniversalEngine};
|
||||||
|
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
pub use wasmer_engine_shared_object::{SharedObject, SharedObjectArtifact, SharedObjectEngine};
|
pub use wasmer_engine_dylib::{Dylib, DylibArtifact, DylibEngine};
|
||||||
|
|
||||||
/// Version number of this crate.
|
/// Version number of this crate.
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
@ -130,7 +130,7 @@ impl Default for Store {
|
|||||||
wasmer_engine_universal::Universal::new(config)
|
wasmer_engine_universal::Universal::new(config)
|
||||||
.engine()
|
.engine()
|
||||||
} else if #[cfg(feature = "default-native")] {
|
} else if #[cfg(feature = "default-native")] {
|
||||||
wasmer_engine_shared_object::SharedObject::new(config)
|
wasmer_engine_dylib::Dylib::new(config)
|
||||||
.engine()
|
.engine()
|
||||||
} else {
|
} else {
|
||||||
compile_error!("No default engine chosen")
|
compile_error!("No default engine chosen")
|
||||||
|
@ -22,7 +22,7 @@ wasmer-compiler-llvm = { version = "1.0.2", path = "../compiler-llvm", optional
|
|||||||
wasmer-emscripten = { version = "1.0.2", path = "../emscripten", optional = true }
|
wasmer-emscripten = { version = "1.0.2", path = "../emscripten", optional = true }
|
||||||
wasmer-engine = { version = "1.0.2", path = "../engine" }
|
wasmer-engine = { version = "1.0.2", path = "../engine" }
|
||||||
wasmer-engine-universal = { version = "1.0.2", path = "../engine-universal", optional = true }
|
wasmer-engine-universal = { version = "1.0.2", path = "../engine-universal", optional = true }
|
||||||
wasmer-engine-shared-object = { version = "1.0.2", path = "../engine-shared-object", optional = true }
|
wasmer-engine-dylib = { version = "1.0.2", path = "../engine-dylib", optional = true }
|
||||||
wasmer-engine-object-file = { version = "1.0.2", path = "../engine-object-file", optional = true }
|
wasmer-engine-object-file = { version = "1.0.2", path = "../engine-object-file", optional = true }
|
||||||
wasmer-middlewares = { version = "1.0.2", path = "../middlewares", optional = true }
|
wasmer-middlewares = { version = "1.0.2", path = "../middlewares", optional = true }
|
||||||
wasmer-wasi = { version = "1.0.2", path = "../wasi", optional = true }
|
wasmer-wasi = { version = "1.0.2", path = "../wasi", optional = true }
|
||||||
@ -59,8 +59,8 @@ universal = [
|
|||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"engine",
|
"engine",
|
||||||
]
|
]
|
||||||
shared-object = [
|
dylib = [
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"engine",
|
"engine",
|
||||||
]
|
]
|
||||||
object-file = [
|
object-file = [
|
||||||
@ -70,7 +70,7 @@ object-file = [
|
|||||||
compiler = [
|
compiler = [
|
||||||
"wasmer/compiler",
|
"wasmer/compiler",
|
||||||
"wasmer-engine-universal/compiler",
|
"wasmer-engine-universal/compiler",
|
||||||
"wasmer-engine-shared-object/compiler",
|
"wasmer-engine-dylib/compiler",
|
||||||
"wasmer-engine-object-file/compiler"
|
"wasmer-engine-object-file/compiler"
|
||||||
]
|
]
|
||||||
singlepass = [
|
singlepass = [
|
||||||
|
@ -12,10 +12,10 @@ use crate::error::{update_last_error, CApiError};
|
|||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmer::Engine;
|
use wasmer::Engine;
|
||||||
|
#[cfg(feature = "dylib")]
|
||||||
|
use wasmer_engine_dylib::Dylib;
|
||||||
#[cfg(feature = "object-file")]
|
#[cfg(feature = "object-file")]
|
||||||
use wasmer_engine_object_file::ObjectFile;
|
use wasmer_engine_object_file::ObjectFile;
|
||||||
#[cfg(feature = "shared-object")]
|
|
||||||
use wasmer_engine_shared_object::SharedObject;
|
|
||||||
#[cfg(feature = "universal")]
|
#[cfg(feature = "universal")]
|
||||||
use wasmer_engine_universal::Universal;
|
use wasmer_engine_universal::Universal;
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ pub enum wasmer_engine_t {
|
|||||||
/// [`wasmer_engine_universal`] Rust crate.
|
/// [`wasmer_engine_universal`] Rust crate.
|
||||||
UNIVERSAL = 0,
|
UNIVERSAL = 0,
|
||||||
|
|
||||||
/// Variant to represent the Shared Object engine. See the
|
/// Variant to represent the Dylib engine. See the
|
||||||
/// [`wasmer_engine_shared_object`] Rust crate.
|
/// [`wasmer_engine_dylib`] Rust crate.
|
||||||
SHARED_OBJECT = 1,
|
DYLIB = 1,
|
||||||
|
|
||||||
/// Variant to represent the Object File engine. See the
|
/// Variant to represent the Object File engine. See the
|
||||||
/// [`wasmer_engine_object_file`] Rust crate.
|
/// [`wasmer_engine_object_file`] Rust crate.
|
||||||
@ -83,8 +83,8 @@ impl Default for wasmer_engine_t {
|
|||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(feature = "universal")] {
|
if #[cfg(feature = "universal")] {
|
||||||
Self::UNIVERSAL
|
Self::UNIVERSAL
|
||||||
} else if #[cfg(feature = "shared-object")] {
|
} else if #[cfg(feature = "dylib")] {
|
||||||
Self::SHARED_OBJECT
|
Self::DYLIB
|
||||||
} else if #[cfg(feature = "object-file")] {
|
} else if #[cfg(feature = "object-file")] {
|
||||||
Self::OBJECT_FILE
|
Self::OBJECT_FILE
|
||||||
} else {
|
} else {
|
||||||
@ -249,9 +249,9 @@ pub extern "C" fn wasm_config_set_compiler(
|
|||||||
/// if (wasmer_is_engine_available(UNIVERSAL)) {
|
/// if (wasmer_is_engine_available(UNIVERSAL)) {
|
||||||
/// wasm_config_set_engine(config, UNIVERSAL);
|
/// wasm_config_set_engine(config, UNIVERSAL);
|
||||||
/// }
|
/// }
|
||||||
/// // Or maybe the Shared Object engine?
|
/// // Or maybe the Dylib engine?
|
||||||
/// else if (wasmer_is_engine_available(SHARED_OBJECT)) {
|
/// else if (wasmer_is_engine_available(DYLIB)) {
|
||||||
/// wasm_config_set_engine(config, SHARED_OBJECT);
|
/// wasm_config_set_engine(config, DYLIB);
|
||||||
/// }
|
/// }
|
||||||
/// // OK, let's do not specify any particular engine.
|
/// // OK, let's do not specify any particular engine.
|
||||||
///
|
///
|
||||||
@ -330,8 +330,8 @@ cfg_if! {
|
|||||||
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(Universal::headless().engine());
|
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(Universal::headless().engine());
|
||||||
Box::new(wasm_engine_t { inner: engine })
|
Box::new(wasm_engine_t { inner: engine })
|
||||||
}
|
}
|
||||||
} else if #[cfg(all(feature = "shared-object", feature = "compiler"))] {
|
} else if #[cfg(all(feature = "dylib", feature = "compiler"))] {
|
||||||
/// Creates a new shared object engine with the default compiler.
|
/// Creates a new Dylib engine with the default compiler.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
@ -341,11 +341,11 @@ cfg_if! {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||||
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
|
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
|
||||||
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(SharedObject::new(compiler_config).engine());
|
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(Dylib::new(compiler_config).engine());
|
||||||
Box::new(wasm_engine_t { inner: engine })
|
Box::new(wasm_engine_t { inner: engine })
|
||||||
}
|
}
|
||||||
} else if #[cfg(feature = "shared-object")] {
|
} else if #[cfg(feature = "dylib")] {
|
||||||
/// Creates a new headless shared object engine.
|
/// Creates a new headless Dylib engine.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
@ -354,7 +354,7 @@ cfg_if! {
|
|||||||
/// cbindgen:ignore
|
/// cbindgen:ignore
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
|
||||||
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(SharedObject::headless().engine());
|
let engine: Arc<dyn Engine + Send + Sync> = Arc::new(Dylib::headless().engine());
|
||||||
Box::new(wasm_engine_t { inner: engine })
|
Box::new(wasm_engine_t { inner: engine })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,10 +502,10 @@ pub extern "C" fn wasm_engine_new_with_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
wasmer_engine_t::SHARED_OBJECT => {
|
wasmer_engine_t::DYLIB => {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(feature = "shared-object")] {
|
if #[cfg(feature = "dylib")] {
|
||||||
let mut builder = SharedObject::new(compiler_config);
|
let mut builder = Dylib::new(compiler_config);
|
||||||
|
|
||||||
if let Some(target) = config.target {
|
if let Some(target) = config.target {
|
||||||
builder = builder.target(target.inner);
|
builder = builder.target(target.inner);
|
||||||
@ -517,7 +517,7 @@ pub extern "C" fn wasm_engine_new_with_config(
|
|||||||
|
|
||||||
Arc::new(builder.engine())
|
Arc::new(builder.engine())
|
||||||
} else {
|
} else {
|
||||||
return return_with_error("Wasmer has not been compiled with the `shared-object` feature.");
|
return return_with_error("Wasmer has not been compiled with the `dylib` feature.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -565,10 +565,10 @@ pub extern "C" fn wasm_engine_new_with_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
wasmer_engine_t::SHARED_OBJECT => {
|
wasmer_engine_t::DYLIB => {
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(feature = "shared-object")] {
|
if #[cfg(feature = "dylib")] {
|
||||||
let mut builder = SharedObject::headless();
|
let mut builder = Dylib::headless();
|
||||||
|
|
||||||
if let Some(target) = config.target {
|
if let Some(target) = config.target {
|
||||||
builder = builder.target(target.inner);
|
builder = builder.target(target.inner);
|
||||||
@ -580,7 +580,7 @@ pub extern "C" fn wasm_engine_new_with_config(
|
|||||||
|
|
||||||
Arc::new(builder.engine())
|
Arc::new(builder.engine())
|
||||||
} else {
|
} else {
|
||||||
return return_with_error("Wasmer has not been compiled with the `shared-object` feature.");
|
return return_with_error("Wasmer has not been compiled with the `dylib` feature.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -120,7 +120,7 @@ pub extern "C" fn wasmer_is_headless() -> bool {
|
|||||||
pub extern "C" fn wasmer_is_engine_available(engine: wasmer_engine_t) -> bool {
|
pub extern "C" fn wasmer_is_engine_available(engine: wasmer_engine_t) -> bool {
|
||||||
match engine {
|
match engine {
|
||||||
wasmer_engine_t::UNIVERSAL if cfg!(feature = "universal") => true,
|
wasmer_engine_t::UNIVERSAL if cfg!(feature = "universal") => true,
|
||||||
wasmer_engine_t::SHARED_OBJECT if cfg!(feature = "shared-object") => true,
|
wasmer_engine_t::DYLIB if cfg!(feature = "dylib") => true,
|
||||||
wasmer_engine_t::OBJECT_FILE if cfg!(feature = "object-file") => true,
|
wasmer_engine_t::OBJECT_FILE if cfg!(feature = "object-file") => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
@ -202,14 +202,7 @@ mod tests {
|
|||||||
"0"
|
"0"
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
set_var(
|
set_var("DYLIB", if cfg!(feature = "dylib") { "1" } else { "0" });
|
||||||
"SHARED_OBJECT",
|
|
||||||
if cfg!(feature = "shared-object") {
|
|
||||||
"1"
|
|
||||||
} else {
|
|
||||||
"0"
|
|
||||||
},
|
|
||||||
);
|
|
||||||
set_var(
|
set_var(
|
||||||
"OBJECT_FILE",
|
"OBJECT_FILE",
|
||||||
if cfg!(feature = "object-file") {
|
if cfg!(feature = "object-file") {
|
||||||
@ -225,7 +218,7 @@ mod tests {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
assert(wasmer_is_engine_available(UNIVERSAL) == (getenv("UNIVERSAL")[0] == '1'));
|
assert(wasmer_is_engine_available(UNIVERSAL) == (getenv("UNIVERSAL")[0] == '1'));
|
||||||
assert(wasmer_is_engine_available(SHARED_OBJECT) == (getenv("SHARED_OBJECT")[0] == '1'));
|
assert(wasmer_is_engine_available(DYLIB) == (getenv("DYLIB")[0] == '1'));
|
||||||
assert(wasmer_is_engine_available(OBJECT_FILE) == (getenv("OBJECT_FILE")[0] == '1'));
|
assert(wasmer_is_engine_available(OBJECT_FILE) == (getenv("OBJECT_FILE")[0] == '1'));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -234,7 +227,7 @@ mod tests {
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
remove_var("UNIVERSAL");
|
remove_var("UNIVERSAL");
|
||||||
remove_var("SHARED_OBJECT");
|
remove_var("DYLIB");
|
||||||
remove_var("OBJECT_FILE");
|
remove_var("OBJECT_FILE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ wasm_engine_t *wasm_engine_new() {
|
|||||||
if (strcmp(wasmer_test_engine, "universal") == 0) {
|
if (strcmp(wasmer_test_engine, "universal") == 0) {
|
||||||
assert(wasmer_is_engine_available(UNIVERSAL));
|
assert(wasmer_is_engine_available(UNIVERSAL));
|
||||||
wasm_config_set_engine(config, UNIVERSAL);
|
wasm_config_set_engine(config, UNIVERSAL);
|
||||||
} else if (strcmp(wasmer_test_engine, "shared-object") == 0) {
|
} else if (strcmp(wasmer_test_engine, "dylib") == 0) {
|
||||||
assert(wasmer_is_engine_available(SHARED_OBJECT));
|
assert(wasmer_is_engine_available(DYLIB));
|
||||||
wasm_config_set_engine(config, SHARED_OBJECT);
|
wasm_config_set_engine(config, DYLIB);
|
||||||
} else if (wasmer_test_engine) {
|
} else if (wasmer_test_engine) {
|
||||||
printf("Engine %s not recognized\n", wasmer_test_engine);
|
printf("Engine %s not recognized\n", wasmer_test_engine);
|
||||||
abort();
|
abort();
|
||||||
|
@ -125,7 +125,7 @@ typedef enum wasmer_compiler_t {
|
|||||||
|
|
||||||
typedef enum wasmer_engine_t {
|
typedef enum wasmer_engine_t {
|
||||||
UNIVERSAL = 0,
|
UNIVERSAL = 0,
|
||||||
SHARED_OBJECT = 1,
|
DYLIB = 1,
|
||||||
OBJECT_FILE = 2,
|
OBJECT_FILE = 2,
|
||||||
} wasmer_engine_t;
|
} wasmer_engine_t;
|
||||||
|
|
||||||
|
2
lib/cache/Cargo.toml
vendored
2
lib/cache/Cargo.toml
vendored
@ -22,7 +22,7 @@ tempfile = "3"
|
|||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "1.0.2" }
|
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "1.0.2" }
|
||||||
wasmer-engine-universal = { path = "../engine-universal", version = "1.0.2" }
|
wasmer-engine-universal = { path = "../engine-universal", version = "1.0.2" }
|
||||||
wasmer-engine-shared-object = { path = "../engine-shared-object", version = "1.0.2" }
|
wasmer-engine-dylib = { path = "../engine-dylib", version = "1.0.2" }
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_filesystem_cache"
|
name = "bench_filesystem_cache"
|
||||||
|
2
lib/cache/benches/bench_filesystem_cache.rs
vendored
2
lib/cache/benches/bench_filesystem_cache.rs
vendored
@ -6,7 +6,7 @@ use wasmer::{Module, Store};
|
|||||||
use wasmer_cache::Cache;
|
use wasmer_cache::Cache;
|
||||||
use wasmer_cache::{FileSystemCache, Hash};
|
use wasmer_cache::{FileSystemCache, Hash};
|
||||||
use wasmer_compiler_singlepass::Singlepass;
|
use wasmer_compiler_singlepass::Singlepass;
|
||||||
use wasmer_engine_shared_object::SharedObject;
|
use wasmer_engine_dylib::Dylib;
|
||||||
use wasmer_engine_universal::Universal;
|
use wasmer_engine_universal::Universal;
|
||||||
|
|
||||||
fn random_key() -> Hash {
|
fn random_key() -> Hash {
|
||||||
|
@ -32,7 +32,7 @@ wasmer-compiler-llvm = { version = "1.0.2", path = "../compiler-llvm", optional
|
|||||||
wasmer-emscripten = { version = "1.0.2", path = "../emscripten", optional = true }
|
wasmer-emscripten = { version = "1.0.2", path = "../emscripten", optional = true }
|
||||||
wasmer-engine = { version = "1.0.2", path = "../engine" }
|
wasmer-engine = { version = "1.0.2", path = "../engine" }
|
||||||
wasmer-engine-universal = { version = "1.0.2", path = "../engine-universal", optional = true }
|
wasmer-engine-universal = { version = "1.0.2", path = "../engine-universal", optional = true }
|
||||||
wasmer-engine-shared-object = { version = "1.0.2", path = "../engine-shared-object", optional = true }
|
wasmer-engine-dylib = { version = "1.0.2", path = "../engine-dylib", optional = true }
|
||||||
wasmer-engine-object-file = { version = "1.0.2", path = "../engine-object-file", optional = true }
|
wasmer-engine-object-file = { version = "1.0.2", path = "../engine-object-file", optional = true }
|
||||||
wasmer-vm = { version = "1.0.2", path = "../vm" }
|
wasmer-vm = { version = "1.0.2", path = "../vm" }
|
||||||
wasmer-wasi = { version = "1.0.2", path = "../wasi", default-features = false, optional = true }
|
wasmer-wasi = { version = "1.0.2", path = "../wasi", default-features = false, optional = true }
|
||||||
@ -61,7 +61,7 @@ default = [
|
|||||||
"wat",
|
"wat",
|
||||||
"wast",
|
"wast",
|
||||||
"universal",
|
"universal",
|
||||||
"shared-object",
|
"dylib",
|
||||||
"object-file",
|
"object-file",
|
||||||
"cache",
|
"cache",
|
||||||
"wasi",
|
"wasi",
|
||||||
@ -72,8 +72,8 @@ universal = [
|
|||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"engine",
|
"engine",
|
||||||
]
|
]
|
||||||
shared-object = [
|
dylib = [
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"engine",
|
"engine",
|
||||||
]
|
]
|
||||||
object-file = [
|
object-file = [
|
||||||
@ -88,7 +88,7 @@ wat = ["wasmer/wat"]
|
|||||||
compiler = [
|
compiler = [
|
||||||
"wasmer-compiler/translator",
|
"wasmer-compiler/translator",
|
||||||
"wasmer-engine-universal/compiler",
|
"wasmer-engine-universal/compiler",
|
||||||
"wasmer-engine-shared-object/compiler",
|
"wasmer-engine-dylib/compiler",
|
||||||
"wasmer-engine-object-file/compiler",
|
"wasmer-engine-object-file/compiler",
|
||||||
]
|
]
|
||||||
experimental-io-devices = [
|
experimental-io-devices = [
|
||||||
@ -110,4 +110,4 @@ llvm = [
|
|||||||
debug = ["fern", "log", "wasmer-wasi/logging"]
|
debug = ["fern", "log", "wasmer-wasi/logging"]
|
||||||
disable-all-logging = ["wasmer-wasi/disable-all-logging"]
|
disable-all-logging = ["wasmer-wasi/disable-all-logging"]
|
||||||
headless = []
|
headless = []
|
||||||
headless-minimal = ["headless", "disable-all-logging", "wasi", "shared-object", "universal"]
|
headless-minimal = ["headless", "disable-all-logging", "wasi", "dylib", "universal"]
|
||||||
|
@ -26,7 +26,7 @@ The Wasmer supports the following features:
|
|||||||
* `wat` (default): support for executing WebAssembly text files.
|
* `wat` (default): support for executing WebAssembly text files.
|
||||||
* `wast`(default): support for running wast test files.
|
* `wast`(default): support for running wast test files.
|
||||||
* `universal` (default): support for the [Universal engine].
|
* `universal` (default): support for the [Universal engine].
|
||||||
* `shared-object` (default): support for the [Shared Object engine].
|
* `dylib` (default): support for the [Dylib engine].
|
||||||
* `cache` (default): support or automatically caching compiled artifacts.
|
* `cache` (default): support or automatically caching compiled artifacts.
|
||||||
* `wasi` (default): support for [WASI].
|
* `wasi` (default): support for [WASI].
|
||||||
* `experimental-io-devices`: support for experimental IO devices in WASI.
|
* `experimental-io-devices`: support for experimental IO devices in WASI.
|
||||||
@ -36,7 +36,7 @@ The Wasmer supports the following features:
|
|||||||
* `llvm`: support for the [LLVM compiler].
|
* `llvm`: support for the [LLVM compiler].
|
||||||
|
|
||||||
[Universal engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal/
|
[Universal engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal/
|
||||||
[Shared Object engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-shared-object/
|
[Dylib engine]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-dylib/
|
||||||
[WASI]: https://github.com/wasmerio/wasmer/tree/master/lib/wasi/
|
[WASI]: https://github.com/wasmerio/wasmer/tree/master/lib/wasi/
|
||||||
[Emscripten]: https://github.com/wasmerio/wasmer/tree/master/lib/emscripten/
|
[Emscripten]: https://github.com/wasmerio/wasmer/tree/master/lib/emscripten/
|
||||||
[Singlepass compiler]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler-singlepass/
|
[Singlepass compiler]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler-singlepass/
|
||||||
@ -62,7 +62,7 @@ wasmer run myfile.wasm
|
|||||||
Compile a WebAssembly file:
|
Compile a WebAssembly file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wasmer compile myfile.wasm -o myfile.so --shared-object
|
wasmer compile myfile.wasm -o myfile.so --dylib
|
||||||
```
|
```
|
||||||
|
|
||||||
Run a compiled WebAssembly file (fastest):
|
Run a compiled WebAssembly file (fastest):
|
||||||
|
@ -43,11 +43,9 @@ impl Compile {
|
|||||||
target_triple: &Triple,
|
target_triple: &Triple,
|
||||||
) -> Result<&'static str> {
|
) -> Result<&'static str> {
|
||||||
Ok(match engine_type {
|
Ok(match engine_type {
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
EngineType::SharedObject => {
|
EngineType::Dylib => {
|
||||||
wasmer_engine_shared_object::SharedObjectArtifact::get_default_extension(
|
wasmer_engine_dylib::DylibArtifact::get_default_extension(target_triple)
|
||||||
target_triple,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
#[cfg(feature = "universal")]
|
#[cfg(feature = "universal")]
|
||||||
EngineType::Universal => {
|
EngineType::Universal => {
|
||||||
@ -57,11 +55,7 @@ impl Compile {
|
|||||||
EngineType::ObjectFile => {
|
EngineType::ObjectFile => {
|
||||||
wasmer_engine_object_file::ObjectFileArtifact::get_default_extension(target_triple)
|
wasmer_engine_object_file::ObjectFileArtifact::get_default_extension(target_triple)
|
||||||
}
|
}
|
||||||
#[cfg(not(all(
|
#[cfg(not(all(feature = "dylib", feature = "universal", feature = "object-file")))]
|
||||||
feature = "shared-object",
|
|
||||||
feature = "universal",
|
|
||||||
feature = "object-file"
|
|
||||||
)))]
|
|
||||||
_ => bail!("selected engine type is not compiled in"),
|
_ => bail!("selected engine type is not compiled in"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -205,10 +205,10 @@ impl Run {
|
|||||||
|
|
||||||
fn get_module(&self) -> Result<Module> {
|
fn get_module(&self) -> Result<Module> {
|
||||||
let contents = std::fs::read(self.path.clone())?;
|
let contents = std::fs::read(self.path.clone())?;
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
{
|
{
|
||||||
if wasmer_engine_shared_object::SharedObjectArtifact::is_deserializable(&contents) {
|
if wasmer_engine_dylib::DylibArtifact::is_deserializable(&contents) {
|
||||||
let engine = wasmer_engine_shared_object::SharedObject::headless().engine();
|
let engine = wasmer_engine_dylib::Dylib::headless().engine();
|
||||||
let store = Store::new(&engine);
|
let store = Store::new(&engine);
|
||||||
let module = unsafe { Module::deserialize_from_file(&store, &self.path)? };
|
let module = unsafe { Module::deserialize_from_file(&store, &self.path)? };
|
||||||
return Ok(module);
|
return Ok(module);
|
||||||
@ -296,18 +296,15 @@ impl Run {
|
|||||||
cache_dir_root.push(compiler_type.to_string());
|
cache_dir_root.push(compiler_type.to_string());
|
||||||
let mut cache = FileSystemCache::new(cache_dir_root)?;
|
let mut cache = FileSystemCache::new(cache_dir_root)?;
|
||||||
|
|
||||||
// Important: Shared object files need to have a `.dll`
|
// Important: Dylib files need to have a `.dll` extension on
|
||||||
// extension on Windows, otherwise they will not load, so we
|
// Windows, otherwise they will not load, so we just add an
|
||||||
// just add an extension always to make it easier to recognize
|
// extension always to make it easier to recognize as well.
|
||||||
// as well.
|
|
||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
let extension = match *engine_type {
|
let extension = match *engine_type {
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
EngineType::SharedObject => {
|
EngineType::Dylib => {
|
||||||
wasmer_engine_shared_object::SharedObjectArtifact::get_default_extension(
|
wasmer_engine_dylib::DylibArtifact::get_default_extension(&Triple::host())
|
||||||
&Triple::host(),
|
.to_string()
|
||||||
)
|
|
||||||
.to_string()
|
|
||||||
}
|
}
|
||||||
#[cfg(feature = "universal")]
|
#[cfg(feature = "universal")]
|
||||||
EngineType::Universal => {
|
EngineType::Universal => {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#[derive(Debug, Clap, Clone)]
|
#[derive(Debug, Clap, Clone)]
|
||||||
/// LLVM backend flags.
|
/// LLVM backend flags.
|
||||||
pub struct LLVMCLIOptions {
|
pub struct LLVMCLIOptions {
|
||||||
@ -15,7 +14,6 @@ pub struct LLVMCLIOptions {
|
|||||||
obj_file: Option<PathBuf>,
|
obj_file: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl LLVMCallbacks for LLVMCLIOptions {
|
impl LLVMCallbacks for LLVMCLIOptions {
|
||||||
fn preopt_ir_callback(&mut self, module: &InkwellModule) {
|
fn preopt_ir_callback(&mut self, module: &InkwellModule) {
|
||||||
if let Some(filename) = &self.pre_opt_ir {
|
if let Some(filename) = &self.pre_opt_ir {
|
||||||
|
@ -20,15 +20,15 @@ pub struct StoreOptions {
|
|||||||
compiler: CompilerOptions,
|
compiler: CompilerOptions,
|
||||||
|
|
||||||
/// Use the Universal Engine.
|
/// Use the Universal Engine.
|
||||||
#[clap(long, conflicts_with_all = &["shared-object", "object-file"])]
|
#[clap(long, conflicts_with_all = &["dylib", "object-file"])]
|
||||||
universal: bool,
|
universal: bool,
|
||||||
|
|
||||||
/// Use the Shared Object Engine.
|
/// Use the Dylib Engine.
|
||||||
#[clap(long, conflicts_with_all = &["universal", "object-file"])]
|
#[clap(long, conflicts_with_all = &["universal", "object-file"])]
|
||||||
shared_object: bool,
|
dylib: bool,
|
||||||
|
|
||||||
/// Use the ObjectFile Engine.
|
/// Use the ObjectFile Engine.
|
||||||
#[clap(long, conflicts_with_all = &["universal", "shared-object"])]
|
#[clap(long, conflicts_with_all = &["universal", "dylib"])]
|
||||||
object_file: bool,
|
object_file: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,9 +143,9 @@ impl CompilerOptions {
|
|||||||
.target(target)
|
.target(target)
|
||||||
.engine(),
|
.engine(),
|
||||||
),
|
),
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
EngineType::SharedObject => Box::new(
|
EngineType::Dylib => Box::new(
|
||||||
wasmer_engine_shared_object::SharedObject::new(compiler_config)
|
wasmer_engine_dylib::Dylib::new(compiler_config)
|
||||||
.target(target)
|
.target(target)
|
||||||
.features(features)
|
.features(features)
|
||||||
.engine(),
|
.engine(),
|
||||||
@ -157,11 +157,7 @@ impl CompilerOptions {
|
|||||||
.features(features)
|
.features(features)
|
||||||
.engine(),
|
.engine(),
|
||||||
),
|
),
|
||||||
#[cfg(not(all(
|
#[cfg(not(all(feature = "universal", feature = "dylib", feature = "object-file")))]
|
||||||
feature = "universal",
|
|
||||||
feature = "shared-object",
|
|
||||||
feature = "object-file"
|
|
||||||
)))]
|
|
||||||
engine => bail!(
|
engine => bail!(
|
||||||
"The `{}` engine is not included in this binary.",
|
"The `{}` engine is not included in this binary.",
|
||||||
engine.to_string()
|
engine.to_string()
|
||||||
@ -366,8 +362,8 @@ impl FromStr for CompilerType {
|
|||||||
pub enum EngineType {
|
pub enum EngineType {
|
||||||
/// Universal Engine
|
/// Universal Engine
|
||||||
Universal,
|
Universal,
|
||||||
/// Shared Object Engine
|
/// Dylib Engine
|
||||||
SharedObject,
|
Dylib,
|
||||||
/// Object File Engine
|
/// Object File Engine
|
||||||
ObjectFile,
|
ObjectFile,
|
||||||
}
|
}
|
||||||
@ -376,7 +372,7 @@ impl ToString for EngineType {
|
|||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Self::Universal => "universal".to_string(),
|
Self::Universal => "universal".to_string(),
|
||||||
Self::SharedObject => "shared_object".to_string(),
|
Self::Dylib => "dylib".to_string(),
|
||||||
Self::ObjectFile => "objectfile".to_string(),
|
Self::ObjectFile => "objectfile".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,16 +416,16 @@ impl StoreOptions {
|
|||||||
fn get_engine(&self) -> Result<EngineType> {
|
fn get_engine(&self) -> Result<EngineType> {
|
||||||
if self.universal {
|
if self.universal {
|
||||||
Ok(EngineType::Universal)
|
Ok(EngineType::Universal)
|
||||||
} else if self.shared_object {
|
} else if self.dylib {
|
||||||
Ok(EngineType::SharedObject)
|
Ok(EngineType::Dylib)
|
||||||
} else if self.object_file {
|
} else if self.object_file {
|
||||||
Ok(EngineType::ObjectFile)
|
Ok(EngineType::ObjectFile)
|
||||||
} else {
|
} else {
|
||||||
// Auto mode, we choose the best engine for that platform
|
// Auto mode, we choose the best engine for that platform
|
||||||
if cfg!(feature = "universal") {
|
if cfg!(feature = "universal") {
|
||||||
Ok(EngineType::Universal)
|
Ok(EngineType::Universal)
|
||||||
} else if cfg!(feature = "shared-object") {
|
} else if cfg!(feature = "dylib") {
|
||||||
Ok(EngineType::SharedObject)
|
Ok(EngineType::Dylib)
|
||||||
} else if cfg!(feature = "object-file") {
|
} else if cfg!(feature = "object-file") {
|
||||||
Ok(EngineType::ObjectFile)
|
Ok(EngineType::ObjectFile)
|
||||||
} else {
|
} else {
|
||||||
@ -449,19 +445,13 @@ impl StoreOptions {
|
|||||||
EngineType::Universal => {
|
EngineType::Universal => {
|
||||||
Arc::new(wasmer_engine_universal::Universal::headless().engine())
|
Arc::new(wasmer_engine_universal::Universal::headless().engine())
|
||||||
}
|
}
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
EngineType::SharedObject => {
|
EngineType::Dylib => Arc::new(wasmer_engine_dylib::Dylib::headless().engine()),
|
||||||
Arc::new(wasmer_engine_shared_object::SharedObject::headless().engine())
|
|
||||||
}
|
|
||||||
#[cfg(feature = "object-file")]
|
#[cfg(feature = "object-file")]
|
||||||
EngineType::ObjectFile => {
|
EngineType::ObjectFile => {
|
||||||
Arc::new(wasmer_engine_object_file::ObjectFile::headless().engine())
|
Arc::new(wasmer_engine_object_file::ObjectFile::headless().engine())
|
||||||
}
|
}
|
||||||
#[cfg(not(all(
|
#[cfg(not(all(feature = "universal", feature = "dylib", feature = "object-file")))]
|
||||||
feature = "universal",
|
|
||||||
feature = "shared-object",
|
|
||||||
feature = "object-file"
|
|
||||||
)))]
|
|
||||||
engine => bail!(
|
engine => bail!(
|
||||||
"The `{}` engine is not included in this binary.",
|
"The `{}` engine is not included in this binary.",
|
||||||
engine.to_string()
|
engine.to_string()
|
||||||
|
4
lib/deprecated/runtime-core/Cargo.lock
generated
4
lib/deprecated/runtime-core/Cargo.lock
generated
@ -1179,7 +1179,7 @@ dependencies = [
|
|||||||
"wasmer-compiler-singlepass",
|
"wasmer-compiler-singlepass",
|
||||||
"wasmer-derive",
|
"wasmer-derive",
|
||||||
"wasmer-engine",
|
"wasmer-engine",
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
@ -1302,7 +1302,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-engine-shared-object"
|
name = "wasmer-engine-dylib"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
|
4
lib/deprecated/runtime/Cargo.lock
generated
4
lib/deprecated/runtime/Cargo.lock
generated
@ -1183,7 +1183,7 @@ dependencies = [
|
|||||||
"wasmer-derive",
|
"wasmer-derive",
|
||||||
"wasmer-engine",
|
"wasmer-engine",
|
||||||
"wasmer-engine-universal",
|
"wasmer-engine-universal",
|
||||||
"wasmer-engine-shared-object",
|
"wasmer-engine-dylib",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-vm",
|
"wasmer-vm",
|
||||||
"wat",
|
"wat",
|
||||||
@ -1321,7 +1321,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-engine-shared-object"
|
name = "wasmer-engine-dylib"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extern crate wasmer;
|
extern crate wasmer;
|
||||||
|
|
||||||
use wasmer::{LazyInit, WasmerEnv, Memory};
|
use wasmer::{LazyInit, Memory, WasmerEnv};
|
||||||
|
|
||||||
#[derive(WasmerEnv)]
|
#[derive(WasmerEnv)]
|
||||||
struct BadAttribute {
|
struct BadAttribute {
|
||||||
@ -8,4 +8,4 @@ struct BadAttribute {
|
|||||||
memory: LazyInit<Memory>,
|
memory: LazyInit<Memory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
extern crate wasmer;
|
extern crate wasmer;
|
||||||
|
|
||||||
use wasmer::{LazyInit, WasmerEnv, Memory};
|
use wasmer::{LazyInit, Memory, WasmerEnv};
|
||||||
|
|
||||||
#[derive(WasmerEnv)]
|
#[derive(WasmerEnv)]
|
||||||
struct BadExportArg {
|
struct BadExportArg {
|
||||||
#[wasmer(export(this_is_not_a_real_argument="hello, world"))] //~ Unrecognized argument in export options: expected `name` found `this_is_not_a_real_argument
|
#[wasmer(export(this_is_not_a_real_argument = "hello, world"))]
|
||||||
|
//~ Unrecognized argument in export options: expected `name` found `this_is_not_a_real_argument
|
||||||
memory: LazyInit<Memory>,
|
memory: LazyInit<Memory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,4 +15,4 @@ struct BadExportArgRawString {
|
|||||||
memory: LazyInit<Memory>,
|
memory: LazyInit<Memory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
extern crate wasmer;
|
extern crate wasmer;
|
||||||
|
|
||||||
use wasmer::{LazyInit, WasmerEnv, Memory};
|
use wasmer::{LazyInit, Memory, WasmerEnv};
|
||||||
|
|
||||||
#[derive(WasmerEnv)]
|
#[derive(WasmerEnv)]
|
||||||
struct ExportNotWrappedInLazyInit {
|
struct ExportNotWrappedInLazyInit {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wasmer-engine-shared-object"
|
name = "wasmer-engine-dylib"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
description = "Wasmer Shared Object Engine"
|
description = "Wasmer Dylib Engine"
|
||||||
categories = ["wasm"]
|
categories = ["wasm"]
|
||||||
keywords = ["wasm", "webassembly", "engine", "shared-object"]
|
keywords = ["wasm", "webassembly", "engine", "dylib"]
|
||||||
authors = ["Wasmer Engineering Team <engineering@wasmer.io>"]
|
authors = ["Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||||
repository = "https://github.com/wasmerio/wasmer"
|
repository = "https://github.com/wasmerio/wasmer"
|
||||||
license = "MIT"
|
license = "MIT"
|
60
lib/engine-dylib/README.md
Normal file
60
lib/engine-dylib/README.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# `wasmer-engine-dylib` [](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [](https://slack.wasmer.io) [](https://github.com/wasmerio/wasmer/blob/master/LICENSE)
|
||||||
|
|
||||||
|
The Wasmer Dylib engine is usable with any compiler implementation
|
||||||
|
based on [`wasmer-compiler`] that is able to emit
|
||||||
|
[Position-Independent Code][PIC] (PIC).
|
||||||
|
|
||||||
|
After the compiler generates the machine code for the functions, the
|
||||||
|
Dylib Engine generates a shared object file and links it via [`dlsym`]
|
||||||
|
so it can be usable by the [`wasmer`] API.
|
||||||
|
|
||||||
|
This allows Wasmer to achieve *blazing fast* **native startup times**.
|
||||||
|
|
||||||
|
*Note: you can find a [full working example using the Dylib engine
|
||||||
|
here][example].*
|
||||||
|
|
||||||
|
### Difference with `wasmer-engine-universal`
|
||||||
|
|
||||||
|
The Dylib Engine and Universal Engine mainly differ on how the Modules
|
||||||
|
are loaded/stored. Using the same compilers, both will have the same
|
||||||
|
runtime speed.
|
||||||
|
|
||||||
|
However, the Dylib Engine uses the Operating System shared library
|
||||||
|
loader (via `dlopen`) and as such is able to achieve a much faster
|
||||||
|
startup time when deserializing a serialized `Module`.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
The `wasmer-engine-dylib` crate requires a linker available on
|
||||||
|
your system to generate the shared object file.
|
||||||
|
|
||||||
|
We recommend having [`gcc`] or [`clang`] installed.
|
||||||
|
|
||||||
|
> Note: when **cross-compiling** to other targets, `clang` will be the
|
||||||
|
> default command used for compiling.
|
||||||
|
|
||||||
|
You can install LLVM (that provides `clang`) easily on your
|
||||||
|
Debian-like system via this command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
|
||||||
|
```
|
||||||
|
|
||||||
|
Or in macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install llvm
|
||||||
|
```
|
||||||
|
|
||||||
|
Or via any of the [pre-built binaries that LLVM
|
||||||
|
offers][llvm-pre-built].
|
||||||
|
|
||||||
|
|
||||||
|
[`wasmer-compiler`]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler
|
||||||
|
[PIC]: https://en.wikipedia.org/wiki/Position-independent_code
|
||||||
|
[`dlsym`]: https://www.freebsd.org/cgi/man.cgi?query=dlsym
|
||||||
|
[`wasmer`]: https://github.com/wasmerio/wasmer/tree/master/lib/api
|
||||||
|
[example]: https://github.com/wasmerio/wasmer/blob/master/examples/engine_dylib.rs
|
||||||
|
[`gcc`]: https://gcc.gnu.org/
|
||||||
|
[`clang`]: https://clang.llvm.org/
|
||||||
|
[llvm-pre-built]: https://releases.llvm.org/download.html
|
@ -1,7 +1,7 @@
|
|||||||
//! Define `SharedObjectArtifact` to allow compiling and instantiating
|
//! Define `DylibArtifact` to allow compiling and instantiating
|
||||||
//! to be done as separate steps.
|
//! to be done as separate steps.
|
||||||
|
|
||||||
use crate::engine::{SharedObjectEngine, SharedObjectEngineInner};
|
use crate::engine::{DylibEngine, DylibEngineInner};
|
||||||
use crate::serialize::{ArchivedModuleMetadata, ModuleMetadata};
|
use crate::serialize::{ArchivedModuleMetadata, ModuleMetadata};
|
||||||
use libloading::{Library, Symbol as LibrarySymbol};
|
use libloading::{Library, Symbol as LibrarySymbol};
|
||||||
use loupe::MemoryUsage;
|
use loupe::MemoryUsage;
|
||||||
@ -46,8 +46,8 @@ use wasmer_vm::{
|
|||||||
|
|
||||||
/// A compiled Wasm module, ready to be instantiated.
|
/// A compiled Wasm module, ready to be instantiated.
|
||||||
#[derive(MemoryUsage)]
|
#[derive(MemoryUsage)]
|
||||||
pub struct SharedObjectArtifact {
|
pub struct DylibArtifact {
|
||||||
shared_object_path: PathBuf,
|
dylib_path: PathBuf,
|
||||||
metadata: ModuleMetadata,
|
metadata: ModuleMetadata,
|
||||||
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
finished_functions: BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>,
|
||||||
#[loupe(skip)]
|
#[loupe(skip)]
|
||||||
@ -64,7 +64,7 @@ fn to_compile_error(err: impl Error) -> CompileError {
|
|||||||
|
|
||||||
const WASMER_METADATA_SYMBOL: &[u8] = b"WASMER_METADATA";
|
const WASMER_METADATA_SYMBOL: &[u8] = b"WASMER_METADATA";
|
||||||
|
|
||||||
impl SharedObjectArtifact {
|
impl DylibArtifact {
|
||||||
// Mach-O header in Mac
|
// Mach-O header in Mac
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const MAGIC_HEADER_MH_CIGAM_64: &'static [u8] = &[207, 250, 237, 254];
|
const MAGIC_HEADER_MH_CIGAM_64: &'static [u8] = &[207, 250, 237, 254];
|
||||||
@ -81,7 +81,7 @@ impl SharedObjectArtifact {
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
const MAGIC_HEADER_COFF_64: &'static [u8] = &[b'M', b'Z'];
|
const MAGIC_HEADER_COFF_64: &'static [u8] = &[b'M', b'Z'];
|
||||||
|
|
||||||
/// Check if the provided bytes look like `SharedObjectArtifact`.
|
/// Check if the provided bytes look like `DylibArtifact`.
|
||||||
///
|
///
|
||||||
/// This means, if the bytes look like a shared object file in the target
|
/// This means, if the bytes look like a shared object file in the target
|
||||||
/// system.
|
/// system.
|
||||||
@ -154,11 +154,11 @@ impl SharedObjectArtifact {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compile a data buffer into a `SharedObjectArtifact`, which may
|
/// Compile a data buffer into a `DylibArtifact`, which may
|
||||||
/// then be instantiated.
|
/// then be instantiated.
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
engine: &SharedObjectEngine,
|
engine: &DylibEngine,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
tunables: &dyn Tunables,
|
tunables: &dyn Tunables,
|
||||||
) -> Result<Self, CompileError> {
|
) -> Result<Self, CompileError> {
|
||||||
@ -224,7 +224,7 @@ impl SharedObjectArtifact {
|
|||||||
Some(obj_bytes) => {
|
Some(obj_bytes) => {
|
||||||
let obj_bytes = obj_bytes?;
|
let obj_bytes = obj_bytes?;
|
||||||
let file = tempfile::Builder::new()
|
let file = tempfile::Builder::new()
|
||||||
.prefix("wasmer_shared_object_")
|
.prefix("wasmer_dylib_")
|
||||||
.suffix(".o")
|
.suffix(".o")
|
||||||
.tempfile()
|
.tempfile()
|
||||||
.map_err(to_compile_error)?;
|
.map_err(to_compile_error)?;
|
||||||
@ -252,7 +252,7 @@ impl SharedObjectArtifact {
|
|||||||
emit_compilation(&mut obj, compilation, &symbol_registry, &target_triple)
|
emit_compilation(&mut obj, compilation, &symbol_registry, &target_triple)
|
||||||
.map_err(to_compile_error)?;
|
.map_err(to_compile_error)?;
|
||||||
let file = tempfile::Builder::new()
|
let file = tempfile::Builder::new()
|
||||||
.prefix("wasmer_shared_object_")
|
.prefix("wasmer_dylib_")
|
||||||
.suffix(".o")
|
.suffix(".o")
|
||||||
.tempfile()
|
.tempfile()
|
||||||
.map_err(to_compile_error)?;
|
.map_err(to_compile_error)?;
|
||||||
@ -269,7 +269,7 @@ impl SharedObjectArtifact {
|
|||||||
let shared_filepath = {
|
let shared_filepath = {
|
||||||
let suffix = format!(".{}", Self::get_default_extension(&target_triple));
|
let suffix = format!(".{}", Self::get_default_extension(&target_triple));
|
||||||
let shared_file = tempfile::Builder::new()
|
let shared_file = tempfile::Builder::new()
|
||||||
.prefix("wasmer_shared_object_")
|
.prefix("wasmer_dylib_")
|
||||||
.suffix(&suffix)
|
.suffix(&suffix)
|
||||||
.tempfile()
|
.tempfile()
|
||||||
.map_err(to_compile_error)?;
|
.map_err(to_compile_error)?;
|
||||||
@ -358,10 +358,10 @@ impl SharedObjectArtifact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a `SharedObjectArtifact` from component parts.
|
/// Construct a `DylibArtifact` from component parts.
|
||||||
pub fn from_parts_crosscompiled(
|
pub fn from_parts_crosscompiled(
|
||||||
metadata: ModuleMetadata,
|
metadata: ModuleMetadata,
|
||||||
shared_object_path: PathBuf,
|
dylib_path: PathBuf,
|
||||||
) -> Result<Self, CompileError> {
|
) -> Result<Self, CompileError> {
|
||||||
let finished_functions: PrimaryMap<LocalFunctionIndex, FunctionBodyPtr> = PrimaryMap::new();
|
let finished_functions: PrimaryMap<LocalFunctionIndex, FunctionBodyPtr> = PrimaryMap::new();
|
||||||
let finished_function_call_trampolines: PrimaryMap<SignatureIndex, VMTrampoline> =
|
let finished_function_call_trampolines: PrimaryMap<SignatureIndex, VMTrampoline> =
|
||||||
@ -370,7 +370,7 @@ impl SharedObjectArtifact {
|
|||||||
PrimaryMap::new();
|
PrimaryMap::new();
|
||||||
let signatures: PrimaryMap<SignatureIndex, VMSharedSignatureIndex> = PrimaryMap::new();
|
let signatures: PrimaryMap<SignatureIndex, VMSharedSignatureIndex> = PrimaryMap::new();
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
shared_object_path,
|
dylib_path,
|
||||||
metadata,
|
metadata,
|
||||||
finished_functions: finished_functions.into_boxed_slice(),
|
finished_functions: finished_functions.into_boxed_slice(),
|
||||||
finished_function_call_trampolines: finished_function_call_trampolines
|
finished_function_call_trampolines: finished_function_call_trampolines
|
||||||
@ -383,11 +383,11 @@ impl SharedObjectArtifact {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a `SharedObjectArtifact` from component parts.
|
/// Construct a `DylibArtifact` from component parts.
|
||||||
pub fn from_parts(
|
pub fn from_parts(
|
||||||
engine_inner: &mut SharedObjectEngineInner,
|
engine_inner: &mut DylibEngineInner,
|
||||||
metadata: ModuleMetadata,
|
metadata: ModuleMetadata,
|
||||||
shared_object_path: PathBuf,
|
dylib_path: PathBuf,
|
||||||
lib: Library,
|
lib: Library,
|
||||||
) -> Result<Self, CompileError> {
|
) -> Result<Self, CompileError> {
|
||||||
let mut finished_functions: PrimaryMap<LocalFunctionIndex, FunctionBodyPtr> =
|
let mut finished_functions: PrimaryMap<LocalFunctionIndex, FunctionBodyPtr> =
|
||||||
@ -475,7 +475,7 @@ impl SharedObjectArtifact {
|
|||||||
engine_inner.add_library(lib);
|
engine_inner.add_library(lib);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
shared_object_path,
|
dylib_path,
|
||||||
metadata,
|
metadata,
|
||||||
finished_functions: finished_functions.into_boxed_slice(),
|
finished_functions: finished_functions.into_boxed_slice(),
|
||||||
finished_function_call_trampolines: finished_function_call_trampolines
|
finished_function_call_trampolines: finished_function_call_trampolines
|
||||||
@ -488,22 +488,22 @@ impl SharedObjectArtifact {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compile a data buffer into a `SharedObjectArtifact`, which may
|
/// Compile a data buffer into a `DylibArtifact`, which may
|
||||||
/// then be instantiated.
|
/// then be instantiated.
|
||||||
#[cfg(not(feature = "compiler"))]
|
#[cfg(not(feature = "compiler"))]
|
||||||
pub fn new(_engine: &SharedObjectEngine, _data: &[u8]) -> Result<Self, CompileError> {
|
pub fn new(_engine: &DylibEngine, _data: &[u8]) -> Result<Self, CompileError> {
|
||||||
Err(CompileError::Codegen(
|
Err(CompileError::Codegen(
|
||||||
"Compilation is not enabled in the engine".to_string(),
|
"Compilation is not enabled in the engine".to_string(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialize a `SharedObjectArtifact` from bytes.
|
/// Deserialize a `DylibArtifact` from bytes.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// The bytes must represent a serialized WebAssembly module.
|
/// The bytes must represent a serialized WebAssembly module.
|
||||||
pub unsafe fn deserialize(
|
pub unsafe fn deserialize(
|
||||||
engine: &SharedObjectEngine,
|
engine: &DylibEngine,
|
||||||
bytes: &[u8],
|
bytes: &[u8],
|
||||||
) -> Result<Self, DeserializeError> {
|
) -> Result<Self, DeserializeError> {
|
||||||
if !Self::is_deserializable(&bytes) {
|
if !Self::is_deserializable(&bytes) {
|
||||||
@ -520,13 +520,13 @@ impl SharedObjectArtifact {
|
|||||||
Self::deserialize_from_file_unchecked(&engine, &path)
|
Self::deserialize_from_file_unchecked(&engine, &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialize a `SharedObjectArtifact` from a file path.
|
/// Deserialize a `DylibArtifact` from a file path.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// The file's content must represent a serialized WebAssembly module.
|
/// The file's content must represent a serialized WebAssembly module.
|
||||||
pub unsafe fn deserialize_from_file(
|
pub unsafe fn deserialize_from_file(
|
||||||
engine: &SharedObjectEngine,
|
engine: &DylibEngine,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> Result<Self, DeserializeError> {
|
) -> Result<Self, DeserializeError> {
|
||||||
let mut file = File::open(&path)?;
|
let mut file = File::open(&path)?;
|
||||||
@ -541,13 +541,13 @@ impl SharedObjectArtifact {
|
|||||||
Self::deserialize_from_file_unchecked(&engine, &path)
|
Self::deserialize_from_file_unchecked(&engine, &path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialize a `SharedObjectArtifact` from a file path (unchecked).
|
/// Deserialize a `DylibArtifact` from a file path (unchecked).
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// The file's content must represent a serialized WebAssembly module.
|
/// The file's content must represent a serialized WebAssembly module.
|
||||||
pub unsafe fn deserialize_from_file_unchecked(
|
pub unsafe fn deserialize_from_file_unchecked(
|
||||||
engine: &SharedObjectEngine,
|
engine: &DylibEngine,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
) -> Result<Self, DeserializeError> {
|
) -> Result<Self, DeserializeError> {
|
||||||
let lib = Library::new(&path).map_err(|e| {
|
let lib = Library::new(&path).map_err(|e| {
|
||||||
@ -590,7 +590,7 @@ impl SharedObjectArtifact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Artifact for SharedObjectArtifact {
|
impl Artifact for DylibArtifact {
|
||||||
fn module(&self) -> Arc<ModuleInfo> {
|
fn module(&self) -> Arc<ModuleInfo> {
|
||||||
self.metadata.compile_info.module.clone()
|
self.metadata.compile_info.module.clone()
|
||||||
}
|
}
|
||||||
@ -769,8 +769,8 @@ impl Artifact for SharedObjectArtifact {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serialize a `SharedObjectArtifact`.
|
/// Serialize a `DylibArtifact`.
|
||||||
fn serialize(&self) -> Result<Vec<u8>, SerializeError> {
|
fn serialize(&self) -> Result<Vec<u8>, SerializeError> {
|
||||||
Ok(std::fs::read(&self.shared_object_path)?)
|
Ok(std::fs::read(&self.dylib_path)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
use crate::SharedObjectEngine;
|
use crate::DylibEngine;
|
||||||
use wasmer_compiler::{CompilerConfig, Features, Target};
|
use wasmer_compiler::{CompilerConfig, Features, Target};
|
||||||
|
|
||||||
/// The Shared Object builder
|
/// The Dylib builder
|
||||||
pub struct SharedObject {
|
pub struct Dylib {
|
||||||
compiler_config: Option<Box<dyn CompilerConfig>>,
|
compiler_config: Option<Box<dyn CompilerConfig>>,
|
||||||
target: Option<Target>,
|
target: Option<Target>,
|
||||||
features: Option<Features>,
|
features: Option<Features>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedObject {
|
impl Dylib {
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
/// Create a new Shared Object builder.
|
/// Create a new Dylib builder.
|
||||||
pub fn new<T>(compiler_config: T) -> Self
|
pub fn new<T>(compiler_config: T) -> Self
|
||||||
where
|
where
|
||||||
T: Into<Box<dyn CompilerConfig>>,
|
T: Into<Box<dyn CompilerConfig>>,
|
||||||
@ -25,7 +25,7 @@ impl SharedObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new headless Shared Object builder.
|
/// Create a new headless Dylib builder.
|
||||||
pub fn headless() -> Self {
|
pub fn headless() -> Self {
|
||||||
Self {
|
Self {
|
||||||
compiler_config: None,
|
compiler_config: None,
|
||||||
@ -46,8 +46,8 @@ impl SharedObject {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the `SharedObjectEngine` for this configuration
|
/// Build the `DylibEngine` for this configuration
|
||||||
pub fn engine(self) -> SharedObjectEngine {
|
pub fn engine(self) -> DylibEngine {
|
||||||
if let Some(_compiler_config) = self.compiler_config {
|
if let Some(_compiler_config) = self.compiler_config {
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
{
|
{
|
||||||
@ -57,15 +57,15 @@ impl SharedObject {
|
|||||||
.features
|
.features
|
||||||
.unwrap_or_else(|| compiler_config.default_features_for_target(&target));
|
.unwrap_or_else(|| compiler_config.default_features_for_target(&target));
|
||||||
let compiler = compiler_config.compiler();
|
let compiler = compiler_config.compiler();
|
||||||
SharedObjectEngine::new(compiler, target, features)
|
DylibEngine::new(compiler, target, features)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "compiler"))]
|
#[cfg(not(feature = "compiler"))]
|
||||||
{
|
{
|
||||||
unreachable!("Cannot call `SharedObjectEngine::new` without the `compiler` feature")
|
unreachable!("Cannot call `DylibEngine::new` without the `compiler` feature")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SharedObjectEngine::headless()
|
DylibEngine::headless()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,13 +105,13 @@ mod tests {
|
|||||||
#[should_panic(expected = "compiler not implemented")]
|
#[should_panic(expected = "compiler not implemented")]
|
||||||
fn build_engine() {
|
fn build_engine() {
|
||||||
let compiler_config = TestCompilerConfig::default();
|
let compiler_config = TestCompilerConfig::default();
|
||||||
let shared_object = SharedObject::new(compiler_config);
|
let dylib = Dylib::new(compiler_config);
|
||||||
let _engine = shared_object.engine();
|
let _engine = dylib.engine();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_headless_engine() {
|
fn build_headless_engine() {
|
||||||
let shared_object = SharedObject::headless();
|
let dylib = Dylib::headless();
|
||||||
let _engine = shared_object.engine();
|
let _engine = dylib.engine();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
//! Shared Object Engine.
|
//! Dylib Engine.
|
||||||
|
|
||||||
use crate::SharedObjectArtifact;
|
use crate::DylibArtifact;
|
||||||
use libloading::Library;
|
use libloading::Library;
|
||||||
use loupe::MemoryUsage;
|
use loupe::MemoryUsage;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -17,24 +17,24 @@ use wasmer_vm::{
|
|||||||
FuncDataRegistry, SignatureRegistry, VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex,
|
FuncDataRegistry, SignatureRegistry, VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A WebAssembly `SharedObject` Engine.
|
/// A WebAssembly `Dylib` Engine.
|
||||||
#[derive(Clone, MemoryUsage)]
|
#[derive(Clone, MemoryUsage)]
|
||||||
pub struct SharedObjectEngine {
|
pub struct DylibEngine {
|
||||||
inner: Arc<Mutex<SharedObjectEngineInner>>,
|
inner: Arc<Mutex<DylibEngineInner>>,
|
||||||
/// The target for the compiler
|
/// The target for the compiler
|
||||||
target: Arc<Target>,
|
target: Arc<Target>,
|
||||||
engine_id: EngineId,
|
engine_id: EngineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedObjectEngine {
|
impl DylibEngine {
|
||||||
/// Create a new `SharedObjectEngine` with the given config
|
/// Create a new `DylibEngine` with the given config
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
|
pub fn new(compiler: Box<dyn Compiler>, target: Target, features: Features) -> Self {
|
||||||
let is_cross_compiling = *target.triple() != Triple::host();
|
let is_cross_compiling = *target.triple() != Triple::host();
|
||||||
let linker = Linker::find_linker(is_cross_compiling);
|
let linker = Linker::find_linker(is_cross_compiling);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
inner: Arc::new(Mutex::new(SharedObjectEngineInner {
|
inner: Arc::new(Mutex::new(DylibEngineInner {
|
||||||
compiler: Some(compiler),
|
compiler: Some(compiler),
|
||||||
signatures: SignatureRegistry::new(),
|
signatures: SignatureRegistry::new(),
|
||||||
func_data: Arc::new(FuncDataRegistry::new()),
|
func_data: Arc::new(FuncDataRegistry::new()),
|
||||||
@ -49,7 +49,7 @@ impl SharedObjectEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a headless `SharedObjectEngine`
|
/// Create a headless `DylibEngine`
|
||||||
///
|
///
|
||||||
/// A headless engine is an engine without any compiler attached.
|
/// A headless engine is an engine without any compiler attached.
|
||||||
/// This is useful for assuring a minimal runtime for running
|
/// This is useful for assuring a minimal runtime for running
|
||||||
@ -64,7 +64,7 @@ impl SharedObjectEngine {
|
|||||||
/// they just take already processed Modules (via `Module::serialize`).
|
/// they just take already processed Modules (via `Module::serialize`).
|
||||||
pub fn headless() -> Self {
|
pub fn headless() -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: Arc::new(Mutex::new(SharedObjectEngineInner {
|
inner: Arc::new(Mutex::new(DylibEngineInner {
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
compiler: None,
|
compiler: None,
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
@ -99,16 +99,16 @@ impl SharedObjectEngine {
|
|||||||
inner.prefixer = Some(Box::new(prefixer));
|
inner.prefixer = Some(Box::new(prefixer));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn inner(&self) -> std::sync::MutexGuard<'_, SharedObjectEngineInner> {
|
pub(crate) fn inner(&self) -> std::sync::MutexGuard<'_, DylibEngineInner> {
|
||||||
self.inner.lock().unwrap()
|
self.inner.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn inner_mut(&self) -> std::sync::MutexGuard<'_, SharedObjectEngineInner> {
|
pub(crate) fn inner_mut(&self) -> std::sync::MutexGuard<'_, DylibEngineInner> {
|
||||||
self.inner.lock().unwrap()
|
self.inner.lock().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Engine for SharedObjectEngine {
|
impl Engine for DylibEngine {
|
||||||
/// The target
|
/// The target
|
||||||
fn target(&self) -> &Target {
|
fn target(&self) -> &Target {
|
||||||
&self.target
|
&self.target
|
||||||
@ -143,9 +143,7 @@ impl Engine for SharedObjectEngine {
|
|||||||
binary: &[u8],
|
binary: &[u8],
|
||||||
tunables: &dyn Tunables,
|
tunables: &dyn Tunables,
|
||||||
) -> Result<Arc<dyn Artifact>, CompileError> {
|
) -> Result<Arc<dyn Artifact>, CompileError> {
|
||||||
Ok(Arc::new(SharedObjectArtifact::new(
|
Ok(Arc::new(DylibArtifact::new(&self, binary, tunables)?))
|
||||||
&self, binary, tunables,
|
|
||||||
)?))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compile a WebAssembly binary (it will fail because the `compiler` flag is disabled).
|
/// Compile a WebAssembly binary (it will fail because the `compiler` flag is disabled).
|
||||||
@ -156,23 +154,23 @@ impl Engine for SharedObjectEngine {
|
|||||||
_tunables: &dyn Tunables,
|
_tunables: &dyn Tunables,
|
||||||
) -> Result<Arc<dyn Artifact>, CompileError> {
|
) -> Result<Arc<dyn Artifact>, CompileError> {
|
||||||
Err(CompileError::Codegen(
|
Err(CompileError::Codegen(
|
||||||
"The `SharedObjectEngine` is operating in headless mode, so it cannot compile a module."
|
"The `DylibEngine` is operating in headless mode, so it cannot compile a module."
|
||||||
.to_string(),
|
.to_string(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserializes a WebAssembly module (binary content of a Shared Object file)
|
/// Deserializes a WebAssembly module (binary content of a shared object file)
|
||||||
unsafe fn deserialize(&self, bytes: &[u8]) -> Result<Arc<dyn Artifact>, DeserializeError> {
|
unsafe fn deserialize(&self, bytes: &[u8]) -> Result<Arc<dyn Artifact>, DeserializeError> {
|
||||||
Ok(Arc::new(SharedObjectArtifact::deserialize(&self, &bytes)?))
|
Ok(Arc::new(DylibArtifact::deserialize(&self, &bytes)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserializes a WebAssembly module from a path
|
/// Deserializes a WebAssembly module from a path
|
||||||
/// It should point to a Shared Object file generated by this engine.
|
/// It should point to a shared object file generated by this engine.
|
||||||
unsafe fn deserialize_from_file(
|
unsafe fn deserialize_from_file(
|
||||||
&self,
|
&self,
|
||||||
file_ref: &Path,
|
file_ref: &Path,
|
||||||
) -> Result<Arc<dyn Artifact>, DeserializeError> {
|
) -> Result<Arc<dyn Artifact>, DeserializeError> {
|
||||||
Ok(Arc::new(SharedObjectArtifact::deserialize_from_file(
|
Ok(Arc::new(DylibArtifact::deserialize_from_file(
|
||||||
&self, &file_ref,
|
&self, &file_ref,
|
||||||
)?))
|
)?))
|
||||||
}
|
}
|
||||||
@ -212,7 +210,7 @@ impl Linker {
|
|||||||
.next()
|
.next()
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
panic!(
|
panic!(
|
||||||
"Need {} installed in order to use `SharedObjectEngine` when {}cross-compiling",
|
"Need {} installed in order to use `DylibEngine` when {}cross-compiling",
|
||||||
requirements,
|
requirements,
|
||||||
if is_cross_compiling { "" } else { "not " }
|
if is_cross_compiling { "" } else { "not " }
|
||||||
)
|
)
|
||||||
@ -230,9 +228,9 @@ impl Linker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The inner contents of `SharedObjectEngine`
|
/// The inner contents of `DylibEngine`
|
||||||
#[derive(MemoryUsage)]
|
#[derive(MemoryUsage)]
|
||||||
pub struct SharedObjectEngineInner {
|
pub struct DylibEngineInner {
|
||||||
/// The compiler
|
/// The compiler
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
compiler: Option<Box<dyn Compiler>>,
|
compiler: Option<Box<dyn Compiler>>,
|
||||||
@ -251,12 +249,12 @@ pub struct SharedObjectEngineInner {
|
|||||||
func_data: Arc<FuncDataRegistry>,
|
func_data: Arc<FuncDataRegistry>,
|
||||||
|
|
||||||
/// The prefixer returns the a String to prefix each of
|
/// The prefixer returns the a String to prefix each of
|
||||||
/// the functions in the shared object generated by the `SharedObjectEngine`,
|
/// the functions in the shared object generated by the `DylibEngine`,
|
||||||
/// so we can assure no collisions.
|
/// so we can assure no collisions.
|
||||||
#[loupe(skip)]
|
#[loupe(skip)]
|
||||||
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
|
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send>>,
|
||||||
|
|
||||||
/// Whether the shared object engine will cross-compile.
|
/// Whether the Dylib engine will cross-compile.
|
||||||
is_cross_compiling: bool,
|
is_cross_compiling: bool,
|
||||||
|
|
||||||
/// The linker to use.
|
/// The linker to use.
|
||||||
@ -267,12 +265,12 @@ pub struct SharedObjectEngineInner {
|
|||||||
libraries: Vec<Library>,
|
libraries: Vec<Library>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SharedObjectEngineInner {
|
impl DylibEngineInner {
|
||||||
/// Gets the compiler associated to this engine.
|
/// Gets the compiler associated to this engine.
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
|
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
|
||||||
if self.compiler.is_none() {
|
if self.compiler.is_none() {
|
||||||
return Err(CompileError::Codegen("The `SharedObjectEngine` is operating in headless mode, so it can only execute already compiled Modules.".to_string()));
|
return Err(CompileError::Codegen("The `DylibEngine` is operating in headless mode, so it can only execute already compiled Modules.".to_string()));
|
||||||
}
|
}
|
||||||
Ok(&**self
|
Ok(&**self
|
||||||
.compiler
|
.compiler
|
||||||
@ -304,7 +302,7 @@ impl SharedObjectEngineInner {
|
|||||||
#[cfg(not(feature = "compiler"))]
|
#[cfg(not(feature = "compiler"))]
|
||||||
pub fn validate<'data>(&self, _data: &'data [u8]) -> Result<(), CompileError> {
|
pub fn validate<'data>(&self, _data: &'data [u8]) -> Result<(), CompileError> {
|
||||||
Err(CompileError::Validate(
|
Err(CompileError::Validate(
|
||||||
"The `SharedObjectEngine` is not compiled with compiler support, which is required for validating".to_string(),
|
"The `DylibEngine` is not compiled with compiler support, which is required for validating".to_string(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
|||||||
//! Shared Object Engine for Wasmer compilers.
|
//! Ddylib Engine for Wasmer compilers.
|
||||||
//!
|
//!
|
||||||
//! Given a compiler (such as `CraneliftCompiler` or `LLVMCompiler`)
|
//! Given a compiler (such as `CraneliftCompiler` or `LLVMCompiler`)
|
||||||
//! it generates a shared object file (`.so` or `.dylib` depending on
|
//! it generates a dylib/shared object file (`.so` or `.dylib`
|
||||||
//! the target), saves it temporarily to disk and uses it natively
|
//! depending on the target), saves it temporarily to disk and uses it
|
||||||
//! via `dlopen` and `dlsym` (using the `libloading` library).
|
//! natively via `dlopen` and `dlsym` (using the `libloading`
|
||||||
|
//! library).
|
||||||
|
|
||||||
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
||||||
#![warn(unused_import_braces)]
|
#![warn(unused_import_braces)]
|
||||||
@ -27,9 +28,9 @@ mod builder;
|
|||||||
mod engine;
|
mod engine;
|
||||||
mod serialize;
|
mod serialize;
|
||||||
|
|
||||||
pub use crate::artifact::SharedObjectArtifact;
|
pub use crate::artifact::DylibArtifact;
|
||||||
pub use crate::builder::SharedObject;
|
pub use crate::builder::Dylib;
|
||||||
pub use crate::engine::SharedObjectEngine;
|
pub use crate::engine::DylibEngine;
|
||||||
|
|
||||||
/// Version number of this crate.
|
/// Version number of this crate.
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
@ -1,60 +0,0 @@
|
|||||||
# `wasmer-engine-shared-object` [](https://github.com/wasmerio/wasmer/actions?query=workflow%3Abuild) [](https://slack.wasmer.io) [](https://github.com/wasmerio/wasmer/blob/master/LICENSE)
|
|
||||||
|
|
||||||
The Wasmer Shared Object engine is usable with any compiler
|
|
||||||
implementation based on [`wasmer-compiler`] that is able to emit
|
|
||||||
[Position-Independent Code][PIC] (PIC).
|
|
||||||
|
|
||||||
After the compiler generates the machine code for the functions, the
|
|
||||||
Shared Object Engine generates a shared object file and links it via
|
|
||||||
[`dlsym`] so it can be usable by the [`wasmer`] API.
|
|
||||||
|
|
||||||
This allows Wasmer to achieve *blazing fast* **native startup times**.
|
|
||||||
|
|
||||||
*Note: you can find a [full working example using the Shared Object
|
|
||||||
engine here][example].*
|
|
||||||
|
|
||||||
### Difference with `wasmer-engine-universal`
|
|
||||||
|
|
||||||
The Shared Object Engine and Universal Engine mainly differ on how the
|
|
||||||
Modules are loaded/stored. Using the same compilers, both will have
|
|
||||||
the same runtime speed.
|
|
||||||
|
|
||||||
However, the Shared Object Engine uses the Operating System shared
|
|
||||||
library loader (via `dlopen`) and as such is able to achieve a much
|
|
||||||
faster startup time when deserializing a serialized `Module`.
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
The `wasmer-engine-shared-object` crate requires a linker available on
|
|
||||||
your system to generate the shared object file.
|
|
||||||
|
|
||||||
We recommend having [`gcc`] or [`clang`] installed.
|
|
||||||
|
|
||||||
> Note: when **cross-compiling** to other targets, `clang` will be the
|
|
||||||
> default command used for compiling.
|
|
||||||
|
|
||||||
You can install LLVM (that provides `clang`) easily on your
|
|
||||||
Debian-like system via this command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
|
|
||||||
```
|
|
||||||
|
|
||||||
Or in macOS:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
brew install llvm
|
|
||||||
```
|
|
||||||
|
|
||||||
Or via any of the [pre-built binaries that LLVM
|
|
||||||
offers][llvm-pre-built].
|
|
||||||
|
|
||||||
|
|
||||||
[`wasmer-compiler`]: https://github.com/wasmerio/wasmer/tree/master/lib/compiler
|
|
||||||
[PIC]: https://en.wikipedia.org/wiki/Position-independent_code
|
|
||||||
[`dlsym`]: https://www.freebsd.org/cgi/man.cgi?query=dlsym
|
|
||||||
[`wasmer`]: https://github.com/wasmerio/wasmer/tree/master/lib/api
|
|
||||||
[example]: https://github.com/wasmerio/wasmer/blob/master/examples/engine_shared_object.rs
|
|
||||||
[`gcc`]: https://gcc.gnu.org/
|
|
||||||
[`clang`]: https://clang.llvm.org/
|
|
||||||
[llvm-pre-built]: https://releases.llvm.org/download.html
|
|
@ -11,7 +11,7 @@ Wasmer Engines are mainly responsible for two things:
|
|||||||
It currently has three implementations:
|
It currently has three implementations:
|
||||||
|
|
||||||
1. Universal with [`wasmer-engine-universal`],
|
1. Universal with [`wasmer-engine-universal`],
|
||||||
2. Native with [`wasmer-engine-shared-object`],
|
2. Native with [`wasmer-engine-dylib`],
|
||||||
3. Object with [`wasmer-engine-object-file`].
|
3. Object with [`wasmer-engine-object-file`].
|
||||||
|
|
||||||
## Example Implementation
|
## Example Implementation
|
||||||
@ -29,7 +29,7 @@ attributions of the project.
|
|||||||
|
|
||||||
|
|
||||||
[`wasmer-engine-universal`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal
|
[`wasmer-engine-universal`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-universal
|
||||||
[`wasmer-engine-shared-object`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-shared-object
|
[`wasmer-engine-dylib`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-dylib
|
||||||
[`wasmer-engine-object-file`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-object-file
|
[`wasmer-engine-object-file`]: https://github.com/wasmerio/wasmer/tree/master/lib/engine-object-file
|
||||||
[`wasmer-engine-dummy`]: https://github.com/wasmerio/wasmer/tree/master/tests/lib/engine-dummy
|
[`wasmer-engine-dummy`]: https://github.com/wasmerio/wasmer/tree/master/tests/lib/engine-dummy
|
||||||
[`wasmtime-api`]: https://crates.io/crates/wasmtime
|
[`wasmtime-api`]: https://crates.io/crates/wasmtime
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
The Wasmer Native Object crate aims at cross-generating native objects
|
The Wasmer Native Object crate aims at cross-generating native objects
|
||||||
for various platforms.
|
for various platforms.
|
||||||
|
|
||||||
This crate is the foundation of [the `wasmer-engine-shared-object`
|
This crate is the foundation of [the `wasmer-engine-dylib`
|
||||||
crate](../engine-shared-object/). Given a compilation result, i.e. the result
|
crate](../engine-dylib/). Given a compilation result, i.e. the result
|
||||||
of `wasmer_compiler::Compiler::compile_module`, this crate exposes
|
of `wasmer_compiler::Compiler::compile_module`, this crate exposes
|
||||||
functions to create an `Object` file for a given target. It is a
|
functions to create an `Object` file for a given target. It is a
|
||||||
useful thin layer on top of [the `object`
|
useful thin layer on top of [the `object`
|
||||||
|
@ -35,20 +35,20 @@ dep_graph = {
|
|||||||
"wasmer-compiler-cranelift": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]),
|
"wasmer-compiler-cranelift": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]),
|
||||||
"wasmer-compiler-llvm": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]),
|
"wasmer-compiler-llvm": set(["wasmer-types", "wasmer-vm", "wasmer-compiler"]),
|
||||||
"wasmer-engine-universal": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine"]),
|
"wasmer-engine-universal": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine"]),
|
||||||
"wasmer-engine-shared-object": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine",
|
"wasmer-engine-dylib": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine",
|
||||||
"wasmer-object"]),
|
"wasmer-object"]),
|
||||||
"wasmer-engine-object-file": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine",
|
"wasmer-engine-object-file": set(["wasmer-types", "wasmer-vm", "wasmer-compiler", "wasmer-engine",
|
||||||
"wasmer-object"]),
|
"wasmer-object"]),
|
||||||
"wasmer": set(["wasmer-vm", "wasmer-compiler-singlepass", "wasmer-compiler-cranelift",
|
"wasmer": set(["wasmer-vm", "wasmer-compiler-singlepass", "wasmer-compiler-cranelift",
|
||||||
"wasmer-compiler-llvm", "wasmer-compiler", "wasmer-engine", "wasmer-engine-universal",
|
"wasmer-compiler-llvm", "wasmer-compiler", "wasmer-engine", "wasmer-engine-universal",
|
||||||
"wasmer-engine-shared-object", "wasmer-engine-object-file", "wasmer-types", "wasmer-derive"]),
|
"wasmer-engine-dylib", "wasmer-engine-object-file", "wasmer-types", "wasmer-derive"]),
|
||||||
"wasmer-cache": set(["wasmer"]),
|
"wasmer-cache": set(["wasmer"]),
|
||||||
"wasmer-wasi": set(["wasmer"]),
|
"wasmer-wasi": set(["wasmer"]),
|
||||||
"wasmer-wasi-experimental-io-devices": set(["wasmer-wasi"]),
|
"wasmer-wasi-experimental-io-devices": set(["wasmer-wasi"]),
|
||||||
"wasmer-emscripten": set(["wasmer"]),
|
"wasmer-emscripten": set(["wasmer"]),
|
||||||
"wasmer-c-api": set(["wasmer", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass",
|
"wasmer-c-api": set(["wasmer", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-compiler-singlepass",
|
||||||
"wasmer-compiler-llvm", "wasmer-emscripten", "wasmer-engine", "wasmer-engine-universal",
|
"wasmer-compiler-llvm", "wasmer-emscripten", "wasmer-engine", "wasmer-engine-universal",
|
||||||
"wasmer-engine-shared-object", "wasmer-engine-object-file", "wasmer-wasi", "wasmer-types"]),
|
"wasmer-engine-dylib", "wasmer-engine-object-file", "wasmer-wasi", "wasmer-types"]),
|
||||||
"wasmer-middlewares": set(["wasmer", "wasmer-types", "wasmer-vm"]),
|
"wasmer-middlewares": set(["wasmer", "wasmer-types", "wasmer-vm"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ location = {
|
|||||||
"wasmer-compiler-llvm": "compiler-llvm",
|
"wasmer-compiler-llvm": "compiler-llvm",
|
||||||
"wasmer-engine": "engine",
|
"wasmer-engine": "engine",
|
||||||
"wasmer-engine-universal": "engine-universal",
|
"wasmer-engine-universal": "engine-universal",
|
||||||
"wasmer-engine-shared-object": "engine-shared-object",
|
"wasmer-engine-dylib": "engine-dylib",
|
||||||
"wasmer-engine-object-file": "engine-object-file",
|
"wasmer-engine-object-file": "engine-object-file",
|
||||||
"wasmer-cache": "cache",
|
"wasmer-cache": "cache",
|
||||||
"wasmer": "api",
|
"wasmer": "api",
|
||||||
|
@ -10,7 +10,7 @@ pub enum Compiler {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum Engine {
|
pub enum Engine {
|
||||||
SharedObject,
|
Dylib,
|
||||||
Universal,
|
Universal,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ impl Config {
|
|||||||
#[cfg(not(feature = "engine"))]
|
#[cfg(not(feature = "engine"))]
|
||||||
compile_error!("Plese enable at least one engine via the features");
|
compile_error!("Plese enable at least one engine via the features");
|
||||||
match &self.engine {
|
match &self.engine {
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
Engine::SharedObject => {
|
Engine::Dylib => {
|
||||||
let mut engine = wasmer_engine_shared_object::SharedObject::new(compiler_config);
|
let mut engine = wasmer_engine_dylib::Dylib::new(compiler_config);
|
||||||
if let Some(ref features) = self.features {
|
if let Some(ref features) = self.features {
|
||||||
engine = engine.features(features.clone())
|
engine = engine.features(features.clone())
|
||||||
}
|
}
|
||||||
@ -87,10 +87,8 @@ impl Config {
|
|||||||
|
|
||||||
pub fn engine_headless(&self) -> Box<dyn WasmerEngine> {
|
pub fn engine_headless(&self) -> Box<dyn WasmerEngine> {
|
||||||
match &self.engine {
|
match &self.engine {
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
Engine::SharedObject => {
|
Engine::Dylib => Box::new(wasmer_engine_dylib::Dylib::headless().engine()),
|
||||||
Box::new(wasmer_engine_shared_object::SharedObject::headless().engine())
|
|
||||||
}
|
|
||||||
#[cfg(feature = "universal")]
|
#[cfg(feature = "universal")]
|
||||||
Engine::Universal => Box::new(wasmer_engine_universal::Universal::headless().engine()),
|
Engine::Universal => Box::new(wasmer_engine_universal::Universal::headless().engine()),
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -40,8 +40,7 @@ pub fn run_wast(mut config: crate::Config, wast_path: &str) -> anyhow::Result<()
|
|||||||
wast.allow_trap_message("uninitialized element 2", "uninitialized element");
|
wast.allow_trap_message("uninitialized element 2", "uninitialized element");
|
||||||
// `liking.wast` has different wording but the same meaning
|
// `liking.wast` has different wording but the same meaning
|
||||||
wast.allow_trap_message("out of bounds memory access", "memory out of bounds");
|
wast.allow_trap_message("out of bounds memory access", "memory out of bounds");
|
||||||
if config.compiler == crate::Compiler::Cranelift && config.engine == crate::Engine::SharedObject
|
if config.compiler == crate::Compiler::Cranelift && config.engine == crate::Engine::Dylib {
|
||||||
{
|
|
||||||
wast.allow_trap_message("call stack exhausted", "out of bounds memory access");
|
wast.allow_trap_message("call stack exhausted", "out of bounds memory access");
|
||||||
wast.allow_trap_message("indirect call type mismatch", "call stack exhausted");
|
wast.allow_trap_message("indirect call type mismatch", "call stack exhausted");
|
||||||
wast.allow_trap_message("integer divide by zero", "call stack exhausted");
|
wast.allow_trap_message("integer divide by zero", "call stack exhausted");
|
||||||
|
@ -3,36 +3,36 @@ singlepass spec::multi_value
|
|||||||
singlepass spec::simd
|
singlepass spec::simd
|
||||||
|
|
||||||
singlepass+windows *
|
singlepass+windows *
|
||||||
singlepass+shared-object *
|
singlepass+dylib *
|
||||||
windows+shared-object *
|
windows+dylib *
|
||||||
musl+shared-object * # Dynamic loading not supported in Musl
|
musl+dylib * # Dynamic loading not supported in Musl
|
||||||
|
|
||||||
# Traps
|
# Traps
|
||||||
singlepass traps::test_trap_trace
|
singlepass traps::test_trap_trace
|
||||||
shared-object traps::test_trap_trace
|
dylib traps::test_trap_trace
|
||||||
aarch64 traps::test_trap_trace
|
aarch64 traps::test_trap_trace
|
||||||
singlepass traps::test_trap_stack_overflow
|
singlepass traps::test_trap_stack_overflow
|
||||||
shared-object traps::test_trap_stack_overflow
|
dylib traps::test_trap_stack_overflow
|
||||||
aarch64 traps::test_trap_stack_overflow
|
aarch64 traps::test_trap_stack_overflow
|
||||||
singlepass traps::trap_display_pretty
|
singlepass traps::trap_display_pretty
|
||||||
llvm traps::trap_display_pretty
|
llvm traps::trap_display_pretty
|
||||||
shared-object traps::trap_display_pretty
|
dylib traps::trap_display_pretty
|
||||||
aarch64 traps::trap_display_pretty
|
aarch64 traps::trap_display_pretty
|
||||||
singlepass traps::trap_display_multi_module
|
singlepass traps::trap_display_multi_module
|
||||||
llvm traps::trap_display_multi_module
|
llvm traps::trap_display_multi_module
|
||||||
shared-object traps::trap_display_multi_module
|
dylib traps::trap_display_multi_module
|
||||||
aarch64 traps::trap_display_multi_module
|
aarch64 traps::trap_display_multi_module
|
||||||
singlepass traps::call_signature_mismatch
|
singlepass traps::call_signature_mismatch
|
||||||
llvm traps::call_signature_mismatch
|
llvm traps::call_signature_mismatch
|
||||||
shared-object traps::call_signature_mismatch
|
dylib traps::call_signature_mismatch
|
||||||
macos+aarch64 traps::call_signature_mismatch
|
macos+aarch64 traps::call_signature_mismatch
|
||||||
singlepass traps::start_trap_pretty
|
singlepass traps::start_trap_pretty
|
||||||
llvm traps::start_trap_pretty
|
llvm traps::start_trap_pretty
|
||||||
shared-object traps::start_trap_pretty
|
dylib traps::start_trap_pretty
|
||||||
aarch64 traps::start_trap_pretty
|
aarch64 traps::start_trap_pretty
|
||||||
|
|
||||||
cranelift multi_value_imports::shared-object
|
cranelift multi_value_imports::dylib
|
||||||
singlepass multi_value_imports::shared-object
|
singlepass multi_value_imports::dylib
|
||||||
singlepass multi_value_imports::dynamic
|
singlepass multi_value_imports::dynamic
|
||||||
|
|
||||||
|
|
||||||
@ -45,9 +45,9 @@ llvm+universal+macos+aarch64 *
|
|||||||
cranelift spec::skip_stack_guard_page
|
cranelift spec::skip_stack_guard_page
|
||||||
llvm spec::skip_stack_guard_page
|
llvm spec::skip_stack_guard_page
|
||||||
|
|
||||||
# TODO(https://github.com/wasmerio/wasmer/issues/1727): Traps in shared-object engine
|
# TODO(https://github.com/wasmerio/wasmer/issues/1727): Traps in dylib engine
|
||||||
cranelift+shared-object spec::linking
|
cranelift+dylib spec::linking
|
||||||
cranelift+shared-object spec::bulk
|
cranelift+dylib spec::bulk
|
||||||
|
|
||||||
# Some SIMD opperations are not yet supported by Cranelift
|
# Some SIMD opperations are not yet supported by Cranelift
|
||||||
cranelift+aarch64 spec::simd::simd_boolean
|
cranelift+aarch64 spec::simd::simd_boolean
|
||||||
|
@ -22,7 +22,7 @@ impl Compiler {
|
|||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum Engine {
|
pub enum Engine {
|
||||||
Universal,
|
Universal,
|
||||||
SharedObject,
|
Dylib,
|
||||||
ObjectFile,
|
ObjectFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ impl Engine {
|
|||||||
pub const fn to_flag(self) -> &'static str {
|
pub const fn to_flag(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Engine::Universal => "--universal",
|
Engine::Universal => "--universal",
|
||||||
Engine::SharedObject => "--shared-object",
|
Engine::Dylib => "--dylib",
|
||||||
Engine::ObjectFile => "--object-file",
|
Engine::ObjectFile => "--object-file",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ impl Ignores {
|
|||||||
arch = Some(alias.to_string());
|
arch = Some(alias.to_string());
|
||||||
}
|
}
|
||||||
// Engines
|
// Engines
|
||||||
"universal" | "shared-object" => {
|
"universal" | "dylib" => {
|
||||||
engine = Some(alias.to_string());
|
engine = Some(alias.to_string());
|
||||||
}
|
}
|
||||||
// Compilers
|
// Compilers
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use ::proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use ::proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use ::quote::quote;
|
use quote::quote;
|
||||||
#[cfg(not(test))]
|
|
||||||
use ::syn::parse;
|
|
||||||
#[cfg(test)]
|
|
||||||
use ::syn::parse2 as parse;
|
|
||||||
use ::syn::*;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
#[cfg(not(test))]
|
||||||
|
use syn::parse;
|
||||||
|
#[cfg(test)]
|
||||||
|
use syn::parse2 as parse;
|
||||||
|
use syn::*;
|
||||||
|
|
||||||
mod ignores;
|
mod ignores;
|
||||||
|
|
||||||
@ -112,8 +112,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||||||
let mod_name = ::quote::format_ident!("{}", compiler_name.to_lowercase());
|
let mod_name = ::quote::format_ident!("{}", compiler_name.to_lowercase());
|
||||||
let universal_engine_test =
|
let universal_engine_test =
|
||||||
construct_engine_test(func, compiler_name, "Universal", "universal");
|
construct_engine_test(func, compiler_name, "Universal", "universal");
|
||||||
let shared_object_engine_test =
|
let dylib_engine_test = construct_engine_test(func, compiler_name, "Dylib", "dylib");
|
||||||
construct_engine_test(func, compiler_name, "SharedObject", "shared-object");
|
|
||||||
let compiler_name_lowercase = compiler_name.to_lowercase();
|
let compiler_name_lowercase = compiler_name.to_lowercase();
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
@ -122,7 +121,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#universal_engine_test
|
#universal_engine_test
|
||||||
#shared_object_engine_test
|
#dylib_engine_test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use ::pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
macro_rules! gen_tests {(
|
macro_rules! gen_tests {(
|
||||||
$(
|
$(
|
||||||
@ -71,10 +71,10 @@ gen_tests! {
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
#[cold]
|
#[cold]
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
fn shared_object() {
|
fn dylib() {
|
||||||
add(crate::Config::new(
|
add(crate::Config::new(
|
||||||
crate::Engine::SharedObject,
|
crate::Engine::Dylib,
|
||||||
crate::Compiler::Singlepass
|
crate::Compiler::Singlepass
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -94,10 +94,10 @@ gen_tests! {
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
#[cold]
|
#[cold]
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
fn shared_object() {
|
fn dylib() {
|
||||||
add(crate::Config::new(
|
add(crate::Config::new(
|
||||||
crate::Engine::SharedObject,
|
crate::Engine::Dylib,
|
||||||
crate::Compiler::Cranelift
|
crate::Compiler::Cranelift
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -117,10 +117,10 @@ gen_tests! {
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
#[cold]
|
#[cold]
|
||||||
#[cfg(feature = "shared-object")]
|
#[cfg(feature = "dylib")]
|
||||||
fn shared_object() {
|
fn dylib() {
|
||||||
add(crate::Config::new(
|
add(crate::Config::new(
|
||||||
crate::Engine::SharedObject,
|
crate::Engine::Dylib,
|
||||||
crate::Compiler::LLVM
|
crate::Compiler::LLVM
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,5 @@ anyhow = "1.0"
|
|||||||
target-lexicon = "0.12"
|
target-lexicon = "0.12"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-shared-object = []
|
test-dylib = []
|
||||||
test-universal = []
|
test-universal = []
|
||||||
|
@ -7,12 +7,14 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(target = "wasi")] {
|
#[cfg(target = "wasi")]
|
||||||
|
{
|
||||||
println!("stdin: {}", unsafe { isatty(0) });
|
println!("stdin: {}", unsafe { isatty(0) });
|
||||||
println!("stdout: {}", unsafe { isatty(1) });
|
println!("stdout: {}", unsafe { isatty(1) });
|
||||||
println!("stderr: {}", unsafe { isatty(2) });
|
println!("stderr: {}", unsafe { isatty(2) });
|
||||||
}
|
}
|
||||||
#[cfg(not(target = "wasi"))] {
|
#[cfg(not(target = "wasi"))]
|
||||||
|
{
|
||||||
println!("stdin: 1");
|
println!("stdin: 1");
|
||||||
println!("stdout: 1");
|
println!("stdout: 1");
|
||||||
println!("stderr: 1");
|
println!("stderr: 1");
|
||||||
|
@ -10,10 +10,7 @@ pub const BYTE_STR: &'static [u8] = b"abcdefghijklmnopqrstuvwxyz";
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(not(target_os = "wasi"))]
|
#[cfg(not(target_os = "wasi"))]
|
||||||
do_logic_on_path(
|
do_logic_on_path("test_fs/hamlet/act1/abc", "test_fs/hamlet/act1/abc");
|
||||||
"test_fs/hamlet/act1/abc",
|
|
||||||
"test_fs/hamlet/act1/abc",
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(target_os = "wasi")]
|
#[cfg(target_os = "wasi")]
|
||||||
do_logic_on_path("/act1/abc", "act1-again/abc");
|
do_logic_on_path("/act1/abc", "act1-again/abc");
|
||||||
|
Reference in New Issue
Block a user