diff --git a/bazel/external/wee8.BUILD b/bazel/external/wee8.BUILD deleted file mode 100644 index 2eb6631ed2..0000000000 --- a/bazel/external/wee8.BUILD +++ /dev/null @@ -1,27 +0,0 @@ -licenses(["notice"]) # Apache 2 - -load(":genrule_cmd.bzl", "genrule_cmd") - -cc_library( - name = "wee8", - srcs = select({ - "@envoy//bazel:windows_x86_64": ["WINDOWS_IS_NOT_SUPPORTED_YET"], - "//conditions:default": [ - "libwee8.a", - ], - }), - hdrs = [ - "wee8/third_party/wasm-api/wasm.hh", - ], - includes = ["wee8/third_party"], - visibility = ["//visibility:public"], -) - -genrule( - name = "build", - srcs = glob(["wee8/**"]), - outs = [ - "libwee8.a", - ], - cmd = genrule_cmd("@envoy//bazel/external:wee8.genrule_cmd"), -) diff --git a/bazel/external/wee8.genrule_cmd b/bazel/external/wee8.genrule_cmd deleted file mode 100644 index e93bc8d685..0000000000 --- a/bazel/external/wee8.genrule_cmd +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -e - -# This works only on Linux-x86_64 and macOS-x86_64. -if [[ ( `uname` != "Linux" && `uname` != "Darwin" ) || `uname -m` != "x86_64" ]]; then - echo "ERROR: wee8 is currently supported only on Linux-x86_64 and macOS-x86_64." - exit 1 -fi - -# Bazel magic. -ROOT=$$(dirname $(rootpath wee8/BUILD.gn))/.. -pushd $$ROOT/wee8 - -# Clean after previous build. -rm -rf out/wee8 - -# Build wee8. -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. -popd -mv $$ROOT/wee8/out/wee8/obj/libwee8.a $(execpath libwee8.a) diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index 4c9e506f3f..59101278bc 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -290,3 +290,22 @@ envoy_cmake_external( "//conditions:default": ["libz.a"], }), ) + +configure_make( + name = "wee8", + configure_command = "third_party/depot_tools/gn", + configure_in_place = True, + configure_options = [ + "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 use_glib=false custom_toolchain="//build/toolchain/linux/unbundle:default"'""", + ], + lib_source = "@com_googlesource_chromium_v8//:all", + make_commands = [ + "third_party/depot_tools/ninja -C out/wee8 wee8", + "mkdir -p $$INSTALL_PREFIX$$/include", + "cp -L -r --no-target-directory third_party/wasm-api $$INSTALL_PREFIX$$/include/wasm-api", + "cp -L -r --no-target-directory out/wee8/obj $$INSTALL_PREFIX$$/lib", + ], + static_libraries = ["libwee8.a"], +) diff --git a/bazel/external/wee8.patch b/bazel/foreign_cc/wee8.patch similarity index 74% rename from bazel/external/wee8.patch rename to bazel/foreign_cc/wee8.patch index cde188ba68..1c82799359 100644 --- a/bazel/external/wee8.patch +++ b/bazel/foreign_cc/wee8.patch @@ -3,8 +3,9 @@ # 3. Fix for VMs with overlapping lifetimes (https://crrev.com/c/1698387). # 4. Fix linking with unbundled toolchain on macOS. # 5. Increase VSZ limit to 4TiB (allows us to start up to 370 VMs). ---- a/wee8/build/toolchain/gcc_toolchain.gni -+++ b/wee8/build/toolchain/gcc_toolchain.gni +# 6. Remove Bazel added -fuse-ld=gold if gn chose -fuse-ld=lld +--- a/build/toolchain/gcc_toolchain.gni ++++ b/build/toolchain/gcc_toolchain.gni @@ -355,6 +355,8 @@ template("gcc_toolchain") { # AIX does not support either -D (deterministic output) or response # files. @@ -23,8 +24,8 @@ # 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 +--- a/src/wasm/c-api.cc ++++ b/src/wasm/c-api.cc @@ -633,7 +633,7 @@ auto seal(const typename implement::type* x) -> const C* { return reinterpret_cast(x); } @@ -70,8 +71,8 @@ store->context()->Enter(); isolate->SetData(0, store.get()); ---- a/wee8/src/wasm/wasm-memory.cc -+++ b/wee8/src/wasm/wasm-memory.cc +--- a/src/wasm/wasm-memory.cc ++++ b/src/wasm/wasm-memory.cc @@ -139,7 +139,7 @@ void* TryAllocateBackingStore(WasmMemoryTracker* memory_tracker, Heap* heap, // address space limits needs to be smaller. constexpr size_t kAddressSpaceLimit = 0x8000000000L; // 512 GiB @@ -81,8 +82,8 @@ #else constexpr size_t kAddressSpaceLimit = 0xC0000000; // 3 GiB #endif ---- a/wee8/third_party/wasm-api/wasm.hh -+++ b/wee8/third_party/wasm-api/wasm.hh +--- a/third_party/wasm-api/wasm.hh ++++ b/third_party/wasm-api/wasm.hh @@ -111,7 +111,7 @@ class vec { size_t size_; std::unique_ptr data_; @@ -92,3 +93,28 @@ void make_data(); void free_data(); #else + + +--- a/build/config/compiler/BUILD.gn ++++ b/build/config/compiler/BUILD.gn +@@ -233,7 +233,6 @@ config("compiler") { + ":clang_revision", + ":compiler_cpu_abi", + ":compiler_codegen", +- ":compiler_deterministic", + ] + + # In general, Windows is totally different, but all the other builds share +--- a/build/toolchain/wrapper_utils.py ++++ b/build/toolchain/wrapper_utils.py +@@ -63,6 +63,10 @@ def RunLinkWithOptionalMapFile(command, env=None, map_file=None): + Returns: + The exit code of running |command|. + """ ++ ++ if "-fuse-ld=lld" in command and "-fuse-ld=gold" in command: ++ command.remove("-fuse-ld=gold") ++ + tmp_map_path = None + if map_file and map_file.endswith('.gz'): + tmp_map_path = map_file + '.tmp' diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 8b53b129a7..f3e8d686b1 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -725,17 +725,15 @@ def _com_github_wavm_wavm(): ) def _com_googlesource_chromium_v8(): - location = REPOSITORY_LOCATIONS["com_googlesource_chromium_v8"] - genrule_repository( + _repository_impl( 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 + build_file_content = BUILD_ALL_CONTENT, + patch_args = ["-p1"], + patches = ["@envoy//bazel/foreign_cc:wee8.patch"], ) native.bind( name = "wee8", - actual = "@com_googlesource_chromium_v8//:wee8", + actual = "@envoy//bazel/foreign_cc:wee8", ) def _foreign_cc_dependencies(): diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index d0b5712907..6563368978 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -245,6 +245,7 @@ REPOSITORY_LOCATIONS = 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. sha256 = "690ca8e3460362fba8e95d94c9325211ad477a4d71a392461f899ec91afd1292", + strip_prefix = "wee8", urls = ["https://storage.googleapis.com/envoyproxy-wee8/wee8-7.6.303.20.tar.gz"], ), io_opencensus_cpp = dict(