Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
build: use common source and local toolchain when building wee8.
Browse files Browse the repository at this point in the history
While there, backport a small fix from upstream.

Signed-off-by: Piotr Sikora <[email protected]>
  • Loading branch information
PiotrSikora committed Aug 21, 2019
1 parent 432025a commit 06d5984
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 48 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ jobs:

macos:
macos:
xcode: "10.2.1"
xcode: "11.0.0"
environment:
BAZEL_BUILD_EXTRA_OPTIONS: "--define wasm=v8" # v8 only, WAVM segfaults in tests.
BAZEL_TEST_TARGETS: "//test/extensions/access_loggers/wasm/... //test/extensions/filters/http/wasm/... //test/extensions/wasm/..."
CC: clang
CXX: clang++
steps:
- run: sudo sntp -sS time.apple.com
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
Expand Down
10 changes: 0 additions & 10 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,6 @@ alias(
}),
)

# Alias pointing to a platform-specific version of wee8.
alias(
name = "wee8",
actual = select({
":darwin": "@wee8_macos//:wee8",
":darwin_x86_64": "@wee8_macos//:wee8",
"//conditions:default": "@wee8_linux//:wee8",
}),
)

config_setting(
name = "linux_x86_64",
values = {"cpu": "k8"},
Expand Down
2 changes: 1 addition & 1 deletion bazel/external/wee8.genrule_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pushd $$ROOT/wee8
rm -rf out/wee8

# Build wee8.
third_party/depot_tools/gn gen out/wee8 --args="v8_use_external_startup_data=false v8_enable_i18n_support=false v8_enable_gdbjit=false v8_expose_symbols=true is_component_build=false is_debug=false use_sysroot=false use_custom_libcxx=false"
AR=ar NM=nm third_party/depot_tools/gn gen out/wee8 --args='v8_use_external_startup_data=false v8_enable_i18n_support=false v8_enable_gdbjit=false v8_expose_symbols=true is_component_build=false is_debug=false clang_use_chrome_plugins=false use_sysroot=false use_custom_libcxx=false custom_toolchain="//build/toolchain/linux/unbundle:default"'
third_party/depot_tools/ninja -C out/wee8 wee8

# Move compiled library to the expected destinations.
Expand Down
55 changes: 54 additions & 1 deletion bazel/external/wee8.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
# 1. Fix handling of f64 globals.
# 2. Force full GC when destroying VMs.
# 3. Fix build with -DDEBUG.
# 4. Fix for VMs with overlapping lifetimes (https://crrev.com/c/1698387).
# 5. Fix linking with unbundled toolchain on macOS.
--- a/wee8/build/toolchain/gcc_toolchain.gni
+++ b/wee8/build/toolchain/gcc_toolchain.gni
@@ -355,6 +355,8 @@
# AIX does not support either -D (deterministic output) or response
# files.
command = "$ar -X64 {{arflags}} -r -c -s {{output}} {{inputs}}"
+ } else if (current_os == "mac") {
+ command = "\"$ar\" {{arflags}} -r -c -s {{output}} {{inputs}}"
} else {
rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs}}"
@@ -546,7 +548,7 @@

