Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1 change: 1 addition & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def _build_recipe_repository_impl(ctxt):
print("Fetching external dependencies...")
result = ctxt.execute(
["./repositories.sh"] + recipes,
timeout = 3600,
Comment thread
PiotrSikora marked this conversation as resolved.
quiet = False,
)
print(result.stdout)
Expand Down
1 change: 1 addition & 0 deletions bazel/target_recipes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ TARGET_RECIPES = {
"tcmalloc_and_profiler": "gperftools",
"tcmalloc_debug": "gperftools",
"luajit": "luajit",
"v8": "v8",
Comment thread
PiotrSikora marked this conversation as resolved.
"wavm_with_llvm": "wavm",
}
6 changes: 5 additions & 1 deletion ci/build_container/build_container_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ set -e
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get install -y curl wget software-properties-common make cmake git python python-pip python3 python3-pip \
unzip bc libtool ninja-build automake zip time golang gdb strace wireshark tshark tcpdump
unzip bc libtool automake zip time golang gdb strace wireshark tshark tcpdump
# Install cmake 3.12.
curl -sLO https://cmake.org/files/v3.12/cmake-3.12.3-Linux-x86_64.tar.gz
echo "0210f500c71af0ee7e8c42da76954298144d5f72f725ea381ae5db7b766b000e cmake-3.12.3-Linux-x86_64.tar.gz" | sha256sum --check
tar -zxf cmake-3.12.3-Linux-x86_64.tar.gz -C /usr --strip-components=1
# Install ninja 1.8.2.
curl -sLO https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" | sha256sum --check

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reason? Do we need >= 1.8.2 or <=1.8.2 in this case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

= 1.8.2.

unzip ninja-linux.zip && mv ninja /usr/bin
# clang 7.
curl http://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
Expand Down
84 changes: 84 additions & 0 deletions ci/build_container/build_recipes/v8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

set -e

# Get wasm-c-api.

COMMIT=0705a10690d42ff312102392a7f6eeda56985182 # Tue Apr 16 14:05:11 2019 +0200
SHA256=dc4ea492e4a45ea8aa482091585710a44719bc60a60b958fe5aa4e22fa8887ba

curl https://github.com/WebAssembly/wasm-c-api/archive/"$COMMIT".tar.gz -sLo wasm-c-api-"$COMMIT".tar.gz \
&& echo "$SHA256" wasm-c-api-"$COMMIT".tar.gz | sha256sum --check
tar xf wasm-c-api-"$COMMIT".tar.gz
cd wasm-c-api-"$COMMIT"

# Build v8 inside v8 subdirectory to match wasm-c-api's Makefile.

mkdir v8
cd v8

# Get depot_tools.

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:$PWD/depot_tools"

# Get v8.

VERSION=7.4.288.26 # match wasm-c-api (branch-heads/7.4)

fetch v8
cd v8
git checkout "$VERSION"
gclient sync

# Patch v8 for wasm-c-api.

patch -p1 < ../../patch/0001-BUILD.gn-add-wasm-v8-lowlevel.patch
cp -p ../../src/wasm-v8-lowlevel.cc src/wasm-v8-lowlevel.cc
cp -p ../../src/wasm-v8-lowlevel.hh include/wasm-v8-lowlevel.hh

# Build v8 static library.

tools/dev/v8gen.py x64.release -- v8_monolithic=true v8_use_external_startup_data=false v8_enable_i18n_support=false v8_enable_gdbjit=false use_custom_libcxx=false
ninja -v -C out.gn/x64.release v8_monolith

# Install v8.

mkdir -p "$THIRDPARTY_BUILD/include/v8/libplatform"
cp -p include/v8*.h "$THIRDPARTY_BUILD/include/v8/"
cp -p include/libplatform/*.h "$THIRDPARTY_BUILD/include/v8/libplatform/"
cp -p out.gn/x64.release/obj/libv8_monolith.a "$THIRDPARTY_BUILD/lib/"

cd ../..

# Patch wasm-c-api.

cat <<EOF | patch -p1
--- a/src/wasm-v8.cc
+++ b/src/wasm-v8.cc
@@ -296,7 +296,7 @@ auto Engine::make(own<Config*>&& config) -> own<Engine*> {
v8::internal::FLAG_experimental_wasm_bigint = true;
v8::internal::FLAG_experimental_wasm_mv = true;
// v8::internal::FLAG_experimental_wasm_anyref = true;
- // v8::internal::FLAG_experimental_wasm_bulk_memory = true;
+ v8::internal::FLAG_experimental_wasm_bulk_memory = true;
// v8::V8::SetFlagsFromCommandLine(&argc, const_cast<char**>(argv), false);
auto engine = new(std::nothrow) EngineImpl;
if (!engine) return own<Engine*>();
EOF

# Build wasm-c-api.

# TODO(PiotrSikora): respect CC/CXX/CFLAGS/CXXFLAGS/LDFLAGS upstream.

# Disable sanitizers.
sed -i"" -E "s/ -fsanitize[^\n]+//" Makefile

make wasm

# Install wasm-c-api.

mkdir -p "$THIRDPARTY_BUILD/include/wasm-c-api"
cp -p include/wasm.hh "$THIRDPARTY_BUILD/include/wasm-c-api/"
cp -p src/wasm-bin.hh "$THIRDPARTY_BUILD/include/wasm-c-api/"
ar -r -c -s "$THIRDPARTY_BUILD/lib/libwasm.a" out/wasm-bin.o out/wasm-v8.o
17 changes: 17 additions & 0 deletions ci/prebuilt/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ cc_library(
strip_include_prefix = "thirdparty_build/include",
)

cc_library(
name = "v8",
srcs = select({
"@envoy//bazel:windows_x86_64": ["WINDOWS_IS_NOT_SUPPORTED_YET"],
"//conditions:default": [
# Order matters!
Comment thread
PiotrSikora marked this conversation as resolved.
"thirdparty_build/lib/libwasm.a",
"thirdparty_build/lib/libv8_monolith.a",
],
}),
hdrs = [
"thirdparty_build/include/wasm-c-api/wasm.hh",
"thirdparty_build/include/wasm-c-api/wasm-bin.hh",
],
includes = ["thirdparty_build/include"],
)

cc_library(
name = "wavm_with_llvm",
srcs = select({
Expand Down
1 change: 1 addition & 0 deletions source/extensions/common/wasm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ envoy_cc_library(
"//source/common/http:message_lib",
"//source/common/http:utility_lib",
"//source/common/tracing:http_tracer_lib",
"//source/extensions/common/wasm/v8:v8_lib",
"//source/extensions/common/wasm/wavm:wavm_lib",
],
)
28 changes: 28 additions & 0 deletions source/extensions/common/wasm/v8/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
licenses(["notice"]) # Apache 2

load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

envoy_package()

envoy_cc_library(
name = "v8_lib",
srcs = ["v8.cc"],
hdrs = ["v8.h"],
external_deps = [
"v8",
],
deps = [
"//include/envoy/server:wasm_interface",
"//include/envoy/thread_local:thread_local_interface",
"//source/common/common:assert_lib",
"//source/common/common:c_smart_ptr_lib",
"//source/common/protobuf",
"//source/extensions/common/wasm:wasm_hdr",
"//source/extensions/common/wasm:well_known_names",
"@envoy_api//envoy/config/wasm/v2:wasm_cc",
],
)
Loading