Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into singlepass-opt-1
Browse files Browse the repository at this point in the history
  • Loading branch information
losfair committed Jun 9, 2020
2 parents 47829d1 + ee9da72 commit 5850fed
Show file tree
Hide file tree
Showing 35 changed files with 1,540 additions and 280 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ jobs:
- run: make test
- name: Build and Test C API
run: |
make capi
make build-capi
make test-capi-cranelift
if: matrix.os != 'windows-latest'
- name: Build C API on Windows
run: make capi
run: make build-capi
if: matrix.os == 'windows-latest'
- name: Build Wasmer binary
run: |
make build-wasmer
# TODO: build wapm
# make build-wapm
make package
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
**/target
**/*.rs.bk
/artifacts
.DS_Store
.idea
**/.vscode
install/
capi/
api-docs/
api-docs-repo/
/.cargo_home/
/package/
/dist/
/wapm-cli/

# Generated by tests on Android
/avd
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ rustc_version = "0.2"
[dev-dependencies]
anyhow = "1.0"
blake3 = "0.3"
lazy_static = "1.4"
test-utils = { path = "tests/lib/test-utils" }
wasmer-engine-dummy = { path = "tests/lib/engine-dummy" }

Expand Down
196 changes: 142 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# uname only works in *Unix like systems
ifneq ($(OS), Windows_NT)
ARCH := $(shell uname -m)
UNAME_S := $(shell uname -s)
ARCH := $(shell uname -m)
UNAME_S := $(shell uname -s)
else
# We can assume, if in windows it will likely be in x86_64
ARCH := x86_64
UNAME_S :=
# We can assume, if in windows it will likely be in x86_64
ARCH := x86_64
UNAME_S :=
endif

compilers :=
Expand All @@ -14,38 +14,38 @@ compilers :=
RUST_VERSION := $(shell rustc -V)

ifneq (, $(findstring nightly,$(RUST_VERSION)))
# Singlepass doesn't work yet on Windows
ifneq ($(OS), Windows_NT)
compilers += singlepass
endif
# Singlepass doesn't work yet on Windows
ifneq ($(OS), Windows_NT)
compilers += singlepass
endif
endif

ifeq ($(ARCH), x86_64)
# In X64, Cranelift is enabled
compilers += cranelift
# LLVM could be enabled if not in Windows
ifneq ($(OS), Windows_NT)
# Autodetect LLVM from llvm-config
ifneq (, $(shell which llvm-config))
LLVM_VERSION := $(shell llvm-config --version)
# If findstring is not empty, then it have found the value
ifneq (, $(findstring 10,$(LLVM_VERSION)))
compilers += llvm
endif
else
ifneq (, $(shell which llvm-config-10))
compilers += llvm
endif
endif
endif
# In X64, Cranelift is enabled
compilers += cranelift
# LLVM could be enabled if not in Windows
ifneq ($(OS), Windows_NT)
# Autodetect LLVM from llvm-config
ifneq (, $(shell which llvm-config))
LLVM_VERSION := $(shell llvm-config --version)
# If findstring is not empty, then it have found the value
ifneq (, $(findstring 10,$(LLVM_VERSION)))
compilers += llvm
endif
else
ifneq (, $(shell which llvm-config-10))
compilers += llvm
endif
endif
endif
endif

compilers := $(filter-out ,$(compilers))

ifneq ($(OS), Windows_NT)
bold := $(shell tput bold)
green := $(shell tput setaf 2)
reset := $(shell tput sgr0)
bold := $(shell tput bold)
green := $(shell tput setaf 2)
reset := $(shell tput sgr0)
endif


Expand All @@ -55,51 +55,139 @@ compiler_features_spaced := $(foreach compiler,$(compilers),$(compiler))
compiler_features := --features "$(compiler_features_spaced)"


tests-spec-update-testsuite:
git subtree pull --prefix tests/wast/spec https://github.com/WebAssembly/testsuite.git master --squash
############
# Building #
############

test:
cargo test --release $(compiler_features)

release:
build-wasmer:
cargo build --release $(compiler_features)

doc:
cargo doc --all-features --document-private-items
WAPM_VERSION = v0.5.0
build-wapm:
git clone --branch $(WAPM_VERSION) https://github.com/wasmerio/wapm-cli.git
cargo build --release --manifest-path wapm-cli/Cargo.toml --features "telemetry update-notifications"

doc-local:
cargo doc --all-features --document-private-items --no-deps
build-docs:
cargo doc --release --all-features --document-private-items --no-deps

RUSTFLAGS := "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects" # TODO: add `-D missing-docs`
lint:
cargo fmt --all -- --check
RUSTFLAGS=${RUSTFLAGS} cargo clippy $(compiler_features)
build-docs-capi:
cd lib/c-api/ && doxygen doxyfile

# We use cranelift as the default backend for the capi for now
build-capi: build-capi-cranelift

capi-singlepass:
build-capi-singlepass:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi

capi-cranelift:
build-capi-cranelift:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi

capi-llvm:
build-capi-llvm:
cargo build --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi

# We use cranelift as the default backend for the capi for now
capi: capi-cranelift

test-capi-singlepass: capi-singlepass
###########
# Testing #
###########

test:
cargo test --release $(compiler_features)

test-capi-singlepass: build-capi-singlepass
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features singlepass-backend,wasi
--no-default-features --features singlepass,wasi

test-capi-cranelift: capi-cranelift
test-capi-cranelift: build-capi-cranelift
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features cranelift-backend,wasi -- --nocapture --test-threads=1
--no-default-features --features cranelift,wasi -- --nocapture --test-threads=1