start_group_flag = ""
end_group_flag = ""
- if (current_os != "aix") {
+ if (current_os != "aix" && current_os != "mac") {
# the "--start-group .. --end-group" feature isn't available on the aix ld.
start_group_flag = "-Wl,--start-group"
end_group_flag = "-Wl,--end-group "
--- a/wee8/src/wasm/c-api.cc
+++ b/wee8/src/wasm/c-api.cc
@@ -825,7 +825,7 @@ void global_set_f32(v8::Local<v8::Object> global, float val) {
Expand All @@ -12,7 +34,16 @@
}

// Tables
@@ -1107,7 +1107,7 @@ class StoreImpl {
@@ -985,7 +985,7 @@ auto seal(const typename implement<C>::type* x) -> const C* {
return reinterpret_cast<const C*>(x);
}

-#ifdef DEBUG
+#if 0
template <class T>
void vec<T>::make_data() {}

@@ -1107,13 +1107,12 @@ class StoreImpl {
StoreImpl() {}

~StoreImpl() {
Expand All @@ -21,6 +52,28 @@
reinterpret_cast<i::Isolate*>(isolate_)->heap()->PreciseCollectAllGarbage(
i::Heap::kNoGCFlags, i::GarbageCollectionReason::kTesting,
v8::kGCCallbackFlagForced);
#endif
context()->Exit();
- isolate_->Exit();
isolate_->Dispose();
delete create_params_.array_buffer_allocator;
}
@@ -1163,7 +1162,6 @@ auto Store::make(Engine*) -> own<Store*> {
if (!isolate) return own<Store*>();

{
- v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);

// Create context.
@@ -1246,7 +1244,6 @@ auto Store::make(Engine*) -> own<Store*> {
store->host_data_map_ = v8::Eternal<v8::Object>(isolate, map);
}

- store->isolate()->Enter();
store->context()->Enter();
isolate->SetData(0, store.get());

--- a/wee8/third_party/wasm-api/wasm.hh
+++ b/wee8/third_party/wasm-api/wasm.hh
@@ -111,7 +111,7 @@ class vec {
Expand Down
31 changes: 8 additions & 23 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ def envoy_dependencies(skip_targets = []):
actual = "@envoy//bazel:boringssl",
)

# Binding to an alias pointing to a platform-specific version of wee8.
_wee8_linux()
_wee8_macos()
native.bind(
name = "wee8",
actual = "@envoy//bazel:wee8",
)

# The long repo names (`com_github_fmtlib_fmt` instead of `fmtlib`) are
# semi-standard in the Bazel community, intended to avoid both duplicate
# dependencies and name conflicts.
Expand Down Expand Up @@ -158,6 +150,7 @@ def envoy_dependencies(skip_targets = []):
_com_github_curl()
_com_github_envoyproxy_sqlparser()
_com_googlesource_quiche()
_com_googlesource_chromium_v8()
_org_llvm_llvm()
_com_github_wavm_wavm()
_com_lightstep_tracer_cpp()
Expand Down Expand Up @@ -731,26 +724,18 @@ def _com_github_wavm_wavm():
actual = "@envoy//bazel/foreign_cc:wavm",
)

def _wee8_linux():
location = REPOSITORY_LOCATIONS["wee8_linux"]
def _com_googlesource_chromium_v8():
location = REPOSITORY_LOCATIONS["com_googlesource_chromium_v8"]
genrule_repository(
name = "wee8_linux",
urls = location["urls"],
sha256 = location["sha256"],
name = "com_googlesource_chromium_v8",
genrule_cmd_file = "@envoy//bazel/external:wee8.genrule_cmd",
build_file = "@envoy//bazel/external:wee8.BUILD",
patches = ["@envoy//bazel/external:wee8.patch"],
**location
)

def _wee8_macos():
location = REPOSITORY_LOCATIONS["wee8_macos"]
genrule_repository(
name = "wee8_macos",
urls = location["urls"],
sha256 = location["sha256"],
genrule_cmd_file = "@envoy//bazel/external:wee8.genrule_cmd",
build_file = "@envoy//bazel/external:wee8.BUILD",
patches = ["@envoy//bazel/external:wee8.patch"],
native.bind(
name = "wee8",
actual = "@com_googlesource_chromium_v8//:wee8",
)

def _foreign_cc_dependencies():
Expand Down
16 changes: 4 additions & 12 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,11 @@ REPOSITORY_LOCATIONS = dict(
strip_prefix = "WAVM-95dbf08c8695b8941e7020c557d8612f9d2af895",
urls = ["https://github.com/WAVM/WAVM/archive/95dbf08c8695b8941e7020c557d8612f9d2af895.tar.gz"],
),
wee8_linux = dict(
com_googlesource_chromium_v8 = dict(
# This archive was created using https://storage.googleapis.com/envoyproxy-wee8/wee8-archive.sh
# and contains complete checkout of v8 with all dependencies necessary to build wee8 on Linux-x86_64.
# TODO(PiotrSikora): switch to local compiler and provide single platform-agnostic archive.
sha256 = "1caebced30cb9d3531be4720b70c9132c988b362160f7721bc01caeb572c0eb7",
urls = ["https://storage.googleapis.com/envoyproxy-wee8/wee8-7.5.288.22-linux-x86_64.tar.gz"],
),
wee8_macos = dict(
# This archive was created using https://storage.googleapis.com/envoyproxy-wee8/wee8-archive.sh
# and contains complete checkout of v8 with all dependencies necessary to build wee8 on macOS-x86_64.
# TODO(PiotrSikora): switch to local compiler and provide single platform-agnostic archive.
sha256 = "f84e423417db0b03b96e853b7d92f69be7d4936a33d1e8e05848fb146925ff68",
urls = ["https://storage.googleapis.com/envoyproxy-wee8/wee8-7.5.288.22-macos-x86_64.tar.gz"],
# and contains complete checkout of v8 with all dependencies necessary to build wee8.
sha256 = "d59c26ce5d7a2b23fb6251823df700cda0dc9a93086c932be5dfd9048a763d03",
urls = ["https://storage.googleapis.com/envoyproxy-wee8/wee8-7.5.288.22.tar.gz"],
),
io_opencensus_cpp = dict(
sha256 = "8d6016e47c2e19e7acbadb6f905b8c422748c64299d71101ac8f28151677e195",
Expand Down

0 comments on commit 06d5984

Please sign in to comment.