Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ae297be
wasm: add wasmtime runtime
mathetake Nov 7, 2020
ac09b65
add build files for wasmtime/c-api
mathetake Nov 7, 2020
3f62cc6
fix doc checks
mathetake Nov 7, 2020
6c37091
update proxy-wasm-cpp-host
mathetake Nov 7, 2020
4b4f8b2
remove unnecessary wasmtime features
mathetake Nov 7, 2020
eb72994
add wasmtime to dictionary
mathetake Nov 7, 2020
a67720a
define ENVOY_WASM_WASMTIME
mathetake Nov 7, 2020
893a914
define=wasmtime in bazel.compile_time_options
mathetake Nov 7, 2020
28aefc4
fix format
mathetake Nov 7, 2020
a871b14
update wasmtime to 0.21.0
mathetake Nov 8, 2020
b156df5
use wasm-c-api archive
mathetake Nov 10, 2020
6a8d023
Update cpp-host
mathetake Nov 10, 2020
58e0a03
review: wasmtime -> Wasmtime, update proxy-wasm-cpp-host
mathetake Nov 10, 2020
660257a
review: drop "all", cleanup BUILD file.
PiotrSikora Nov 10, 2020
b066ad8
review: add missing file.
PiotrSikora Nov 10, 2020
e0c3cf1
Update proxy-wasm-cpp-host
mathetake Nov 10, 2020
6d83c0f
review: don't build V8 with other runtimes.
PiotrSikora Nov 10, 2020
21de783
review: update examples.
PiotrSikora Nov 10, 2020
c7a7eb9
Merge pull request #1 from PiotrSikora/wasmtime-all
mathetake Nov 10, 2020
b7d6930
Update proxy-wasm-cpp-host: point to origin
mathetake Nov 10, 2020
2c5dc57
Update release date of proxy-wasm-cpp-host
mathetake Nov 10, 2020
ec4d2dd
Add wasmtime test in bazel.compile_time_options CI target
mathetake Nov 10, 2020
b00c82a
Review: clean up proxy-wasm-cpp-host BUILD file
mathetake Nov 10, 2020
c39664e
Fix style
mathetake Nov 10, 2020
e4fa56e
Review: specify wasm runtimes explicitly in ci, and fix release dates…
mathetake Nov 10, 2020
6ed3a2b
Fix typo in bazel build in bazel.compile_time_options target
mathetake Nov 10, 2020
c779e33
Fix typo in bazel build in bazel.compile_time_options target: 2
mathetake Nov 10, 2020
1a6bf15
Style: remove unnecessary white spaces
mathetake Nov 10, 2020
4b314c5
Review: fix release dates of proxy-wasm-cpp-{host,sdk}
mathetake Nov 11, 2020
2dbbd26
Review: Build wasmtime first
mathetake Nov 11, 2020
2e38d03
Review: Remove bazel build for wasmtime
mathetake Nov 11, 2020
98f7f3e
Merge upstream
mathetake Nov 11, 2020
0210faa
Review: Add comment about wasm-c-api's version
mathetake Nov 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,6 @@ config_setting(
)

# TODO: consider converting WAVM VM support to an extension (https://github.com/envoyproxy/envoy/issues/12574)
config_setting(
name = "wasm_all",
values = {"define": "wasm=enabled"},
)

