Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7d5f240
wasm: update Proxy-Wasm C++ SDK to latest.
PiotrSikora Jan 17, 2022
01f7cdc
review: update use_category for emsdk.
PiotrSikora Jan 17, 2022
7c3efe8
review: add emdwp tool.
PiotrSikora Jan 17, 2022
b1459cd
review: try using /bin/false instead.
PiotrSikora Jan 17, 2022
e2b6284
review: don't advertise "per_object_debug_info" feature.
PiotrSikora Jan 18, 2022
fdae2ca
review: allow @emsdk to be imported into non-x86_64 workspace.
PiotrSikora Jan 18, 2022
539aa58
review: remove sanitizers from flags propagated to Emscripten.
PiotrSikora Jan 18, 2022
9fd86f5
review: update Proxy-Wasm C++ SDK to fix tags.
PiotrSikora Jan 18, 2022
6ec9108
review: skip some tests that fail on WAMR due to a small stack size.
PiotrSikora Jan 18, 2022
c59d140
review: add comments to the patch.
PiotrSikora Jan 18, 2022
7865cf5
review: use the default (latest) version of Emscripten.
PiotrSikora Jan 18, 2022
771b8b3
review: use uintptr_t to fix Windows build.
PiotrSikora Jan 18, 2022
9ea9536
review: update condition for excluding C++ tests.
PiotrSikora Jan 18, 2022
ff158ce
review: better approach to sanitizers.
PiotrSikora Jan 18, 2022
33ef8a8
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Jan 18, 2022
c97a2da
review: non-ambiguous select.
PiotrSikora Jan 18, 2022
caceac1
review: fix visibility.
PiotrSikora Jan 18, 2022
36e186d
review: uintptr_t -> unsigned int.
PiotrSikora Jan 18, 2022
691f7a5
review: bump timeout for a test.
PiotrSikora Jan 18, 2022
aaae279
review: suppress warning on Windows.
PiotrSikora Jan 18, 2022
ef0f5b4
review: ignore unknown pragmas.
PiotrSikora Jan 18, 2022
c5a4f72
review: revert changes for excluding C++ tests.
PiotrSikora Jan 20, 2022
e11caee
review: revert hacks for Windows.
PiotrSikora Jan 20, 2022
60a178c
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Jan 20, 2022
c5aeb17
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Feb 9, 2022
29591f5
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Mar 11, 2022
7387adf
review: update to emsdk v3.1.7 with Bazel fixes.
PiotrSikora Mar 11, 2022
7f503b0
review: undo no longer necessary changes in tests.
PiotrSikora Mar 11, 2022
1b7584c
review: use envoy_wasm_cc_binary(protobuf="lite|full").
PiotrSikora Mar 11, 2022
a61fda1
review: style.
PiotrSikora Mar 11, 2022
4a00dd7
review: bump Proxy-Wasm C++ SDK.
PiotrSikora Mar 11, 2022
89dfafc
review: update Proxy-Wasm C++ SDK.
PiotrSikora Mar 14, 2022
99d087d
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Mar 14, 2022
b684a75
review: use merged commit.
PiotrSikora Mar 15, 2022
c87e7ce
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Mar 15, 2022
b153d34
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Mar 17, 2022
515752f
Merge remote-tracking branch 'origin/main' into PiotrSikora/emsdk_v3.1.1
PiotrSikora Mar 18, 2022
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
2 changes: 2 additions & 0 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ load("@rules_rust//rust:repositories.bzl", "rust_repositories")
load("@rules_antlr//antlr:deps.bzl", "antlr_dependencies")
load("@proxy_wasm_rust_sdk//bazel:dependencies.bzl", "proxy_wasm_rust_sdk_dependencies")
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")

# go version for rules_go
GO_VERSION = "1.17.5"
Expand All @@ -30,6 +31,7 @@ def envoy_dependency_imports(go_version = GO_VERSION):
)
rules_cc_dependencies()
rules_cc_toolchains()
emsdk_emscripten_deps(emscripten_version = "3.1.1")

