Skip to content

Introduce multi-engine franken-build. #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d5c3b9c
Rename "runtime" to "engine".
PiotrSikora Feb 10, 2022
4f3f362
review: fix format.
PiotrSikora Feb 10, 2022
5338031
Introduce multi-engine franken-build!
PiotrSikora Feb 10, 2022
079a02e
review: macOS prefixes all symbols with underscore.
PiotrSikora Feb 10, 2022
f06884f
review: more macOS fixes.
PiotrSikora Feb 10, 2022
a695ee1
review: try binutils.
PiotrSikora Feb 10, 2022
dcfd316
review: add to $PATH.
PiotrSikora Feb 10, 2022
fb7b3f2
review: exit 1.
PiotrSikora Feb 10, 2022
470886d
review: try llvm-objcopy.
PiotrSikora Feb 10, 2022
d8d2222
review: $PATH.
PiotrSikora Feb 10, 2022
cef5f63
review: debug.
PiotrSikora Feb 10, 2022
d2a2f48
review: fixup.
PiotrSikora Feb 10, 2022
1c46100
review: fix $PATH.
PiotrSikora Feb 10, 2022
bdda1c3
review: better approach (generate prefixed version on-the-fly).
PiotrSikora Feb 10, 2022
4fe221a
review: drop backward-compatibility for --define runtime=X.
PiotrSikora Feb 17, 2022
09eb810
Merge remote-tracking branch 'origin/master' into PiotrSikora/runtime…
PiotrSikora Feb 17, 2022
4d1cea8
review: rename in GitHub Actions.
PiotrSikora Feb 17, 2022
7498176
review: rename in codebase.
PiotrSikora Feb 17, 2022
ac58a5f
review: "null" engine and "NullVM" WasmVm.
PiotrSikora Feb 17, 2022
7f29f0a
review: fix format.
PiotrSikora Feb 17, 2022
3ea40e3
Merge branch 'runtime-engine' into PiotrSikora/multiengine
PiotrSikora Feb 17, 2022
70a0dcf
review: fix typo.
PiotrSikora Feb 17, 2022
3d82de6
Merge branch 'runtime-engine' into PiotrSikora/multiengine
PiotrSikora Feb 17, 2022
c545c28
review: use @proxy_wasm_cpp_host//...
PiotrSikora Feb 17, 2022
fc463b3
Merge remote-tracking branch 'origin/master' into PiotrSikora/multien…
PiotrSikora Feb 17, 2022
5286e5c
review: style.
PiotrSikora Feb 17, 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
42 changes: 37 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,54 @@ cc_library(
],
)

cc_library(
name = "wasmtime_lib",
genrule(
name = "prefixed_wasmtime_sources",
srcs = [
"src/common/types.h",
"src/wasmtime/types.h",
"src/wasmtime/wasmtime.cc",
],
outs = [
"src/wasmtime/prefixed_types.h",
"src/wasmtime/prefixed_wasmtime.cc",
],
cmd = """
for file in $(SRCS); do
sed -e 's/wasm_/wasmtime_wasm_/g' \
-e 's/wasmtime\\/types.h/wasmtime\\/prefixed_types.h/g' \
$$file >$(@D)/$$(dirname $$file)/prefixed_$$(basename $$file)
done
""",
)

cc_library(
name = "wasmtime_lib",
srcs = [
"src/common/types.h",
] + select({
"@proxy_wasm_cpp_host//bazel:multiengine": [
"src/wasmtime/prefixed_types.h",
"src/wasmtime/prefixed_wasmtime.cc",
],
"//conditions:default": [
"src/wasmtime/types.h",
"src/wasmtime/wasmtime.cc",
],
}),
hdrs = ["include/proxy-wasm/wasmtime.h"],
defines = [
"PROXY_WASM_HAS_RUNTIME_WASMTIME",
"PROXY_WASM_HOST_ENGINE_WASMTIME",
],
deps = [
":wasm_vm_headers",
"//external:wasmtime",
],
] + select({
"@proxy_wasm_cpp_host//bazel:multiengine": [
"//external:prefixed_wasmtime",
],
"//conditions:default": [
"//external:wasmtime",
],
}),
)