test-capi-llvm: capi-llvm
test-capi-llvm: build-capi-llvm
cargo test --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features llvm-backend,wasi
--no-default-features --features llvm,wasi

test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-emscripten

#############
# Packaging #
#############

package-wasmer:
mkdir -p "package/bin"
ifeq ($(OS), Windows_NT)
cp target/release/wasmer.exe package/bin/
else
cp target/release/wasmer package/bin/
endif

# Comment out WAPM for now to speed up release process.
# cp ./wapm-cli/target/release/wapm package/bin/
# # Create the wax binary as symlink to wapm
# cd package/bin/ && ln -sf wapm wax && chmod +x wax

package-capi:
mkdir -p "package/include"
mkdir -p "package/lib"
cp lib/c-api/wasmer.h* package/include
cp lib/c-api/doc/index.md package/include/README.md
ifeq ($(OS), Windows_NT)
cp target/release/wasmer_c_api.dll package/lib
cp target/release/wasmer_c_api.lib package/lib
else
ifeq ($(UNAME_S), Darwin)
cp target/release/libwasmer_c_api.dylib package/lib/libwasmer.dylib
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a
# Fix the rpath for the dylib
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib
else
cp target/release/libwasmer_c_api.so package/lib/libwasmer.so
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a
endif
endif

package-docs: build-docs build-docs-capi
mkdir -p "package/docs"
mkdir -p "package/docs/c"
cp -R target/doc package/docs/crates
cp -R lib/c-api/doc/html package/docs/c-api
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=rust/wasmer_runtime/index.html">' > package/docs/index.html
echo '<!-- Build $(SOURCE_VERSION) --><meta http-equiv="refresh" content="0; url=wasmer_runtime/index.html">' > package/docs/crates/index.html

package: package-wasmer package-capi
cp LICENSE package/LICENSE
cp ATTRIBUTIONS.md package/ATTRIBUTIONS
mkdir -p dist
ifeq ($(OS), Windows_NT)
iscc src/windows-installer/wasmer.iss
cp src/windows-installer/WasmerInstaller.exe dist/wasmer-windows.exe
else
cp LICENSE package/LICENSE
cp ATTRIBUTIONS.md package/ATTRIBUTIONS
tar -C package -zcvf wasmer.tar.gz bin lib include LICENSE ATTRIBUTIONS
cp ./wasmer.tar.gz ./dist/$(shell ./scripts/binary-name.sh)
endif

#################
# Miscellaneous #
#################

# Updates the spectests from the repo
update-testsuite:
git subtree pull --prefix tests/wast/spec https://github.com/WebAssembly/testsuite.git master --squash

RUSTFLAGS := "-D dead-code -D nonstandard-style -D unused-imports -D unused-mut -D unused-variables -D unused-unsafe -D unreachable-patterns -D bad-style -D improper-ctypes -D unused-allocation -D unused-comparisons -D while-true -D unconditional-recursion -D bare-trait-objects" # TODO: add `-D missing-docs`
lint:
cargo fmt --all -- --check
RUSTFLAGS=${RUSTFLAGS} cargo clippy $(compiler_features)

install-local: package
tar -C ~/.wasmer -zxvf wasmer.tar.gz

publish-docs:
git clone -b "gh-pages" --depth=1 https://wasmerbot:$(GITHUB_DOCS_TOKEN)@github.com/wasmerio/wasmer.git api-docs-repo
cp -R package/docs/* api-docs-repo/
cd api-docs-repo && git add index.html crates/* c-api/*
cd api-docs-repo && (git diff-index --quiet HEAD || git commit -m "Publishing GitHub Pages")
# cd api-docs-repo && git push origin gh-pages
2 changes: 1 addition & 1 deletion lib/api/src/externals/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl std::fmt::Debug for Function {
}
}

/// This trait is one that all dynamic funcitons must fulfill.
/// This trait is one that all dynamic functions must fulfill.
trait VMDynamicFunction {
fn call(&self, args: &[Val]) -> Result<Vec<Val>, RuntimeError>;
fn function_type(&self) -> &FunctionType;
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl Module {
}

/// The ABI of the ModuleInfo is very unstable, we refactor it very often.
/// This funciton is public because in some cases it can be useful to get some
/// This function is public because in some cases it can be useful to get some
/// extra information from the module.
///
/// However, the usage is highly discouraged.
Expand Down
14 changes: 9 additions & 5 deletions lib/c-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "wasmer-runtime-c-api"
name = "wasmer-c-api"
version = "0.16.2"
description = "Wasmer C API library"
documentation = "https://wasmerio.github.io/wasmer/c/runtime-c-api/"
documentation = "https://wasmerio.github.io/wasmer/c-api/"
license = "MIT"
authors = ["The Wasmer Engineering Team <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
Expand Down Expand Up @@ -49,13 +49,17 @@ optional = true

[features]
default = ["cranelift-backend", "wasi"]
singlepass-backend = ["wasmer/singlepass"]
cranelift-backend = ["wasmer/cranelift"]
llvm-backend = ["wasmer/llvm"]
singlepass = ["wasmer/singlepass"]
cranelift = ["wasmer/cranelift"]
llvm = ["wasmer/llvm"]
wasi = ["wasmer-wasi"]
#emscripten = ["wasmer-emscripten"]
# used to avoid generating standard Wasm C API types in our header files
ignore-wasm-c-api = []
# This is for compatibility for old usage
singlepass-backend = ["singlepass"]
cranelift-backend = ["cranelift"]
llvm-backend = ["llvm"]

[build-dependencies]
cbindgen = { git = "https://github.com/eqrion/cbindgen", version = "0.14" }
Loading

0 comments on commit 5850fed

Please sign in to comment.