custom_exec_properties(
name = "envoy_large_machine_exec_property",
Expand Down
15 changes: 3 additions & 12 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def envoy_dependencies(skip_targets = []):
_upb()
_proxy_wasm_cpp_sdk()
_proxy_wasm_cpp_host()
_emscripten_toolchain()
_emsdk()
_rules_fuzzing()
external_http_archive("proxy_wasm_rust_sdk")
external_http_archive("com_googlesource_code_re2")
Expand Down Expand Up @@ -939,17 +939,8 @@ def _proxy_wasm_cpp_sdk():
def _proxy_wasm_cpp_host():
external_http_archive(name = "proxy_wasm_cpp_host")

def _emscripten_toolchain():
external_http_archive(
name = "emscripten_toolchain",
build_file_content = _build_all_content(exclude = [
"upstream/emscripten/cache/is_vanilla.txt",
".emscripten_sanity",
]),
patch_cmds = [
"if [[ \"$(uname -m)\" == \"x86_64\" ]]; then ./emsdk install 2.0.7 && ./emsdk activate --embedded 2.0.7; fi",
],
)
def _emsdk():
external_http_archive(name = "emsdk")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not dig into it, now we can install emsdk on OS except x86?


def _com_github_google_jwt_verify():
external_http_archive("com_github_google_jwt_verify")
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:pip.bzl", "pip_install", "pip_parse")
load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_fetch_remote_crates")
load("@emsdk//:deps.bzl", emsdk_deps = "deps")
load("//bazel/external/cargo:crates.bzl", "raze_fetch_remote_crates")

# Python dependencies.
Expand Down Expand Up @@ -33,5 +34,6 @@ def _python_deps():
# Envoy deps that rely on a first stage of dependency loading in envoy_dependencies().
def envoy_dependencies_extra():
_python_deps()
emsdk_deps()
proxy_wasm_cpp_host_fetch_remote_crates()
raze_fetch_remote_crates()
17 changes: 9 additions & 8 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_name = "WebAssembly for Proxies (C++ SDK)",
project_desc = "WebAssembly for Proxies (C++ SDK)",
project_url = "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk",
version = "fd0be8405db25de0264bdb78fae3a82668c03782",
sha256 = "c57de2425b5c61d7f630c5061e319b4557ae1f1c7526e5a51c33dc1299471b08",
version = "011ced83a6995167147c00d5baf40a7c356ceefa",
Comment thread
PiotrSikora marked this conversation as resolved.
Outdated
sha256 = "64c31d8b01dd03b852186ea0405b6e78fe9b2dfa3cf9ffd30dd47be2f7f2c06f",
strip_prefix = "proxy-wasm-cpp-sdk-{version}",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],
Expand All @@ -1021,7 +1021,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
"envoy.wasm.runtime.wavm",
"envoy.wasm.runtime.wasmtime",
],
release_date = "2021-06-24",
release_date = "2022-01-17",
cpe = "N/A",
),
proxy_wasm_cpp_host = dict(
Expand Down Expand Up @@ -1060,16 +1060,17 @@ REPOSITORY_LOCATIONS_SPEC = dict(
release_date = "2021-07-13",
cpe = "N/A",
),
emscripten_toolchain = dict(
emsdk = dict(
project_name = "Emscripten SDK",
project_desc = "Emscripten SDK (use by Wasm)",
project_url = "https://github.com/emscripten-core/emsdk",
version = "2.0.7",
sha256 = "ce7a5c76e8b425aca874cea329fd9ac44b203b777053453b6a37b4496c5ce34f",
strip_prefix = "emsdk-{version}",
# v3.1.1 with Bazel fixes
version = "7eecde8afcb89fbdff2597d6cce61a24ae2c34f3",
sha256 = "19851efd2616a66f9abd84f55f1d094e03252d87b1d78ae0f5d992121d1dd9cc",
strip_prefix = "emsdk-{version}/bazel",
urls = ["https://github.com/emscripten-core/emsdk/archive/{version}.tar.gz"],
use_category = ["build"],
release_date = "2020-10-13",
release_date = "2022-01-16",
),
rules_rust = dict(
project_name = "Bazel rust rules",
Expand Down
13 changes: 9 additions & 4 deletions bazel/wasm/wasm.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@proxy_wasm_cpp_sdk//bazel/wasm:wasm.bzl", "wasm_cc_binary")
load("@proxy_wasm_cpp_sdk//bazel:defs.bzl", "proxy_wasm_cc_binary")
load("@rules_rust//rust:rust.bzl", "rust_binary")

def _wasm_rust_transition_impl(settings, attr):
Expand Down Expand Up @@ -65,10 +65,15 @@ wasi_rust_binary_rule = rule(
attrs = _wasm_attrs(wasi_rust_transition),
)

def envoy_wasm_cc_binary(name, deps = [], tags = [], **kwargs):
wasm_cc_binary(
def envoy_wasm_cc_binary(name, additional_linker_inputs = [], linkopts = [], tags = [], **kwargs):
proxy_wasm_cc_binary(
name = name,
deps = deps + ["@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics"],
additional_linker_inputs = additional_linker_inputs + [
"@envoy//source/extensions/common/wasm/ext:envoy_proxy_wasm_api_js",
],
linkopts = linkopts + [
"--js-library=$(location @envoy//source/extensions/common/wasm/ext:envoy_proxy_wasm_api_js)",
],
tags = tags + ["manual"],
**kwargs
)
Expand Down
5 changes: 5 additions & 0 deletions source/extensions/common/wasm/ext/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ cc_library(
alwayslink = 1,
)

filegroup(
name = "envoy_proxy_wasm_api_js",
srcs = ["envoy_proxy_wasm_api.js"],
)

# NB: this target is compiled both to native code and to Wasm. Hence the generic rule.
proto_library(
name = "declare_property_proto",
Expand Down
3 changes: 3 additions & 0 deletions source/extensions/common/wasm/ext/envoy_proxy_wasm_api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mergeInto(LibraryManager.library, {
envoy_resolve_dns: function() {},
});
3 changes: 2 additions & 1 deletion test/extensions/access_loggers/wasm/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ TEST_P(WasmAccessLogConfigTest, CreateWasmFromWASM) {
std::string code;
if (GetParam() != "null") {
code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/access_loggers/wasm/test_data/test_cpp.wasm"));
"{{ test_rundir "
"}}/test/extensions/access_loggers/wasm/test_data/test_cpp.wasm/proxy_wasm_test_cpp.wasm"));
} else {
code = "AccessLoggerTestCpp";
}
Expand Down
10 changes: 6 additions & 4 deletions test/extensions/bootstrap/wasm/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class WasmFactoryTest : public testing::TestWithParam<std::string> {
absl::StrCat("envoy.wasm.runtime.", GetParam()));
if (GetParam() != "null") {
config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename(
TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/start_cpp.wasm"));
TestEnvironment::substitute("{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/start_cpp.wasm/"
"proxy_wasm_start_cpp.wasm"));
} else {
config_.mutable_config()
->mutable_vm_config()
Expand Down Expand Up @@ -115,8 +116,9 @@ TEST_P(WasmFactoryTest, MissingImport) {
return;
}
config_.mutable_config()->mutable_vm_config()->mutable_code()->mutable_local()->set_filename(
TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/missing_cpp.wasm"));
TestEnvironment::substitute("{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/missing_cpp.wasm/"
"proxy_wasm_missing_cpp.wasm"));
EXPECT_THROW_WITH_MESSAGE(initializeWithConfig(config_), Extensions::Common::Wasm::WasmException,
"Unable to create Wasm service test");
}
Expand Down
4 changes: 3 additions & 1 deletion test/extensions/bootstrap/wasm/test_data/segv_cpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
// Required Proxy-Wasm ABI version.
extern "C" PROXY_WASM_KEEPALIVE void proxy_abi_version_0_1_0() {}

static int* badptr = nullptr;
// With Emscripten, dereferencing a null pointer does not immediately cause a segmentation fault,
// so use an invalid address to trigger it.
static int* badptr = reinterpret_cast<int*>(0xDEADBEEF);

extern "C" PROXY_WASM_KEEPALIVE uint32_t proxy_on_configure(uint32_t, uint32_t) {
logError("before badptr");
Expand Down
3 changes: 2 additions & 1 deletion test/extensions/bootstrap/wasm/wasm_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class WasmIntegrationTest : public HttpIntegrationTest, public testing::TestWith
}
void initialize() override {
auto httpwasm = TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/http_cpp.wasm");
"{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/http_cpp.wasm/proxy_wasm_http_cpp.wasm");
config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) {
auto* wasm = bootstrap.mutable_static_resources()->add_clusters();
wasm->MergeFrom(bootstrap.static_resources().clusters()[0]);
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/bootstrap/wasm/wasm_speed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ static void bmWasmSimpleCallSpeedTest(benchmark::State& state, std::string test,
if (runtime == "null") {
code = "WasmSpeedCpp";
} else {
code = TestEnvironment::readFileToStringForTest(
TestEnvironment::runfilesPath("test/extensions/bootstrap/wasm/test_data/speed_cpp.wasm"));
code = TestEnvironment::readFileToStringForTest(TestEnvironment::runfilesPath(
"test/extensions/bootstrap/wasm/test_data/speed_cpp.wasm/proxy_wasm_speed_cpp.wasm"));
}
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm->load(code, false));
Expand Down
44 changes: 29 additions & 15 deletions test/extensions/bootstrap/wasm/wasm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ class WasmNullTest : public WasmTestBase, public testing::TestWithParam<std::str
public:
void createWasm() {
WasmTestBase::createWasm(GetParam());
const auto code =
GetParam() != "null"
? TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/stats_cpp.wasm"))
: "WasmStatsCpp";
const auto code = GetParam() != "null"
? TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/stats_cpp.wasm/"
"proxy_wasm_stats_cpp.wasm"))
: "WasmStatsCpp";
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
Expand All @@ -119,8 +120,13 @@ class WasmTestMatrix : public WasmTestBase,
void setWasmCode(std::string vm_configuration) {
const auto basic_path =
absl::StrCat("test/extensions/bootstrap/wasm/test_data/", vm_configuration);
code_ = TestEnvironment::readFileToStringForTest(
TestEnvironment::runfilesPath(basic_path + "_" + std::get<1>(GetParam()) + ".wasm"));
if (std::get<1>(GetParam()) == "cpp") {
code_ = TestEnvironment::readFileToStringForTest(TestEnvironment::runfilesPath(
basic_path + "_cpp.wasm/proxy_wasm_" + vm_configuration + "_cpp.wasm"));
} else {
code_ = TestEnvironment::readFileToStringForTest(
TestEnvironment::runfilesPath(basic_path + "_" + std::get<1>(GetParam()) + ".wasm"));
}

EXPECT_FALSE(code_.empty());
}
Expand Down Expand Up @@ -177,8 +183,10 @@ TEST_P(WasmTest, BadSignature) {
}
#endif
createWasm();
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/bad_signature_cpp.wasm"));
const auto code = TestEnvironment::readFileToStringForTest(
TestEnvironment::substitute("{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/"
"bad_signature_cpp.wasm/proxy_wasm_bad_signature_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_FALSE(wasm_->initialize());
Expand All @@ -194,7 +202,8 @@ TEST_P(WasmTest, Segv) {
#endif
createWasm();
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm"));
"{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm/proxy_wasm_segv_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
Expand All @@ -213,7 +222,8 @@ TEST_P(WasmTest, DivByZero) {
#endif
createWasm();
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm"));
"{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/segv_cpp.wasm/proxy_wasm_segv_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
Expand All @@ -231,8 +241,10 @@ TEST_P(WasmTest, IntrinsicGlobals) {
}
#endif
createWasm();
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/emscripten_cpp.wasm"));
const auto code = TestEnvironment::readFileToStringForTest(
TestEnvironment::substitute("{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/emscripten_cpp.wasm/"
"proxy_wasm_emscripten_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
Expand All @@ -256,8 +268,10 @@ TEST_P(WasmTest, Asm2Wasm) {
}
#endif
createWasm();
const auto code = TestEnvironment::readFileToStringForTest(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/bootstrap/wasm/test_data/asm2wasm_cpp.wasm"));
const auto code = TestEnvironment::readFileToStringForTest(
TestEnvironment::substitute("{{ test_rundir "
"}}/test/extensions/bootstrap/wasm/test_data/asm2wasm_cpp.wasm/"
"proxy_wasm_asm2wasm_cpp.wasm"));
EXPECT_FALSE(code.empty());
EXPECT_TRUE(wasm_->load(code, false));
EXPECT_TRUE(wasm_->initialize());
Expand Down
5 changes: 4 additions & 1 deletion test/extensions/common/wasm/test_data/test_cpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

START_WASM_PLUGIN(CommonWasmTestCpp)

static int* badptr = nullptr;
// With Emscripten, dereferencing a null pointer does not immediately cause a segmentation fault,
// so use an invalid address to trigger it.
static int* badptr = reinterpret_cast<int*>(0xDEADBEEF);

static float gNan = std::nan("1");
static float gInfinity = INFINITY;
volatile double zero_unbeknownst_to_the_compiler = 0.0;
Expand Down
Loading