cc_library(
Expand Down
5 changes: 5 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ config_setting(
values = {"define": "engine=wavm"},
)

config_setting(
name = "multiengine",
values = {"define": "engine=multi"},
)

config_setting(
name = "requested_crypto_system",
values = {"define": "crypto=system"},
Expand Down
24 changes: 22 additions & 2 deletions bazel/external/v8.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Disable pointer compression (limits the maximum number of WasmVMs).
# 1. Disable pointer compression (limits the maximum number of WasmVMs).
# 2. Don't expose Wasm C API (only Wasm C++ API).

diff --git a/BUILD.bazel b/BUILD.bazel
index 1cc0121e60..4947c1dba2 100644
index 5fb10d3940..a19930d36e 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -161,7 +161,7 @@ v8_int(
Expand All @@ -13,3 +14,22 @@ index 1cc0121e60..4947c1dba2 100644
)

# Default setting for v8_enable_pointer_compression.
diff --git a/src/wasm/c-api.cc b/src/wasm/c-api.cc
index ce3f569fd5..dc8a4c4f6a 100644
--- a/src/wasm/c-api.cc
+++ b/src/wasm/c-api.cc
@@ -2238,6 +2238,8 @@ auto Instance::exports() const -> ownvec<Extern> {

} // namespace wasm

+#if 0
+
// BEGIN FILE wasm-c.cc

extern "C" {
@@ -3257,3 +3259,5 @@ wasm_instance_t* wasm_frame_instance(const wasm_frame_t* frame) {
#undef WASM_DEFINE_SHARABLE_REF

} // extern "C"
+
+#endif
45 changes: 45 additions & 0 deletions bazel/external/wasm-c-api.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,48 @@ cc_library(
"@com_github_bytecodealliance_wasmtime//:rust_c_api",
],
)

genrule(
name = "prefixed_wasmtime_c_api_headers",
srcs = [
"include/wasm.h",
],
outs = [
"wasmtime/include/wasm.h",
],
cmd = """
sed -e 's/\\ wasm_/\\ wasmtime_wasm_/g' \
-e 's/\\*wasm_/\\*wasmtime_wasm_/g' \
-e 's/(wasm_/(wasmtime_wasm_/g' \
$(<) >$@
""",
)

genrule(
name = "prefixed_wasmtime_c_api_lib",
srcs = [
"@com_github_bytecodealliance_wasmtime//:rust_c_api",
],
outs = [
"prefixed_wasmtime_c_api.a",
],
cmd = """
for symbol in $$(nm -P $(<) 2>/dev/null | grep -E ^_?wasm_ | cut -d" " -f1); do
echo $$symbol | sed -r 's/^(_?)(wasm_[a-z_]+)$$/\\1\\2 \\1wasmtime_\\2/' >>prefixed
done
# This should be OBJCOPY, but bazel-zig-cc doesn't define it.
objcopy --redefine-syms=prefixed $(<) $@
""",
toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
)

cc_library(
name = "prefixed_wasmtime_lib",
srcs = [
":prefixed_wasmtime_c_api_lib",
],
hdrs = [
":prefixed_wasmtime_c_api_headers",
],
linkstatic = 1,
)
5 changes: 5 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ def proxy_wasm_cpp_host_repositories():
actual = "@com_github_webassembly_wasm_c_api//:wasmtime_lib",
)

native.bind(
name = "prefixed_wasmtime",
actual = "@com_github_webassembly_wasm_c_api//:prefixed_wasmtime_lib",
)

# WAVM with dependencies.

maybe(
Expand Down
4 changes: 4 additions & 0 deletions bazel/select.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,27 @@
def proxy_wasm_select_engine_v8(xs):
return select({
"@proxy_wasm_cpp_host//bazel:engine_v8": xs,
"@proxy_wasm_cpp_host//bazel:multiengine": xs,
"//conditions:default": [],
})

def proxy_wasm_select_engine_wamr(xs):
return select({
"@proxy_wasm_cpp_host//bazel:engine_wamr": xs,
"@proxy_wasm_cpp_host//bazel:multiengine": xs,
"//conditions:default": [],
})

def proxy_wasm_select_engine_wasmtime(xs):
return select({
"@proxy_wasm_cpp_host//bazel:engine_wasmtime": xs,
"@proxy_wasm_cpp_host//bazel:multiengine": xs,
"//conditions:default": [],
})

def proxy_wasm_select_engine_wavm(xs):
return select({
"@proxy_wasm_cpp_host//bazel:engine_wavm": xs,
"@proxy_wasm_cpp_host//bazel:multiengine": xs,
"//conditions:default": [],
})
1 change: 0 additions & 1 deletion src/wasmtime/wasmtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <unordered_map>
#include <vector>

#include "include/proxy-wasm/wasm_vm.h"
#include "src/wasmtime/types.h"

#include "wasmtime/include/wasm.h"
Expand Down