config_setting(
name = "wasm_wavm",
values = {"define": "wasm=wavm"},
Expand All @@ -330,6 +325,11 @@ config_setting(
values = {"define": "wasm=v8"},
)

config_setting(
name = "wasm_wasmtime",
values = {"define": "wasm=wasmtime"},
)

config_setting(
name = "wasm_none",
values = {"define": "wasm=disabled"},
Expand Down
4 changes: 2 additions & 2 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ load(
_envoy_select_hot_restart = "envoy_select_hot_restart",
_envoy_select_new_codecs_in_integration_tests = "envoy_select_new_codecs_in_integration_tests",
_envoy_select_wasm = "envoy_select_wasm",
_envoy_select_wasm_all_v8_wavm_none = "envoy_select_wasm_all_v8_wavm_none",
_envoy_select_wasm_v8 = "envoy_select_wasm_v8",
_envoy_select_wasm_wasmtime = "envoy_select_wasm_wasmtime",
_envoy_select_wasm_wavm = "envoy_select_wasm_wavm",
)
load(
Expand Down Expand Up @@ -181,8 +181,8 @@ envoy_select_boringssl = _envoy_select_boringssl
envoy_select_google_grpc = _envoy_select_google_grpc
envoy_select_hot_restart = _envoy_select_hot_restart
envoy_select_wasm = _envoy_select_wasm
envoy_select_wasm_all_v8_wavm_none = _envoy_select_wasm_all_v8_wavm_none
envoy_select_wasm_wavm = _envoy_select_wasm_wavm
envoy_select_wasm_wasmtime = _envoy_select_wasm_wasmtime
envoy_select_wasm_v8 = _envoy_select_wasm_v8
envoy_select_new_codecs_in_integration_tests = _envoy_select_new_codecs_in_integration_tests

Expand Down
11 changes: 4 additions & 7 deletions bazel/envoy_select.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,22 @@ def envoy_select_wasm(xs):

def envoy_select_wasm_v8(xs):
return select({
"@envoy//bazel:wasm_wasmtime": [],
"@envoy//bazel:wasm_wavm": [],
"@envoy//bazel:wasm_none": [],
"//conditions:default": xs,
})

def envoy_select_wasm_wavm(xs):
return select({
"@envoy//bazel:wasm_all": xs,
"@envoy//bazel:wasm_wavm": xs,
"//conditions:default": [],
})

def envoy_select_wasm_all_v8_wavm_none(xs1, xs2, xs3, xs4):
def envoy_select_wasm_wasmtime(xs):
return select({
"@envoy//bazel:wasm_all": xs1,
"@envoy//bazel:wasm_v8": xs2,
"@envoy//bazel:wasm_wavm": xs3,
"@envoy//bazel:wasm_none": xs4,
"//conditions:default": xs2,
"@envoy//bazel:wasm_wasmtime": xs,
"//conditions:default": [],
})

# Select the given values if use legacy codecs in test is on in the current build.
Expand Down
59 changes: 23 additions & 36 deletions bazel/external/proxy_wasm_cpp_host.BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load(
"@envoy//bazel:envoy_build_system.bzl",
"envoy_select_wasm_all_v8_wavm_none",
"envoy_select_wasm_v8",
"envoy_select_wasm_wasmtime",
"envoy_select_wasm_wavm",
)

Expand All @@ -21,38 +21,23 @@ cc_library(
cc_library(
name = "lib",
# Note that the select cannot appear in the glob.
srcs = envoy_select_wasm_all_v8_wavm_none(
glob(
[
"src/**/*.h",
"src/**/*.cc",
],
),
glob(
[
"src/**/*.h",
"src/**/*.cc",
],
exclude = ["src/wavm/*"],
),
glob(
[
"src/**/*.h",
"src/**/*.cc",
],
exclude = ["src/v8/*"],
),
glob(
[
"src/**/*.h",
"src/**/*.cc",
],
exclude = [
"src/wavm/*",
"src/v8/*",
],
),
),
srcs = glob(
[
"src/**/*.h",
"src/**/*.cc",
],
exclude = [
"src/v8/*.cc",
"src/wavm/*.cc",
"src/wasmtime/*.cc",
],
) + envoy_select_wasm_v8(glob([
"src/v8/*.cc",
])) + envoy_select_wasm_wavm(glob([
"src/wavm/*.cc",
])) + envoy_select_wasm_wasmtime(glob([
"src/wasmtime/*.cc",
])),
copts = envoy_select_wasm_wavm([
'-DWAVM_API=""',
"-Wno-non-virtual-dtor",
Expand All @@ -68,9 +53,11 @@ cc_library(
"//external:zlib",
"@proxy_wasm_cpp_sdk//:api_lib",
"@proxy_wasm_cpp_sdk//:common_lib",
] + envoy_select_wasm_wavm([
"@envoy//bazel/foreign_cc:wavm",
]) + envoy_select_wasm_v8([
] + envoy_select_wasm_v8([
"//external:wee8",
]) + envoy_select_wasm_wavm([
"@envoy//bazel/foreign_cc:wavm",
]) + envoy_select_wasm_wasmtime([
"@com_github_wasm_c_api//:wasmtime_lib",
]),
)
19 changes: 19 additions & 0 deletions bazel/external/wasm-c-api.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

package(default_visibility = ["//visibility:public"])

cc_library(
name = "wasmtime_lib",
hdrs = [
"include/wasm.h",
],
defines = [
"ENVOY_WASM_WASMTIME",
],
include_prefix = "wasmtime",
deps = [
"@com_github_wasmtime//:rust_c_api",
],
)
32 changes: 32 additions & 0 deletions bazel/external/wasmtime.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library")

licenses(["notice"]) # Apache 2

package(default_visibility = ["//visibility:public"])

cc_library(
name = "helpers_lib",
srcs = [
"crates/runtime/src/helpers.c",
],
visibility = ["//visibility:private"],
)

rust_library(
name = "rust_c_api",
srcs = glob(["crates/c-api/src/**/*.rs"]),
crate_root = "crates/c-api/src/lib.rs",
crate_type = "staticlib",
edition = "2018",
proc_macro_deps = [
"@proxy_wasm_cpp_host//bazel/cargo:wasmtime_c_api_macros",
],
deps = [
":helpers_lib",
"@proxy_wasm_cpp_host//bazel/cargo:anyhow",
"@proxy_wasm_cpp_host//bazel/cargo:env_logger",
"@proxy_wasm_cpp_host//bazel/cargo:once_cell",
"@proxy_wasm_cpp_host//bazel/cargo:wasmtime",
],
)
14 changes: 14 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def envoy_dependencies(skip_targets = []):

_org_llvm_llvm()
_com_github_wavm_wavm()
_com_github_wasmtime()
_com_github_wasm_c_api()

switched_rules_by_language(
name = "com_google_googleapis_imports",
Expand Down Expand Up @@ -864,6 +866,18 @@ def _com_github_wavm_wavm():
actual = "@envoy//bazel/foreign_cc:wavm",
)

def _com_github_wasmtime():
external_http_archive(
name = "com_github_wasmtime",
build_file = "@envoy//bazel/external:wasmtime.BUILD",
)

def _com_github_wasm_c_api():
external_http_archive(
name = "com_github_wasm_c_api",
build_file = "@envoy//bazel/external:wasm-c-api.BUILD",
)

def _kafka_deps():
# This archive contains Kafka client source code.
# We are using request/response message format files to generate parser code.
Expand Down
2 changes: 2 additions & 0 deletions bazel/repositories_extra.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_python//python:repositories.bzl", "py_repositories")
load("@rules_python//python:pip.bzl", "pip3_import", "pip_repositories")
load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_raze__fetch_remote_crates")

# Python dependencies.
def _python_deps():
Expand Down Expand Up @@ -100,3 +101,4 @@ def _python_deps():
# Envoy deps that rely on a first stage of dependency loading in envoy_dependencies().
def envoy_dependencies_extra():
_python_deps()
proxy_wasm_cpp_host_raze__fetch_remote_crates()
54 changes: 51 additions & 3 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,46 @@ REPOSITORY_LOCATIONS_SPEC = dict(
],
cpe = "cpe:2.3:a:webassembly_virtual_machine_project:webassembly_virtual_machine:*",
),
com_github_wasmtime = dict(
project_name = "wasmtime",
project_desc = "A standalone runtime for WebAssembly",
project_url = "https://github.com/bytecodealliance/wasmtime",
version = "0.21.0",
sha256 = "7874feb1026bbef06796bd5ab80e73f15b8e83752bde8dc93994f5bc039a4952",
strip_prefix = "wasmtime-{version}",
urls = ["https://github.com/bytecodealliance/wasmtime/archive/v{version}.tar.gz"],
release_date = "2020-11-05",
use_category = ["dataplane_ext"],
extensions = [
"envoy.access_loggers.wasm",
"envoy.bootstrap.wasm",
"envoy.filters.http.wasm",
"envoy.filters.network.wasm",
"envoy.stat_sinks.wasm",
],
cpe = "cpe:2.3:a:webassembly_virtual_machine_project:webassembly_virtual_machine:*",
),
com_github_wasm_c_api = dict(
project_name = "wasm-c-api",
project_desc = "WebAssembly C and C++ API",
project_url = "https://github.com/WebAssembly/wasm-c-api",
# this is the submodule's specific commit used by wasmtime
# https://github.com/bytecodealliance/wasmtime/tree/v0.21.0/crates/c-api
version = "d9a80099d496b5cdba6f3fe8fc77586e0e505ddc",
sha256 = "aea8cd095e9937f1e14f2c93e026317b197eb2345e7a817fe3932062eb7b792c",
strip_prefix = "wasm-c-api-{version}",
urls = ["https://github.com/WebAssembly/wasm-c-api/archive/{version}.tar.gz"],
release_date = "2019-11-14",
use_category = ["dataplane_ext"],
extensions = [
"envoy.access_loggers.wasm",
"envoy.bootstrap.wasm",
"envoy.filters.http.wasm",
"envoy.filters.network.wasm",
"envoy.stat_sinks.wasm",
],
cpe = "N/A",
),
io_opencensus_cpp = dict(
project_name = "OpenCensus C++",
project_desc = "OpenCensus tracing library",
Expand Down Expand Up @@ -830,8 +870,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "WebAssembly for Proxies (C++ host implementation)",
project_desc = "WebAssembly for Proxies (C++ host implementation)",
project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-host",
version = "b7d3d13d75bb6b50f192252258bb9583bf723fa4",
sha256 = "ae639f94a80adbe915849bccb32346720c59a579db09918e44aefafed6cbb100",
version = "4741d2f1cd5eb250f66d0518238c333353259d56",
sha256 = "30fc4becfcc5a95ac875fc5a0658a91aa7ddedd763b52d7810c13ed35d9d81aa",
strip_prefix = "proxy-wasm-cpp-host-{version}",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-host/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
Expand Down Expand Up @@ -864,8 +904,16 @@ REPOSITORY_LOCATIONS_SPEC = dict(
sha256 = "426a7712af597d90301dcc29e63d62de5c2e09fb347692e89abb775ec97c74fe",
strip_prefix = "rules_rust-{version}",
urls = ["https://github.com/bazelbuild/rules_rust/archive/{version}.tar.gz"],
use_category = ["test_only"],
use_category = ["dataplane_ext"],
extensions = [
"envoy.access_loggers.wasm",
"envoy.bootstrap.wasm",
"envoy.filters.http.wasm",
"envoy.filters.network.wasm",
"envoy.stat_sinks.wasm",
],
release_date = "2020-10-21",
cpe = "N/A",
),
rules_antlr = dict(
project_name = "ANTLR Rules for Bazel",
Expand Down
16 changes: 9 additions & 7 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then
"--define" "boringssl=fips"
"--define" "log_debug_assert_in_release=enabled"
"--define" "quiche=enabled"
"--define" "wasm=wavm"
"--define" "path_normalization_by_default=true"
"--define" "deprecated_features=disabled"
"--define" "use_new_codecs_in_integration_tests=false"
Expand All @@ -297,19 +296,22 @@ elif [[ "$CI_TARGET" == "bazel.compile_time_options" ]]; then
TEST_TARGETS=("@envoy//test/...")
fi
# Building all the dependencies from scratch to link them against libc++.
echo "Building and testing ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" "${COMPILE_TIME_OPTIONS[@]}" -c dbg "${TEST_TARGETS[@]}" --test_tag_filters=-nofips --build_tests_only
echo "Building and testing with wasm=wasmtime: ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" --define wasm=wasmtime "${COMPILE_TIME_OPTIONS[@]}" -c dbg "${TEST_TARGETS[@]}" --test_tag_filters=-nofips --build_tests_only

echo "Building and testing with wasm=wavm: ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" --define wasm=wavm "${COMPILE_TIME_OPTIONS[@]}" -c dbg "${TEST_TARGETS[@]}" --test_tag_filters=-nofips --build_tests_only

# Legacy codecs "--define legacy_codecs_in_integration_tests=true" should also be tested in
# integration tests with asan.
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" "${COMPILE_TIME_OPTIONS[@]}" -c dbg @envoy//test/integration/... --config=clang-asan --build_tests_only
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" --define wasm=wavm "${COMPILE_TIME_OPTIONS[@]}" -c dbg @envoy//test/integration/... --config=clang-asan --build_tests_only

# "--define log_debug_assert_in_release=enabled" must be tested with a release build, so run only
# these tests under "-c opt" to save time in CI.
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" "${COMPILE_TIME_OPTIONS[@]}" -c opt @envoy//test/common/common:assert_test @envoy//test/server:server_test
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" --define wasm=wavm "${COMPILE_TIME_OPTIONS[@]}" -c opt @envoy//test/common/common:assert_test @envoy//test/server:server_test

echo "Building binary..."
bazel build "${BAZEL_BUILD_OPTIONS[@]}" "${COMPILE_TIME_OPTIONS[@]}" -c dbg @envoy//source/exe:envoy-static --build_tag_filters=-nofips
echo "Building binary with wasm=wavm..."
bazel build "${BAZEL_BUILD_OPTIONS[@]}" --define wasm=wavm "${COMPILE_TIME_OPTIONS[@]}" -c dbg @envoy//source/exe:envoy-static --build_tag_filters=-nofips
collect_build_profile build
exit 0
elif [[ "$CI_TARGET" == "bazel.api" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion examples/wasm-cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ envoy_package()

selects.config_setting_group(
name = "include_wasm_config",
match_all = ["//bazel:x86", "//bazel:wasm_all"],
match_all = ["//bazel:x86", "//bazel:wasm_v8"],
)

filegroup(
Expand Down
10 changes: 10 additions & 0 deletions source/extensions/common/wasm/wasm_vm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#if defined(ENVOY_WASM_WAVM)
#include "include/proxy-wasm/wavm.h"
#endif
#if defined(ENVOY_WASM_WASMTIME)
#include "include/proxy-wasm/wasmtime.h"
#endif

using ContextBase = proxy_wasm::ContextBase;
using Word = proxy_wasm::Word;
Expand Down Expand Up @@ -82,6 +85,13 @@ WasmVmPtr createWasmVm(absl::string_view runtime, const Stats::ScopeSharedPtr& s
auto wasm = proxy_wasm::createWavmVm();
wasm->integration() = getWasmExtension()->createEnvoyWasmVmIntegration(scope, runtime, "wavm");
return wasm;
#endif
#if defined(ENVOY_WASM_WASMTIME)
} else if (runtime == WasmRuntimeNames::get().Wasmtime) {
auto wasm = proxy_wasm::createWasmtimeVm();
wasm->integration() =
getWasmExtension()->createEnvoyWasmVmIntegration(scope, runtime, "wasmtime");
return wasm;
#endif
} else {
ENVOY_LOG_TO_LOGGER(
Expand Down
Loading