From f4da030ca0580eefc0cb272ab2bd36329392b67a Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Thu, 16 Dec 2021 21:27:08 -0800 Subject: [PATCH 01/13] build: add V8 runtime. Fixes #49. Signed-off-by: Piotr Sikora --- .github/workflows/cpp.yml | 2 +- bazel/dependencies.bzl | 7 + bazel/repositories.bzl | 37 ++ bazel/v8.patch | 1034 +++++++++++++++++++++++++++++++++++++ src/v8/v8.cc | 4 +- 5 files changed, 1081 insertions(+), 3 deletions(-) create mode 100644 bazel/v8.patch diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 9e50077ef..cd62c2c9e 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -65,7 +65,7 @@ jobs: strategy: fail-fast: false matrix: - runtime: ["wamr", "wasmtime", "wavm"] + runtime: ["v8", "wamr", "wasmtime", "wavm"] steps: - uses: actions/checkout@v2 diff --git a/bazel/dependencies.bzl b/bazel/dependencies.bzl index c325facfe..b211b4579 100644 --- a/bazel/dependencies.bzl +++ b/bazel/dependencies.bzl @@ -14,9 +14,16 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_fetch_remote_crates") +load("@rules_python//python:pip.bzl", "pip_install") load("@rules_rust//rust:repositories.bzl", "rust_repositories") def proxy_wasm_cpp_host_dependencies(): protobuf_deps() rust_repositories() proxy_wasm_cpp_host_fetch_remote_crates() + + pip_install( + name = "v8_python_deps", + extra_pip_args = ["--require-hashes"], + requirements = "@v8//:bazel/requirements.txt", + ) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 0caa91444..d507f9044 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def proxy_wasm_cpp_host_repositories(): @@ -111,3 +112,39 @@ def proxy_wasm_cpp_host_repositories(): name = "wavm", actual = "@com_github_wavm_wavm//:wavm_lib", ) + + git_repository( + name = "v8", + commit = "a7535a152133bbe43ac2721c3c189749618e2072", + remote = "https://chromium.googlesource.com/v8/v8", + shallow_since = "1639689208 +0000", + patches = ["//:bazel/v8.patch"], + patch_args = ["-p1"], + ) + + new_git_repository( + name = "trace_event_common", + build_file = "@v8//:bazel/BUILD.trace_event_common", + commit = "7f36dbc19d31e2aad895c60261ca8f726442bfbb", + remote = "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git", + shallow_since = "1635355186 -0700", + ) + + new_git_repository( + name = "zlib", + build_file = "@v8//:bazel/BUILD.zlib", + commit = "efd9399ae01364926be2a38946127fdf463480db", + remote = "https://chromium.googlesource.com/chromium/src/third_party/zlib.git", + shallow_since = "1638492135 -0800", + ) + + http_archive( + name = "rules_python", + sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz", + ) + + native.bind( + name = "wee8", + actual = "@v8//:wee8", + ) diff --git a/bazel/v8.patch b/bazel/v8.patch new file mode 100644 index 000000000..a1377bb44 --- /dev/null +++ b/bazel/v8.patch @@ -0,0 +1,1034 @@ +1. Use bazel/config from within the main repository. (https://crrev.com/c/3331591) +2. Manage dependencies in Bazel. (https://crrev.com/c/3344621) +3. Generate inspector files using @rules_python. (https://crrev.com/c/3343881) +7. Fix v8_torque when imported in another workspace. (https://crrev.com/c/3346680) +4. Fix build with GCC and older versions of Clang. (https://crrev.com/c/3333635) +5. Fix build on arm64. (https://crrev.com/c/3337367) +6. Add support for building on s390x. (https://crrev.com/c/3346395) +7. Expose :v8 and :wee8 libraries with headers. (https://crrev.com/c/3346681) + +diff --git a/.bazelrc b/.bazelrc +index e0127628ca..ef69dda4a5 100644 +--- a/.bazelrc ++++ b/.bazelrc +@@ -2,12 +2,16 @@ + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + +-# V8 bazel port only supports clang +-build --action_env=BAZEL_COMPILER=clang +-build --action_env=CC=clang +-build --action_env=CXX=clang++ ++# Pass CC, CXX and PATH from the environment ++build --action_env=CC ++build --action_env=CXX + build --action_env=PATH + ++# Use Clang compiler ++build:clang --action_env=BAZEL_COMPILER=clang ++build:clang --action_env=CC=clang ++build:clang --action_env=CXX=clang++ ++ + # V8 debug config + build:debug --compilation_mode=dbg + build:debug --config=v8_enable_debugging_features +diff --git a/BUILD.bazel b/BUILD.bazel +index 3d37f45ced..b69e0ca3c2 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -3,6 +3,8 @@ + # found in the LICENSE file. + + load("@bazel_skylib//lib:selects.bzl", "selects") ++load("@rules_python//python:defs.bzl", "py_binary") ++load("@v8_python_deps//:requirements.bzl", "requirement") + load( + "@v8//:bazel/defs.bzl", + "v8_binary", +@@ -18,13 +20,6 @@ load( + ) + load(":bazel/v8-non-pointer-compression.bzl", "v8_binary_non_pointer_compression") + +-config_setting( +- name = "is_debug", +- values = { +- "compilation_mode": "dbg", +- }, +-) +- + # ================================================= + # Flags + # ================================================= +@@ -198,7 +193,7 @@ selects.config_setting_group( + name = "v8_target_x64_default_pointer_compression", + match_all = [ + ":v8_enable_pointer_compression_is_none", +- "@config//:v8_target_x64", ++ "@v8//bazel/config:v8_target_x64", + ], + ) + +@@ -207,7 +202,7 @@ selects.config_setting_group( + name = "v8_target_arm64_default_pointer_compression", + match_all = [ + ":v8_enable_pointer_compression_is_none", +- "@config//:v8_target_arm64", ++ "@v8//bazel/config:v8_target_arm64", + ], + ) + +@@ -252,7 +247,7 @@ selects.config_setting_group( + selects.config_setting_group( + name = "should_add_rdynamic", + match_all = [ +- "@config//:is_linux", ++ "@v8//bazel/config:is_linux", + ":is_v8_enable_backtrace", + ], + ) +@@ -290,37 +285,41 @@ v8_config( + "V8_ADVANCED_BIGINT_ALGORITHMS", + "V8_CONCURRENT_MARKING", + ] + select({ +- ":is_debug": [ ++ "@v8//bazel/config:is_debug": [ + "DEBUG", + "V8_ENABLE_CHECKS", + ], + "//conditions:default": [], + }) + select( + { +- "@config//:v8_target_ia32": ["V8_TARGET_ARCH_IA32"], +- "@config//:v8_target_x64": ["V8_TARGET_ARCH_X64"], +- "@config//:v8_target_arm": [ ++ "@v8//bazel/config:v8_target_ia32": ["V8_TARGET_ARCH_IA32"], ++ "@v8//bazel/config:v8_target_x64": ["V8_TARGET_ARCH_X64"], ++ "@v8//bazel/config:v8_target_arm": [ + "V8_TARGET_ARCH_ARM", + "CAN_USE_ARMV7_INSTRUCTIONS", + "CAN_USE_VFP3_INSTRUCTIONS", + ], +- "@config//:v8_target_arm64": ["V8_TARGET_ARCH_ARM64"], ++ "@v8//bazel/config:v8_target_arm64": ["V8_TARGET_ARCH_ARM64"], ++ "@v8//bazel/config:v8_target_s390x": [ ++ "V8_TARGET_ARCH_S390", ++ "V8_TARGET_ARCH_S390X", ++ ], + }, + no_match_error = "Please specify a target cpu supported by v8", + ) + select({ +- "@config//:is_android": [ ++ "@v8//bazel/config:is_android": [ + "V8_HAVE_TARGET_OS", + "V8_TARGET_OS_ANDROID", + ], +- "@config//:is_linux": [ ++ "@v8//bazel/config:is_linux": [ + "V8_HAVE_TARGET_OS", + "V8_TARGET_OS_LINUX", + ], +- "@config//:is_macos": [ ++ "@v8//bazel/config:is_macos": [ + "V8_HAVE_TARGET_OS", + "V8_TARGET_OS_MACOSX", + ], +- "@config//:is_windows": [ ++ "@v8//bazel/config:is_windows": [ + "V8_HAVE_TARGET_OS", + "V8_TARGET_OS_WIN", + "UNICODE", +@@ -622,7 +621,7 @@ filegroup( + "src/base/vlq-base64.h", + "src/base/platform/yield-processor.h", + ] + select({ +- "@config//:is_posix": [ ++ "@v8//bazel/config:is_posix": [ + "src/base/platform/platform-posix.cc", + "src/base/platform/platform-posix.h", + "src/base/platform/platform-posix-time.cc", +@@ -630,19 +629,19 @@ filegroup( + ], + "//conditions:default": [], + }) + select({ +- "@config//:is_linux": [ ++ "@v8//bazel/config:is_linux": [ + "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-linux.cc", + ], +- "@config//:is_android": [ ++ "@v8//bazel/config:is_android": [ + "src/base/debug/stack_trace_android.cc", + "src/base/platform/platform-linux.cc", + ], +- "@config//:is_macos": [ ++ "@v8//bazel/config:is_macos": [ + "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-macos.cc", + ], +- "@config//:is_windows": [ ++ "@v8//bazel/config:is_windows": [ + "src/base/win32-headers.h", + "src/base/debug/stack_trace_win.cc", + "src/base/platform/platform-win32.cc", +@@ -654,7 +653,6 @@ filegroup( + filegroup( + name = "v8_libplatform_files", + srcs = [ +- "base/trace_event/common/trace_event_common.h", + "include/libplatform/libplatform.h", + "include/libplatform/libplatform-export.h", + "include/libplatform/v8-tracing.h", +@@ -982,7 +980,6 @@ filegroup( + ":v8_cppgc_shared_files", + ":v8_bigint", + ":generated_bytecode_builtins_list", +- "base/trace_event/common/trace_event_common.h", + "include/cppgc/common.h", + "include/v8-inspector-protocol.h", + "include/v8-inspector.h", +@@ -1963,8 +1960,6 @@ filegroup( + "src/snapshot/shared-heap-serializer.cc", + "src/snapshot/snapshot-compression.cc", + "src/snapshot/snapshot-compression.h", +- "third_party/zlib/google/compression_utils_portable.h", +- "third_party/zlib/google/compression_utils_portable.cc", + "src/snapshot/snapshot-data.cc", + "src/snapshot/snapshot-data.h", + "src/snapshot/snapshot-source-sink.cc", +@@ -2069,7 +2064,7 @@ filegroup( + "src/heap/third-party/heap-api.h", + "src/heap/third-party/heap-api-stub.cc", + ] + select({ +- "@config//:v8_target_ia32": [ ++ "@v8//bazel/config:v8_target_ia32": [ + "src/baseline/ia32/baseline-assembler-ia32-inl.h", + "src/baseline/ia32/baseline-compiler-ia32-inl.h", + "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", +@@ -2097,7 +2092,7 @@ filegroup( + "src/regexp/ia32/regexp-macro-assembler-ia32.h", + "src/wasm/baseline/ia32/liftoff-assembler-ia32.h", + ], +- "@config//:v8_target_x64": [ ++ "@v8//bazel/config:v8_target_x64": [ + "src/baseline/x64/baseline-assembler-x64-inl.h", + "src/baseline/x64/baseline-compiler-x64-inl.h", + "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", +@@ -2129,7 +2124,7 @@ filegroup( + "src/regexp/x64/regexp-macro-assembler-x64.h", + "src/wasm/baseline/x64/liftoff-assembler-x64.h", + ], +- "@config//:v8_target_arm": [ ++ "@v8//bazel/config:v8_target_arm": [ + "src/baseline/arm/baseline-assembler-arm-inl.h", + "src/baseline/arm/baseline-compiler-arm-inl.h", + "src/codegen/arm/assembler-arm-inl.h", +@@ -2160,7 +2155,7 @@ filegroup( + "src/regexp/arm/regexp-macro-assembler-arm.h", + "src/wasm/baseline/arm/liftoff-assembler-arm.h", + ], +- "@config//:v8_target_arm64": [ ++ "@v8//bazel/config:v8_target_arm64": [ + "src/baseline/arm64/baseline-assembler-arm64-inl.h", + "src/baseline/arm64/baseline-compiler-arm64-inl.h", + "src/codegen/arm64/assembler-arm64-inl.h", +@@ -2203,31 +2198,59 @@ filegroup( + "src/regexp/arm64/regexp-macro-assembler-arm64.h", + "src/wasm/baseline/arm64/liftoff-assembler-arm64.h", + ], ++ "@v8//bazel/config:v8_target_s390x": [ ++ "src/baseline/s390/baseline-assembler-s390-inl.h", ++ "src/baseline/s390/baseline-compiler-s390-inl.h", ++ "src/codegen/s390/assembler-s390-inl.h", ++ "src/codegen/s390/assembler-s390.h", ++ "src/codegen/s390/constants-s390.h", ++ "src/codegen/s390/interface-descriptors-s390-inl.h", ++ "src/codegen/s390/macro-assembler-s390.h", ++ "src/codegen/s390/register-s390.h", ++ "src/compiler/backend/s390/instruction-codes-s390.h", ++ "src/compiler/backend/s390/unwinding-info-writer-s390.h", ++ "src/execution/s390/frame-constants-s390.h", ++ "src/execution/s390/simulator-s390.h", ++ "src/regexp/s390/regexp-macro-assembler-s390.h", ++ "src/wasm/baseline/s390/liftoff-assembler-s390.h", ++ "src/codegen/s390/assembler-s390.cc", ++ "src/codegen/s390/constants-s390.cc", ++ "src/codegen/s390/cpu-s390.cc", ++ "src/codegen/s390/macro-assembler-s390.cc", ++ "src/compiler/backend/s390/code-generator-s390.cc", ++ "src/compiler/backend/s390/instruction-scheduler-s390.cc", ++ "src/compiler/backend/s390/instruction-selector-s390.cc", ++ "src/compiler/backend/s390/unwinding-info-writer-s390.cc", ++ "src/deoptimizer/s390/deoptimizer-s390.cc", ++ "src/diagnostics/s390/disasm-s390.cc", ++ "src/diagnostics/s390/eh-frame-s390.cc", ++ "src/diagnostics/s390/unwinder-s390.cc", ++ "src/execution/s390/frame-constants-s390.cc", ++ "src/execution/s390/simulator-s390.cc", ++ "src/regexp/s390/regexp-macro-assembler-s390.cc", ++ ], + }) + select({ + # Only for x64 builds and for arm64 with x64 host simulator. +- "@config//:is_posix_x64": [ ++ "@v8//bazel/config:is_posix_x64": [ + "src/trap-handler/handler-inside-posix.cc", + "src/trap-handler/handler-outside-posix.cc", + ], + "//conditions:default": [], + }) + select({ +- "@config//:v8_arm64_simulator": [ ++ "@v8//bazel/config:v8_arm64_simulator": [ + "src/trap-handler/trap-handler-simulator.h", + "src/trap-handler/handler-outside-simulator.cc", + ], + "//conditions:default": [], + }) + select({ +- "@config//:is_windows": [ ++ "@v8//bazel/config:is_windows": [ + "src/trap-handler/handler-inside-win.cc", + "src/trap-handler/handler-outside-win.cc", + "src/trap-handler/handler-inside-win.h", +- # Needed on windows to work around https://github.com/bazelbuild/bazel/issues/6337 +- "third_party/zlib/zlib.h", +- "third_party/zlib/zconf.h", + ], + "//conditions:default": [], + }) + select({ +- "@config//:is_windows_64bit": [ ++ "@v8//bazel/config:is_windows_64bit": [ + "src/diagnostics/unwinding-info-win64.cc", + "src/diagnostics/unwinding-info-win64.h", + ], +@@ -2709,10 +2732,11 @@ filegroup( + "src/interpreter/interpreter-intrinsics-generator.cc", + "src/interpreter/interpreter-intrinsics-generator.h", + ] + select({ +- "@config//:v8_target_ia32": ["src/builtins/ia32/builtins-ia32.cc"], +- "@config//:v8_target_x64": ["src/builtins/x64/builtins-x64.cc"], +- "@config//:v8_target_arm": ["src/builtins/arm/builtins-arm.cc"], +- "@config//:v8_target_arm64": ["src/builtins/arm64/builtins-arm64.cc"], ++ "@v8//bazel/config:v8_target_ia32": ["src/builtins/ia32/builtins-ia32.cc"], ++ "@v8//bazel/config:v8_target_x64": ["src/builtins/x64/builtins-x64.cc"], ++ "@v8//bazel/config:v8_target_arm": ["src/builtins/arm/builtins-arm.cc"], ++ "@v8//bazel/config:v8_target_arm64": ["src/builtins/arm64/builtins-arm64.cc"], ++ "@v8//bazel/config:v8_target_s390x": ["src/builtins/s390/builtins-s390.cc"], + }) + select({ + ":is_v8_enable_webassembly": [ + "src/builtins/builtins-wasm-gen.cc", +@@ -2829,13 +2853,14 @@ filegroup( + # Note these cannot be v8_target_is_* selects because these contain + # inline assembly that runs inside the executable. Since these are + # linked directly into mksnapshot, they must use the actual target cpu. +- "@config//:is_inline_asm_ia32": ["src/heap/base/asm/ia32/push_registers_asm.cc"], +- "@config//:is_inline_asm_x64": ["src/heap/base/asm/x64/push_registers_asm.cc"], +- "@config//:is_inline_asm_arm": ["src/heap/base/asm/arm/push_registers_asm.cc"], +- "@config//:is_inline_asm_arm64": ["src/heap/base/asm/arm64/push_registers_asm.cc"], +- "@config//:is_msvc_asm_ia32": ["src/heap/base/asm/ia32/push_registers_masm.S"], +- "@config//:is_msvc_asm_x64": ["src/heap/base/asm/x64/push_registers_masm.S"], +- "@config//:is_msvc_asm_arm64": ["src/heap/base/asm/arm64/push_registers_masm.S"], ++ "@v8//bazel/config:is_inline_asm_ia32": ["src/heap/base/asm/ia32/push_registers_asm.cc"], ++ "@v8//bazel/config:is_inline_asm_x64": ["src/heap/base/asm/x64/push_registers_asm.cc"], ++ "@v8//bazel/config:is_inline_asm_arm": ["src/heap/base/asm/arm/push_registers_asm.cc"], ++ "@v8//bazel/config:is_inline_asm_arm64": ["src/heap/base/asm/arm64/push_registers_asm.cc"], ++ "@v8//bazel/config:is_inline_asm_s390x": ["src/heap/base/asm/s390/push_registers_asm.cc"], ++ "@v8//bazel/config:is_msvc_asm_ia32": ["src/heap/base/asm/ia32/push_registers_masm.S"], ++ "@v8//bazel/config:is_msvc_asm_x64": ["src/heap/base/asm/x64/push_registers_masm.S"], ++ "@v8//bazel/config:is_msvc_asm_arm64": ["src/heap/base/asm/arm64/push_registers_masm.S"], + }), + ) + +@@ -2989,16 +3014,17 @@ filegroup( + srcs = [ + "src/init/setup-isolate-deserialize.cc", + ] + select({ +- "@config//:v8_target_arm": [ ++ "@v8//bazel/config:v8_target_arm": [ + "google3/snapshots/arm/noicu/embedded.S", + "google3/snapshots/arm/noicu/snapshot.cc", + ], +- "@config//:v8_target_ia32": [ ++ "@v8//bazel/config:v8_target_ia32": [ + "google3/snapshots/ia32/noicu/embedded.S", + "google3/snapshots/ia32/noicu/snapshot.cc", + ], +- "@config//:v8_target_arm64": [":noicu/generated_snapshot_files"], +- "@config//:v8_target_x64": [":noicu/generated_snapshot_files"], ++ "@v8//bazel/config:v8_target_arm64": [":noicu/generated_snapshot_files"], ++ "@v8//bazel/config:v8_target_s390x": [":noicu/generated_snapshot_files"], ++ "@v8//bazel/config:v8_target_x64": [":noicu/generated_snapshot_files"], + }), + ) + +@@ -3007,16 +3033,17 @@ filegroup( + srcs = [ + "src/init/setup-isolate-deserialize.cc", + ] + select({ +- "@config//:v8_target_arm": [ ++ "@v8//bazel/config:v8_target_arm": [ + "google3/snapshots/arm/icu/embedded.S", + "google3/snapshots/arm/icu/snapshot.cc", + ], +- "@config//:v8_target_ia32": [ ++ "@v8//bazel/config:v8_target_ia32": [ + "google3/snapshots/ia32/icu/embedded.S", + "google3/snapshots/ia32/icu/snapshot.cc", + ], +- "@config//:v8_target_arm64": [":icu/generated_snapshot_files"], +- "@config//:v8_target_x64": [":icu/generated_snapshot_files"], ++ "@v8//bazel/config:v8_target_arm64": [":icu/generated_snapshot_files"], ++ "@v8//bazel/config:v8_target_s390x": [":icu/generated_snapshot_files"], ++ "@v8//bazel/config:v8_target_x64": [":icu/generated_snapshot_files"], + }), + ) + +@@ -3047,7 +3074,7 @@ v8_torque( + ":is_v8_annotate_torque_ir": ["-annotate-ir"], + "//conditions:default": [], + }) + select({ +- "@config//:v8_target_is_32_bits": ["-m32"], ++ "@v8//bazel/config:v8_target_is_32_bits": ["-m32"], + "//conditions:default": [], + }), + extras = [ +@@ -3076,9 +3103,39 @@ v8_torque( + noicu_srcs = [":noicu/torque_files"], + ) + ++py_binary( ++ name = "code_generator", ++ srcs = [ ++ "third_party/inspector_protocol/code_generator.py", ++ "third_party/inspector_protocol/pdl.py", ++ ], ++ data = [ ++ "third_party/inspector_protocol/lib/Forward_h.template", ++ "third_party/inspector_protocol/lib/Object_cpp.template", ++ "third_party/inspector_protocol/lib/Object_h.template", ++ "third_party/inspector_protocol/lib/Protocol_cpp.template", ++ "third_party/inspector_protocol/lib/ValueConversions_cpp.template", ++ "third_party/inspector_protocol/lib/ValueConversions_h.template", ++ "third_party/inspector_protocol/lib/Values_cpp.template", ++ "third_party/inspector_protocol/lib/Values_h.template", ++ "third_party/inspector_protocol/lib/base_string_adapter_cc.template", ++ "third_party/inspector_protocol/lib/base_string_adapter_h.template", ++ "third_party/inspector_protocol/templates/Exported_h.template", ++ "third_party/inspector_protocol/templates/Imported_h.template", ++ "third_party/inspector_protocol/templates/TypeBuilder_cpp.template", ++ "third_party/inspector_protocol/templates/TypeBuilder_h.template", ++ ], ++ deps = [ ++ requirement("jinja2"), ++ ], ++) ++ + genrule( + name = "generated_inspector_files", +- srcs = ["include/js_protocol.pdl"], ++ srcs = [ ++ "include/js_protocol.pdl", ++ "src/inspector/inspector_protocol_config.json", ++ ], + outs = [ + "include/inspector/Debugger.h", + "include/inspector/Runtime.h", +@@ -3099,10 +3156,27 @@ genrule( + "src/inspector/protocol/Schema.cpp", + "src/inspector/protocol/Schema.h", + ], +- cmd = "bazel/generate-inspector-files.sh $(@D)", +- cmd_bat = "bazel\\generate-inspector-files.cmd $(@D)", +- local = 1, ++ cmd = """ ++ export DIR=$$(dirname $$(dirname $(location :include/js_protocol.pdl))) \ ++ && \ ++ sed -e 's@"path": "..\\/..\\/@"path": "'"$${DIR}"'\\/@g' \ ++ -e 's@"output": "..\\/..\\/@"output": "@g' \ ++ -e 's@"output": "protocol"@"output": "src\\/inspector\\/protocol"@g' \ ++ $(location src/inspector/inspector_protocol_config.json) \ ++ > modified_config.json \ ++ && \ ++ $(location :code_generator) \ ++ --jinja_dir . \ ++ --inspector_protocol_dir third_party/inspector_protocol \ ++ --config modified_config.json \ ++ --output_base $(@D) \ ++ && \ ++ rm modified_config.json ++ """, + message = "Generating inspector files", ++ tools = [ ++ ":code_generator", ++ ], + ) + + filegroup( +@@ -3215,7 +3289,7 @@ cc_library( + ":torque_base_files", + ], + copts = select({ +- "@config//:is_posix": [ "-fexceptions" ], ++ "@v8//bazel/config:is_posix": [ "-fexceptions" ], + "//conditions:default": [], + }), + features = ["-use_header_modules"], +@@ -3248,6 +3322,7 @@ v8_library( + ], + deps = [ + ":v8_libbase", ++ "@trace_event_common", + "@zlib", + ], + ) +@@ -3255,16 +3330,21 @@ v8_library( + v8_library( + name = "v8", + srcs = [":v8_inspector_files"], ++ hdrs = [":public_header_files"], + icu_deps = [":icu/v8_libshared"], + icu_srcs = [":icu/snapshot_files"], + noicu_deps = [":noicu/v8_libshared"], + noicu_srcs = [":noicu/snapshot_files"], ++ visibility = ["//visibility:public"], + ) + + # TODO(victorgomes): Check if v8_enable_webassembly is true. + v8_library( + name = "wee8", + srcs = [":wee8_files"], ++ hdrs = [":public_wasm_c_api_header_files"], ++ strip_include_prefix = "third_party", ++ visibility = ["//visibility:public"], + deps = [":noicu/v8"], + ) + +@@ -3322,12 +3402,12 @@ v8_binary( + ":torque_base_files", + ], + copts = select({ +- "@config//:is_posix": [ "-fexceptions" ], ++ "@v8//bazel/config:is_posix": [ "-fexceptions" ], + "//conditions:default": [], + }), + features = ["-use_header_modules"], + linkopts = select({ +- "@config//:is_android": ["-llog"], ++ "@v8//bazel/config:is_android": ["-llog"], + "//conditions:default": [], + }), + deps = ["v8_libbase"], +@@ -3338,7 +3418,7 @@ v8_binary( + srcs = [":mksnapshot_files"], + icu_deps = [":icu/v8_libshared"], + linkopts = select({ +- "@config//:is_android": ["-llog"], ++ "@v8//bazel/config:is_android": ["-llog"], + "//conditions:default": [], + }), + noicu_deps = [":v8_libshared_noicu"], +diff --git a/WORKSPACE b/WORKSPACE +index 32fff02aab..86ab4fd5d8 100644 +--- a/WORKSPACE ++++ b/WORKSPACE +@@ -4,7 +4,9 @@ + + workspace(name = "v8") + ++load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") ++ + http_archive( + name = "bazel_skylib", + urls = [ +@@ -16,20 +18,37 @@ http_archive( + load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + bazel_skylib_workspace() + +-new_local_repository( +- name = "config", +- path = "bazel/config", +- build_file = "bazel/config/BUILD.bazel", +-) +- +-new_local_repository( ++new_git_repository( + name = "zlib", +- path = "third_party/zlib", +- build_file = "bazel/BUILD.zlib", ++ build_file = "//:bazel/BUILD.zlib", ++ commit = "efd9399ae01364926be2a38946127fdf463480db", ++ remote = "https://chromium.googlesource.com/chromium/src/third_party/zlib.git", + ) + +-new_local_repository( ++new_git_repository( + name = "icu", +- path = "third_party/icu", +- build_file = "bazel/BUILD.icu", ++ build_file = "//:bazel/BUILD.icu", ++ commit = "fbc6faf1c2c429cd27fabe615a89f0b217aa4213", ++ remote = "https://chromium.googlesource.com/chromium/deps/icu.git", ++) ++ ++new_git_repository( ++ name = "trace_event_common", ++ build_file = "//:bazel/BUILD.trace_event_common", ++ commit = "7f36dbc19d31e2aad895c60261ca8f726442bfbb", ++ remote = "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git", ++) ++ ++http_archive( ++ name = "rules_python", ++ sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332", ++ url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz", ++) ++ ++load("@rules_python//python:pip.bzl", "pip_install") ++ ++pip_install( ++ name = "v8_python_deps", ++ extra_pip_args = ["--require-hashes"], ++ requirements = "//:bazel/requirements.txt", + ) +diff --git a/bazel/BUILD.trace_event_common b/bazel/BUILD.trace_event_common +new file mode 100644 +index 0000000000..685b284071 +--- /dev/null ++++ b/bazel/BUILD.trace_event_common +@@ -0,0 +1,10 @@ ++# Copyright 2021 the V8 project authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++cc_library( ++ name = "trace_event_common", ++ hdrs = ["trace_event_common.h"], ++ include_prefix = "base/trace_event/common", ++ visibility = ["//visibility:public"], ++) +diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel +index 78a1b5debd..4f07d57178 100644 +--- a/bazel/config/BUILD.bazel ++++ b/bazel/config/BUILD.bazel +@@ -15,6 +15,20 @@ package( + ], + ) + ++config_setting( ++ name = "is_fastbuild", ++ values = { ++ "compilation_mode": "fastbuild", ++ }, ++) ++ ++config_setting( ++ name = "is_debug", ++ values = { ++ "compilation_mode": "dbg", ++ }, ++) ++ + config_setting( + name = "platform_cpu_x64", + constraint_values = ["@platforms//cpu:x86_64"], +@@ -27,7 +41,7 @@ config_setting( + + config_setting( + name = "platform_cpu_arm64", +- constraint_values = ["@platforms//cpu:arm"], ++ constraint_values = ["@platforms//cpu:aarch64"], + ) + + config_setting( +@@ -35,6 +49,11 @@ config_setting( + constraint_values = ["@platforms//cpu:arm"], + ) + ++config_setting( ++ name = "platform_cpu_s390x", ++ constraint_values = ["@platforms//cpu:s390x"], ++) ++ + v8_target_cpu( + name = "v8_target_cpu", + build_setting_default = "none", +@@ -58,15 +77,20 @@ v8_configure_target_cpu( + ) + + v8_configure_target_cpu( +- name = "arm", ++ name = "arm64", + matching_configs = [":platform_cpu_arm64"], + ) + + v8_configure_target_cpu( +- name = "arm64", ++ name = "arm", + matching_configs = [":platform_cpu_arm"], + ) + ++v8_configure_target_cpu( ++ name = "s390x", ++ matching_configs = [":platform_cpu_s390x"], ++) ++ + selects.config_setting_group( + name = "v8_target_is_32_bits", + match_any = [ +@@ -158,6 +182,11 @@ selects.config_setting_group( + match_all = [":is_posix", ":is_arm"], + ) + ++selects.config_setting_group( ++ name = "is_inline_asm_s390x", ++ match_all = [":is_posix", ":is_s390x"], ++) ++ + selects.config_setting_group( + name = "is_msvc_asm_x64", + match_all = [":is_windows", ":is_x64"], +@@ -172,3 +201,48 @@ selects.config_setting_group( + name = "is_msvc_asm_arm64", + match_all = [":is_windows", ":is_arm64"], + ) ++ ++config_setting( ++ name = "is_clang", ++ flag_values = { ++ "@bazel_tools//tools/cpp:compiler": "clang", ++ }, ++) ++ ++config_setting( ++ name = "is_compiler_default", ++ flag_values = { ++ "@bazel_tools//tools/cpp:compiler": "compiler", ++ }, ++) ++ ++selects.config_setting_group( ++ name = "is_compiler_default_on_linux", ++ match_all = [ ++ ":is_compiler_default", ++ ":is_linux", ++ ], ++) ++ ++config_setting( ++ name = "is_compiler_gcc", ++ flag_values = { ++ "@bazel_tools//tools/cpp:compiler": "gcc", ++ }, ++) ++ ++selects.config_setting_group( ++ name = "is_gcc", ++ match_any = [ ++ ":is_compiler_default_on_linux", ++ ":is_compiler_gcc", ++ ], ++) ++ ++selects.config_setting_group( ++ name = "is_gcc_fastbuild", ++ match_all = [ ++ ":is_gcc", ++ ":is_fastbuild", ++ ], ++) +diff --git a/bazel/config/v8-target-cpu.bzl b/bazel/config/v8-target-cpu.bzl +index 2d5d241ebf..72aae9e270 100644 +--- a/bazel/config/v8-target-cpu.bzl ++++ b/bazel/config/v8-target-cpu.bzl +@@ -14,7 +14,7 @@ V8CpuTypeInfo = provider( + ) + + def _host_target_cpu_impl(ctx): +- allowed_values = ["arm", "arm64", "ia32", "x64", "none"] ++ allowed_values = ["arm", "arm64", "ia32", "s390x", "x64", "none"] + cpu_type = ctx.build_setting_value + if cpu_type in allowed_values: + return V8CpuTypeInfo(value = cpu_type) +diff --git a/bazel/defs.bzl b/bazel/defs.bzl +index 53fccf92e7..3456dbbe4d 100644 +--- a/bazel/defs.bzl ++++ b/bazel/defs.bzl +@@ -89,7 +89,7 @@ def _default_args(): + return struct( + deps = [":define_flags"], + defines = select({ +- "@config//:is_windows": [ ++ "@v8//bazel/config:is_windows": [ + "UNICODE", + "_UNICODE", + "_CRT_RAND_S", +@@ -98,29 +98,59 @@ def _default_args(): + "//conditions:default": [], + }), + copts = select({ +- "@config//:is_posix": [ ++ "@v8//bazel/config:is_posix": [ + "-fPIC", ++ "-fno-strict-aliasing", + "-Werror", + "-Wextra", ++ "-Wno-unknown-warning-option", + "-Wno-bitwise-instead-of-logical", + "-Wno-builtin-assume-aligned-alignment", + "-Wno-unused-parameter", + "-Wno-implicit-int-float-conversion", + "-Wno-deprecated-copy", + "-Wno-non-virtual-dtor", +- "-std=c++17", + "-isystem .", + ], + "//conditions:default": [], ++ }) + select({ ++ "@v8//bazel/config:is_clang": [ ++ "-Wno-invalid-offsetof", ++ "-std=c++17", ++ ], ++ "@v8//bazel/config:is_gcc": [ ++ "-Wno-extra", ++ "-Wno-comments", ++ "-Wno-deprecated-declarations", ++ "-Wno-implicit-fallthrough", ++ "-Wno-maybe-uninitialized", ++ "-Wno-mismatched-new-delete", ++ "-Wno-redundant-move", ++ "-Wno-return-type", ++ # Use GNU dialect, because GCC doesn't allow using ++ # ##__VA_ARGS__ when in standards-conforming mode. ++ "-std=gnu++17", ++ ], ++ "@v8//bazel/config:is_windows": [ ++ "/std:c++17", ++ ], ++ "//conditions:default": [], ++ }) + select({ ++ "@v8//bazel/config:is_gcc_fastbuild": [ ++ # Non-debug builds without optimizations fail because ++ # of recursive inlining of "always_inline" functions. ++ "-O1", ++ ], ++ "//conditions:default": [], + }), + includes = ["include"], + linkopts = select({ +- "@config//:is_windows": [ ++ "@v8//bazel/config:is_windows": [ + "Winmm.lib", + "DbgHelp.lib", + "Advapi32.lib", + ], +- "@config//:is_macos": ["-pthread"], ++ "@v8//bazel/config:is_macos": ["-pthread"], + "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"], + }) + select({ + ":should_add_rdynamic": ["-rdynamic"], +@@ -248,8 +278,10 @@ def v8_library( + ) + + def _torque_impl(ctx): +- v8root = "." +- prefix = ctx.attr.prefix ++ if ctx.workspace_name == "v8": ++ v8root = "." ++ else: ++ v8root = "external/v8" + + # Arguments + args = [] +@@ -301,7 +333,6 @@ _v8_torque = rule( + cfg = "exec", + ), + "args": attr.string_list(), +- "v8root": attr.label(default = ":v8_root"), + }, + ) + +@@ -313,7 +344,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): + args = args, + extras = extras, + tool = select({ +- "@config//:v8_target_is_32_bits": ":torque_non_pointer_compression", ++ "@v8//bazel/config:v8_target_is_32_bits": ":torque_non_pointer_compression", + "//conditions:default": ":torque", + }), + ) +@@ -324,7 +355,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): + args = args, + extras = extras, + tool = select({ +- "@config//:v8_target_is_32_bits": ":torque_non_pointer_compression", ++ "@v8//bazel/config:v8_target_is_32_bits": ":torque_non_pointer_compression", + "//conditions:default": ":torque", + }), + ) +@@ -342,14 +373,14 @@ def _v8_target_cpu_transition_impl(settings, attr): + "armeabi-v7a": "arm32", + } + v8_target_cpu = mapping[settings["//command_line_option:cpu"]] +- return {"@config//:v8_target_cpu": v8_target_cpu} ++ return {"@v8//bazel/config:v8_target_cpu": v8_target_cpu} + + # Set the v8_target_cpu to be the correct architecture given the cpu specified + # on the command line. + v8_target_cpu_transition = transition( + implementation = _v8_target_cpu_transition_impl, + inputs = ["//command_line_option:cpu"], +- outputs = ["@config//:v8_target_cpu"], ++ outputs = ["@v8//bazel/config:v8_target_cpu"], + ) + + def _mksnapshot(ctx): +diff --git a/bazel/generate-inspector-files.cmd b/bazel/generate-inspector-files.cmd +deleted file mode 100644 +index 202dd81d7c..0000000000 +--- a/bazel/generate-inspector-files.cmd ++++ /dev/null +@@ -1,24 +0,0 @@ +-REM Copyright 2021 the V8 project authors. All rights reserved. +-REM Use of this source code is governed by a BSD-style license that can be +-REM found in the LICENSE file. +- +-set BAZEL_OUT=%1 +- +-REM Bazel nukes all env vars, and we need the following for gn to work +-set DEPOT_TOOLS_WIN_TOOLCHAIN=0 +-set ProgramFiles(x86)=C:\Program Files (x86) +-set windir=C:\Windows +- +-REM Create a default GN output folder +-cmd.exe /S /E:ON /V:ON /D /c gn gen out/inspector +- +-REM Generate inspector files +-cmd.exe /S /E:ON /V:ON /D /c autoninja -C out/inspector gen/src/inspector/protocol/Forward.h +- +-REM Create directories in bazel output folder +-MKDIR -p %BAZEL_OUT%\include\inspector +-MKDIR -p %BAZEL_OUT%\src\inspector\protocol +- +-REM Copy generated files to bazel output folder +-COPY out\inspector\gen\include\inspector\* %BAZEL_OUT%\include\inspector\ +-COPY out\inspector\gen\src\inspector\protocol\* %BAZEL_OUT%\src\inspector\protocol\ +\ No newline at end of file +diff --git a/bazel/generate-inspector-files.sh b/bazel/generate-inspector-files.sh +deleted file mode 100755 +index 9547041c33..0000000000 +--- a/bazel/generate-inspector-files.sh ++++ /dev/null +@@ -1,21 +0,0 @@ +-# Copyright 2021 the V8 project authors. All rights reserved. +-# Use of this source code is governed by a BSD-style license that can be +-# found in the LICENSE file. +- +-set -e +- +-BAZEL_OUT=$1 +- +-# Create a default GN output folder +-gn gen out/inspector +- +-# Generate inspector files +-autoninja -C out/inspector src/inspector:protocol_generated_sources +- +-# Create directories in bazel output folder +-mkdir -p $BAZEL_OUT/include/inspector +-mkdir -p $BAZEL_OUT/src/inspector/protocol +- +-# Copy generated files to bazel output folder +-cp out/inspector/gen/include/inspector/* $BAZEL_OUT/include/inspector/ +-cp out/inspector/gen/src/inspector/protocol/* $BAZEL_OUT/src/inspector/protocol/ +diff --git a/bazel/requirements.in b/bazel/requirements.in +new file mode 100644 +index 0000000000..7f7afbf3bf +--- /dev/null ++++ b/bazel/requirements.in +@@ -0,0 +1 @@ ++jinja2 +diff --git a/bazel/requirements.txt b/bazel/requirements.txt +new file mode 100644 +index 0000000000..a9c132f688 +--- /dev/null ++++ b/bazel/requirements.txt +@@ -0,0 +1,81 @@ ++# ++# This file is autogenerated by pip-compile with python 3.9 ++# To update, run: ++# ++# pip-compile --generate-hashes requirements.in ++# ++jinja2==3.0.3 \ ++ --hash=sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8 \ ++ --hash=sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7 ++ # via -r requirements.in ++markupsafe==2.0.1 \ ++ --hash=sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298 \ ++ --hash=sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64 \ ++ --hash=sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b \ ++ --hash=sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194 \ ++ --hash=sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567 \ ++ --hash=sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff \ ++ --hash=sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724 \ ++ --hash=sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74 \ ++ --hash=sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646 \ ++ --hash=sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35 \ ++ --hash=sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6 \ ++ --hash=sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a \ ++ --hash=sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6 \ ++ --hash=sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad \ ++ --hash=sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26 \ ++ --hash=sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38 \ ++ --hash=sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac \ ++ --hash=sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7 \ ++ --hash=sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6 \ ++ --hash=sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047 \ ++ --hash=sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75 \ ++ --hash=sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f \ ++ --hash=sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b \ ++ --hash=sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135 \ ++ --hash=sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8 \ ++ --hash=sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a \ ++ --hash=sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a \ ++ --hash=sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1 \ ++ --hash=sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9 \ ++ --hash=sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864 \ ++ --hash=sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914 \ ++ --hash=sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee \ ++ --hash=sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f \ ++ --hash=sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18 \ ++ --hash=sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8 \ ++ --hash=sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2 \ ++ --hash=sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d \ ++ --hash=sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b \ ++ --hash=sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b \ ++ --hash=sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86 \ ++ --hash=sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6 \ ++ --hash=sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f \ ++ --hash=sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb \ ++ --hash=sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833 \ ++ --hash=sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28 \ ++ --hash=sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e \ ++ --hash=sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415 \ ++ --hash=sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902 \ ++ --hash=sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f \ ++ --hash=sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d \ ++ --hash=sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9 \ ++ --hash=sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d \ ++ --hash=sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145 \ ++ --hash=sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066 \ ++ --hash=sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c \ ++ --hash=sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1 \ ++ --hash=sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a \ ++ --hash=sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207 \ ++ --hash=sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f \ ++ --hash=sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53 \ ++ --hash=sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd \ ++ --hash=sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134 \ ++ --hash=sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85 \ ++ --hash=sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9 \ ++ --hash=sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5 \ ++ --hash=sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94 \ ++ --hash=sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509 \ ++ --hash=sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51 \ ++ --hash=sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872 ++ # via jinja2 diff --git a/src/v8/v8.cc b/src/v8/v8.cc index dd33f5b26..29f3de090 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -25,8 +25,8 @@ #include #include -#include "v8.h" -#include "v8-version.h" +#include "include/v8.h" +#include "include/v8-version.h" #include "wasm-api/wasm.hh" namespace proxy_wasm { From 2f40b7cbb06e9740e6187c7f5c9cad7dae3baffd Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 2 Jan 2022 21:57:40 -0800 Subject: [PATCH 02/13] review: update patches. Signed-off-by: Piotr Sikora --- bazel/repositories.bzl | 4 +- bazel/v8.patch | 118 ++++++++++++++++++++++++++++------------- 2 files changed, 83 insertions(+), 39 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index d507f9044..fbbc158d4 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -123,7 +123,7 @@ def proxy_wasm_cpp_host_repositories(): ) new_git_repository( - name = "trace_event_common", + name = "com_googlesource_chromium_trace_event_common", build_file = "@v8//:bazel/BUILD.trace_event_common", commit = "7f36dbc19d31e2aad895c60261ca8f726442bfbb", remote = "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git", @@ -131,7 +131,7 @@ def proxy_wasm_cpp_host_repositories(): ) new_git_repository( - name = "zlib", + name = "com_googlesource_chromium_zlib", build_file = "@v8//:bazel/BUILD.zlib", commit = "efd9399ae01364926be2a38946127fdf463480db", remote = "https://chromium.googlesource.com/chromium/src/third_party/zlib.git", diff --git a/bazel/v8.patch b/bazel/v8.patch index a1377bb44..b4cef827b 100644 --- a/bazel/v8.patch +++ b/bazel/v8.patch @@ -4,8 +4,9 @@ 7. Fix v8_torque when imported in another workspace. (https://crrev.com/c/3346680) 4. Fix build with GCC and older versions of Clang. (https://crrev.com/c/3333635) 5. Fix build on arm64. (https://crrev.com/c/3337367) -6. Add support for building on s390x. (https://crrev.com/c/3346395) -7. Expose :v8 and :wee8 libraries with headers. (https://crrev.com/c/3346681) +6. Fix build on macOS. (https://crrev.com/c/3364916) +7. Add support for building on s390x. (https://crrev.com/c/3346395) +8. Expose :v8 and :wee8 libraries with headers. (https://crrev.com/c/3346681) diff --git a/.bazelrc b/.bazelrc index e0127628ca..ef69dda4a5 100644 @@ -33,7 +34,7 @@ index e0127628ca..ef69dda4a5 100644 build:debug --compilation_mode=dbg build:debug --config=v8_enable_debugging_features diff --git a/BUILD.bazel b/BUILD.bazel -index 3d37f45ced..b69e0ca3c2 100644 +index 3d37f45ced..b84afd0759 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,6 +3,8 @@ @@ -470,15 +471,25 @@ index 3d37f45ced..b69e0ca3c2 100644 "//conditions:default": [], }), features = ["-use_header_modules"], -@@ -3248,6 +3322,7 @@ v8_library( +@@ -3233,7 +3307,7 @@ v8_library( + ], + icu_deps = [ + ":icu/generated_torque_headers", +- "@icu", ++ "@com_googlesource_chromium_icu//:icu", + ], + icu_srcs = [ + ":generated_regexp_special_case", +@@ -3248,23 +3322,29 @@ v8_library( ], deps = [ ":v8_libbase", -+ "@trace_event_common", - "@zlib", +- "@zlib", ++ "@com_googlesource_chromium_trace_event_common//:trace_event_common", ++ "@com_googlesource_chromium_zlib//:zlib", ], ) -@@ -3255,16 +3330,21 @@ v8_library( + v8_library( name = "v8", srcs = [":v8_inspector_files"], @@ -500,6 +511,15 @@ index 3d37f45ced..b69e0ca3c2 100644 deps = [":noicu/v8"], ) +@@ -3311,7 +3391,7 @@ v8_binary( + "UNISTR_FROM_CHAR_EXPLICIT=", + ], + deps = [ +- "@icu", ++ "@com_googlesource_chromium_icu//:icu", + ], + ) + @@ -3322,12 +3402,12 @@ v8_binary( ":torque_base_files", ], @@ -525,7 +545,7 @@ index 3d37f45ced..b69e0ca3c2 100644 }), noicu_deps = [":v8_libshared_noicu"], diff --git a/WORKSPACE b/WORKSPACE -index 32fff02aab..86ab4fd5d8 100644 +index 32fff02aab..4aacf4354f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -4,7 +4,9 @@ @@ -546,35 +566,35 @@ index 32fff02aab..86ab4fd5d8 100644 - name = "config", - path = "bazel/config", - build_file = "bazel/config/BUILD.bazel", --) -- --new_local_repository( +new_git_repository( - name = "zlib", ++ name = "com_googlesource_chromium_icu", ++ build_file = "//:bazel/BUILD.icu", ++ commit = "fbc6faf1c2c429cd27fabe615a89f0b217aa4213", ++ remote = "https://chromium.googlesource.com/chromium/deps/icu.git", ++) ++ ++new_git_repository( ++ name = "com_googlesource_chromium_trace_event_common", ++ build_file = "//:bazel/BUILD.trace_event_common", ++ commit = "7f36dbc19d31e2aad895c60261ca8f726442bfbb", ++ remote = "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git", + ) + +-new_local_repository( +- name = "zlib", - path = "third_party/zlib", - build_file = "bazel/BUILD.zlib", ++new_git_repository( ++ name = "com_googlesource_chromium_zlib", + build_file = "//:bazel/BUILD.zlib", + commit = "efd9399ae01364926be2a38946127fdf463480db", + remote = "https://chromium.googlesource.com/chromium/src/third_party/zlib.git", ) -new_local_repository( -+new_git_repository( - name = "icu", +- name = "icu", - path = "third_party/icu", - build_file = "bazel/BUILD.icu", -+ build_file = "//:bazel/BUILD.icu", -+ commit = "fbc6faf1c2c429cd27fabe615a89f0b217aa4213", -+ remote = "https://chromium.googlesource.com/chromium/deps/icu.git", -+) -+ -+new_git_repository( -+ name = "trace_event_common", -+ build_file = "//:bazel/BUILD.trace_event_common", -+ commit = "7f36dbc19d31e2aad895c60261ca8f726442bfbb", -+ remote = "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git", -+) -+ +http_archive( + name = "rules_python", + sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332", @@ -605,7 +625,7 @@ index 0000000000..685b284071 + visibility = ["//visibility:public"], +) diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel -index 78a1b5debd..4f07d57178 100644 +index 78a1b5debd..b7edae5815 100644 --- a/bazel/config/BUILD.bazel +++ b/bazel/config/BUILD.bazel @@ -15,6 +15,20 @@ package( @@ -685,19 +705,12 @@ index 78a1b5debd..4f07d57178 100644 selects.config_setting_group( name = "is_msvc_asm_x64", match_all = [":is_windows", ":is_x64"], -@@ -172,3 +201,48 @@ selects.config_setting_group( +@@ -172,3 +201,64 @@ selects.config_setting_group( name = "is_msvc_asm_arm64", match_all = [":is_windows", ":is_arm64"], ) + +config_setting( -+ name = "is_clang", -+ flag_values = { -+ "@bazel_tools//tools/cpp:compiler": "clang", -+ }, -+) -+ -+config_setting( + name = "is_compiler_default", + flag_values = { + "@bazel_tools//tools/cpp:compiler": "compiler", @@ -712,6 +725,29 @@ index 78a1b5debd..4f07d57178 100644 + ], +) + ++selects.config_setting_group( ++ name = "is_compiler_default_on_macos", ++ match_all = [ ++ ":is_compiler_default", ++ ":is_macos", ++ ], ++) ++ ++config_setting( ++ name = "is_compiler_clang", ++ flag_values = { ++ "@bazel_tools//tools/cpp:compiler": "clang", ++ }, ++) ++ ++selects.config_setting_group( ++ name = "is_clang", ++ match_any = [ ++ ":is_compiler_default_on_macos", ++ ":is_compiler_clang", ++ ], ++) ++ +config_setting( + name = "is_compiler_gcc", + flag_values = { @@ -748,7 +784,7 @@ index 2d5d241ebf..72aae9e270 100644 if cpu_type in allowed_values: return V8CpuTypeInfo(value = cpu_type) diff --git a/bazel/defs.bzl b/bazel/defs.bzl -index 53fccf92e7..3456dbbe4d 100644 +index 53fccf92e7..14fff6f049 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -89,7 +89,7 @@ def _default_args(): @@ -863,7 +899,15 @@ index 53fccf92e7..3456dbbe4d 100644 "//conditions:default": ":torque", }), ) -@@ -342,14 +373,14 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -334,6 +365,7 @@ def _v8_target_cpu_transition_impl(settings, attr): + "haswell": "x64", + "k8": "x64", + "x86_64": "x64", ++ "darwin": "x64", + "darwin_x86_64": "x64", + "x86": "ia32", + "ppc": "ppc64", +@@ -342,14 +374,14 @@ def _v8_target_cpu_transition_impl(settings, attr): "armeabi-v7a": "arm32", } v8_target_cpu = mapping[settings["//command_line_option:cpu"]] From c775b29357432e117d459a80e848615ec8deacbc Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 2 Jan 2022 22:26:00 -0800 Subject: [PATCH 03/13] review: build and test V8 on macOS. Signed-off-by: Piotr Sikora --- .github/workflows/cpp.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index cd62c2c9e..fd8712ff2 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -31,7 +31,7 @@ on: jobs: format: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -58,33 +58,42 @@ jobs: addlicense -check . build: - name: build (${{ matrix.runtime }}) + name: build (${{ matrix.runtime }} on ${{ matrix.os }}) - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - runtime: ["v8", "wamr", "wasmtime", "wavm"] + os: [ubuntu-20.04] + runtime: ['v8', 'wamr', 'wasmtime', 'wavm'] + include: + - os: macos-11 + runtime: 'v8' steps: - uses: actions/checkout@v2 - - name: Install dependency + - name: Install dependency (Ubuntu) + if: startsWith(matrix.os, 'ubuntu') run: sudo apt-get install ninja-build + - name: Install dependency (macOS) + if: startsWith(matrix.os, 'macos') + run: brew install ninja + - name: Mount Bazel cache uses: actions/cache@v2 with: path: | ~/.cache/bazel ~/.cache/bazelisk - key: bazel-${{ matrix.runtime }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.raze.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} + key: bazel-${{ matrix.os }}-${{ matrix.runtime }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.raze.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} - name: Test run: | - bazel test --define runtime=${{ matrix.runtime }} //test/... + bazel test --test_output=errors --define runtime=${{ matrix.runtime }} //test/... - name: Test (signed Wasm module) run: | - bazel test --define runtime=${{ matrix.runtime }} --per_file_copt=//...@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" //test:signature_util_test + bazel test --test_output=errors --define runtime=${{ matrix.runtime }} --per_file_copt=//...@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" //test:signature_util_test From 9c7e629d77b76814ea6dcd26963c3689698efa9b Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 14:39:01 -0800 Subject: [PATCH 04/13] review: update to v9.9.52. Signed-off-by: Piotr Sikora --- bazel/repositories.bzl | 4 ++-- bazel/v8.patch | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index fbbc158d4..85c60a5fd 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -115,9 +115,9 @@ def proxy_wasm_cpp_host_repositories(): git_repository( name = "v8", - commit = "a7535a152133bbe43ac2721c3c189749618e2072", + commit = "11559b4461ac0c3328354229e03c2a989b104ff9", remote = "https://chromium.googlesource.com/v8/v8", - shallow_since = "1639689208 +0000", + shallow_since = "1641210631 +0000", patches = ["//:bazel/v8.patch"], patch_args = ["-p1"], ) diff --git a/bazel/v8.patch b/bazel/v8.patch index b4cef827b..0f227f32a 100644 --- a/bazel/v8.patch +++ b/bazel/v8.patch @@ -34,7 +34,7 @@ index e0127628ca..ef69dda4a5 100644 build:debug --compilation_mode=dbg build:debug --config=v8_enable_debugging_features diff --git a/BUILD.bazel b/BUILD.bazel -index 3d37f45ced..b84afd0759 100644 +index c9864429a5..b1717e8fda 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,6 +3,8 @@ @@ -187,7 +187,7 @@ index 3d37f45ced..b84afd0759 100644 "include/cppgc/common.h", "include/v8-inspector-protocol.h", "include/v8-inspector.h", -@@ -1963,8 +1960,6 @@ filegroup( +@@ -1966,8 +1963,6 @@ filegroup( "src/snapshot/shared-heap-serializer.cc", "src/snapshot/snapshot-compression.cc", "src/snapshot/snapshot-compression.h", @@ -196,7 +196,7 @@ index 3d37f45ced..b84afd0759 100644 "src/snapshot/snapshot-data.cc", "src/snapshot/snapshot-data.h", "src/snapshot/snapshot-source-sink.cc", -@@ -2069,7 +2064,7 @@ filegroup( +@@ -2072,7 +2067,7 @@ filegroup( "src/heap/third-party/heap-api.h", "src/heap/third-party/heap-api-stub.cc", ] + select({ @@ -205,7 +205,7 @@ index 3d37f45ced..b84afd0759 100644 "src/baseline/ia32/baseline-assembler-ia32-inl.h", "src/baseline/ia32/baseline-compiler-ia32-inl.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", -@@ -2097,7 +2092,7 @@ filegroup( +@@ -2100,7 +2095,7 @@ filegroup( "src/regexp/ia32/regexp-macro-assembler-ia32.h", "src/wasm/baseline/ia32/liftoff-assembler-ia32.h", ], @@ -214,7 +214,7 @@ index 3d37f45ced..b84afd0759 100644 "src/baseline/x64/baseline-assembler-x64-inl.h", "src/baseline/x64/baseline-compiler-x64-inl.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", -@@ -2129,7 +2124,7 @@ filegroup( +@@ -2132,7 +2127,7 @@ filegroup( "src/regexp/x64/regexp-macro-assembler-x64.h", "src/wasm/baseline/x64/liftoff-assembler-x64.h", ], @@ -223,7 +223,7 @@ index 3d37f45ced..b84afd0759 100644 "src/baseline/arm/baseline-assembler-arm-inl.h", "src/baseline/arm/baseline-compiler-arm-inl.h", "src/codegen/arm/assembler-arm-inl.h", -@@ -2160,7 +2155,7 @@ filegroup( +@@ -2163,7 +2158,7 @@ filegroup( "src/regexp/arm/regexp-macro-assembler-arm.h", "src/wasm/baseline/arm/liftoff-assembler-arm.h", ], @@ -232,7 +232,7 @@ index 3d37f45ced..b84afd0759 100644 "src/baseline/arm64/baseline-assembler-arm64-inl.h", "src/baseline/arm64/baseline-compiler-arm64-inl.h", "src/codegen/arm64/assembler-arm64-inl.h", -@@ -2203,31 +2198,59 @@ filegroup( +@@ -2206,31 +2201,59 @@ filegroup( "src/regexp/arm64/regexp-macro-assembler-arm64.h", "src/wasm/baseline/arm64/liftoff-assembler-arm64.h", ], @@ -299,7 +299,7 @@ index 3d37f45ced..b84afd0759 100644 "src/diagnostics/unwinding-info-win64.cc", "src/diagnostics/unwinding-info-win64.h", ], -@@ -2709,10 +2732,11 @@ filegroup( +@@ -2712,10 +2735,11 @@ filegroup( "src/interpreter/interpreter-intrinsics-generator.cc", "src/interpreter/interpreter-intrinsics-generator.h", ] + select({ @@ -315,7 +315,7 @@ index 3d37f45ced..b84afd0759 100644 }) + select({ ":is_v8_enable_webassembly": [ "src/builtins/builtins-wasm-gen.cc", -@@ -2829,13 +2853,14 @@ filegroup( +@@ -2832,13 +2856,14 @@ filegroup( # Note these cannot be v8_target_is_* selects because these contain # inline assembly that runs inside the executable. Since these are # linked directly into mksnapshot, they must use the actual target cpu. @@ -337,7 +337,7 @@ index 3d37f45ced..b84afd0759 100644 }), ) -@@ -2989,16 +3014,17 @@ filegroup( +@@ -2992,16 +3017,17 @@ filegroup( srcs = [ "src/init/setup-isolate-deserialize.cc", ] + select({ @@ -359,7 +359,7 @@ index 3d37f45ced..b84afd0759 100644 }), ) -@@ -3007,16 +3033,17 @@ filegroup( +@@ -3010,16 +3036,17 @@ filegroup( srcs = [ "src/init/setup-isolate-deserialize.cc", ] + select({ @@ -381,7 +381,7 @@ index 3d37f45ced..b84afd0759 100644 }), ) -@@ -3047,7 +3074,7 @@ v8_torque( +@@ -3050,7 +3077,7 @@ v8_torque( ":is_v8_annotate_torque_ir": ["-annotate-ir"], "//conditions:default": [], }) + select({ @@ -390,7 +390,7 @@ index 3d37f45ced..b84afd0759 100644 "//conditions:default": [], }), extras = [ -@@ -3076,9 +3103,39 @@ v8_torque( +@@ -3079,9 +3106,39 @@ v8_torque( noicu_srcs = [":noicu/torque_files"], ) @@ -431,7 +431,7 @@ index 3d37f45ced..b84afd0759 100644 outs = [ "include/inspector/Debugger.h", "include/inspector/Runtime.h", -@@ -3099,10 +3156,27 @@ genrule( +@@ -3102,10 +3159,27 @@ genrule( "src/inspector/protocol/Schema.cpp", "src/inspector/protocol/Schema.h", ], @@ -462,7 +462,7 @@ index 3d37f45ced..b84afd0759 100644 ) filegroup( -@@ -3215,7 +3289,7 @@ cc_library( +@@ -3218,7 +3292,7 @@ cc_library( ":torque_base_files", ], copts = select({ @@ -471,7 +471,7 @@ index 3d37f45ced..b84afd0759 100644 "//conditions:default": [], }), features = ["-use_header_modules"], -@@ -3233,7 +3307,7 @@ v8_library( +@@ -3236,7 +3310,7 @@ v8_library( ], icu_deps = [ ":icu/generated_torque_headers", @@ -480,7 +480,7 @@ index 3d37f45ced..b84afd0759 100644 ], icu_srcs = [ ":generated_regexp_special_case", -@@ -3248,23 +3322,29 @@ v8_library( +@@ -3251,23 +3325,29 @@ v8_library( ], deps = [ ":v8_libbase", @@ -511,7 +511,7 @@ index 3d37f45ced..b84afd0759 100644 deps = [":noicu/v8"], ) -@@ -3311,7 +3391,7 @@ v8_binary( +@@ -3314,7 +3394,7 @@ v8_binary( "UNISTR_FROM_CHAR_EXPLICIT=", ], deps = [ @@ -520,7 +520,7 @@ index 3d37f45ced..b84afd0759 100644 ], ) -@@ -3322,12 +3402,12 @@ v8_binary( +@@ -3325,12 +3405,12 @@ v8_binary( ":torque_base_files", ], copts = select({ @@ -535,7 +535,7 @@ index 3d37f45ced..b84afd0759 100644 "//conditions:default": [], }), deps = ["v8_libbase"], -@@ -3338,7 +3418,7 @@ v8_binary( +@@ -3341,7 +3421,7 @@ v8_binary( srcs = [":mksnapshot_files"], icu_deps = [":icu/v8_libshared"], linkopts = select({ From c881b3675445184ec2d0fd9f81abce2cdd65a7d8 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 14:41:07 -0800 Subject: [PATCH 05/13] review: move patch. Signed-off-by: Piotr Sikora --- bazel/{ => external}/v8.patch | 0 bazel/repositories.bzl | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename bazel/{ => external}/v8.patch (100%) diff --git a/bazel/v8.patch b/bazel/external/v8.patch similarity index 100% rename from bazel/v8.patch rename to bazel/external/v8.patch diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 85c60a5fd..f184d8d0d 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -118,7 +118,7 @@ def proxy_wasm_cpp_host_repositories(): commit = "11559b4461ac0c3328354229e03c2a989b104ff9", remote = "https://chromium.googlesource.com/v8/v8", shallow_since = "1641210631 +0000", - patches = ["//:bazel/v8.patch"], + patches = ["@proxy_wasm_cpp_host//bazel/external:v8.patch"], patch_args = ["-p1"], ) From ee5b34d87653f905d4839be866baa1e922d75434 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 15:05:32 -0800 Subject: [PATCH 06/13] review: build and test V8 on Windows. Signed-off-by: Piotr Sikora --- .github/workflows/cpp.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index fd8712ff2..c3aa508e0 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -70,6 +70,8 @@ jobs: include: - os: macos-11 runtime: 'v8' + - os: windows-2022 + runtime: 'v8' steps: - uses: actions/checkout@v2 From 2971428958330adfcd498ed5c8ed576e4fc17ac8 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 15:12:58 -0800 Subject: [PATCH 07/13] review: attempt to fix build on Windows. Signed-off-by: Piotr Sikora --- bazel/external/v8.patch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bazel/external/v8.patch b/bazel/external/v8.patch index 0f227f32a..5fe082ba3 100644 --- a/bazel/external/v8.patch +++ b/bazel/external/v8.patch @@ -784,7 +784,7 @@ index 2d5d241ebf..72aae9e270 100644 if cpu_type in allowed_values: return V8CpuTypeInfo(value = cpu_type) diff --git a/bazel/defs.bzl b/bazel/defs.bzl -index 53fccf92e7..14fff6f049 100644 +index 53fccf92e7..6c2fb5166f 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -89,7 +89,7 @@ def _default_args(): @@ -899,15 +899,17 @@ index 53fccf92e7..14fff6f049 100644 "//conditions:default": ":torque", }), ) -@@ -334,6 +365,7 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -334,7 +365,9 @@ def _v8_target_cpu_transition_impl(settings, attr): "haswell": "x64", "k8": "x64", "x86_64": "x64", + "darwin": "x64", "darwin_x86_64": "x64", ++ "x64_windows": "x64", "x86": "ia32", "ppc": "ppc64", -@@ -342,14 +374,14 @@ def _v8_target_cpu_transition_impl(settings, attr): + "arm64-v8a": "arm64", +@@ -342,14 +375,14 @@ def _v8_target_cpu_transition_impl(settings, attr): "armeabi-v7a": "arm32", } v8_target_cpu = mapping[settings["//command_line_option:cpu"]] From 2b8269a57bfa38d0c892ae6b14cab6c58778ed95 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 15:27:17 -0800 Subject: [PATCH 08/13] review: try windows-2019. Signed-off-by: Piotr Sikora --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index c3aa508e0..6b25e16e3 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -70,7 +70,7 @@ jobs: include: - os: macos-11 runtime: 'v8' - - os: windows-2022 + - os: windows-2019 runtime: 'v8' steps: From ac2eb59edadb2c854348186e6f56dd7e7130d293 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 15:36:52 -0800 Subject: [PATCH 09/13] review: add --cxxopt=/std:c++17 for Windows. Signed-off-by: Piotr Sikora --- .bazelrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index e0247e90e..3829ab82d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,7 +11,6 @@ build:linux --linkopt=-ldl build:macos --cxxopt=-std=c++17 -# TODO(mathetake): Windows build is not verified yet. -# build:windows --cxxopt="/std:c++17" +build:windows --cxxopt=/std:c++17 # See https://bytecodealliance.github.io/wasmtime/c-api/ # build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib" From 569f08927a9a1f7910de168f88379255a07edbd9 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 17:40:49 -0800 Subject: [PATCH 10/13] review: attempt to fix linker issues on Windows. Signed-off-by: Piotr Sikora --- bazel/external/v8.patch | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/bazel/external/v8.patch b/bazel/external/v8.patch index 5fe082ba3..1d9dac15a 100644 --- a/bazel/external/v8.patch +++ b/bazel/external/v8.patch @@ -784,7 +784,7 @@ index 2d5d241ebf..72aae9e270 100644 if cpu_type in allowed_values: return V8CpuTypeInfo(value = cpu_type) diff --git a/bazel/defs.bzl b/bazel/defs.bzl -index 53fccf92e7..6c2fb5166f 100644 +index 53fccf92e7..a4e7fd6068 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -89,7 +89,7 @@ def _default_args(): @@ -796,7 +796,7 @@ index 53fccf92e7..6c2fb5166f 100644 "UNICODE", "_UNICODE", "_CRT_RAND_S", -@@ -98,29 +98,59 @@ def _default_args(): +@@ -98,29 +98,70 @@ def _default_args(): "//conditions:default": [], }), copts = select({ @@ -836,6 +836,17 @@ index 53fccf92e7..6c2fb5166f 100644 + "-std=gnu++17", + ], + "@v8//bazel/config:is_windows": [ ++ "/DNTDDI_VERSION=0x0A000000", ++ "/D_WIN32_WINNT=0x0A00", ++ "/DWINVER=0x0A00", ++ "/DWIN32", ++ "/DWIN32_LEAN_AND_MEAN", ++ "/DNOMINMAX", ++ "/DNOKERNEL", ++ "/DNOUSER", ++ "/DNOSERVICE", ++ "/DNOSOUND", ++ "/DNOMCX", + "/std:c++17", + ], + "//conditions:default": [], @@ -860,7 +871,7 @@ index 53fccf92e7..6c2fb5166f 100644 "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"], }) + select({ ":should_add_rdynamic": ["-rdynamic"], -@@ -248,8 +278,10 @@ def v8_library( +@@ -248,8 +289,10 @@ def v8_library( ) def _torque_impl(ctx): @@ -873,7 +884,7 @@ index 53fccf92e7..6c2fb5166f 100644 # Arguments args = [] -@@ -301,7 +333,6 @@ _v8_torque = rule( +@@ -301,7 +344,6 @@ _v8_torque = rule( cfg = "exec", ), "args": attr.string_list(), @@ -881,7 +892,7 @@ index 53fccf92e7..6c2fb5166f 100644 }, ) -@@ -313,7 +344,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): +@@ -313,7 +355,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): args = args, extras = extras, tool = select({ @@ -890,7 +901,7 @@ index 53fccf92e7..6c2fb5166f 100644 "//conditions:default": ":torque", }), ) -@@ -324,7 +355,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): +@@ -324,7 +366,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): args = args, extras = extras, tool = select({ @@ -899,7 +910,7 @@ index 53fccf92e7..6c2fb5166f 100644 "//conditions:default": ":torque", }), ) -@@ -334,7 +365,9 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -334,7 +376,9 @@ def _v8_target_cpu_transition_impl(settings, attr): "haswell": "x64", "k8": "x64", "x86_64": "x64", @@ -909,7 +920,7 @@ index 53fccf92e7..6c2fb5166f 100644 "x86": "ia32", "ppc": "ppc64", "arm64-v8a": "arm64", -@@ -342,14 +375,14 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -342,14 +386,14 @@ def _v8_target_cpu_transition_impl(settings, attr): "armeabi-v7a": "arm32", } v8_target_cpu = mapping[settings["//command_line_option:cpu"]] From 12a10e77bea5996a249577b8023839c7f527c4ac Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 18:53:55 -0800 Subject: [PATCH 11/13] reivew: last attempt to fix linker issues in Windows. Signed-off-by: Piotr Sikora --- bazel/external/v8.patch | 81 ++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/bazel/external/v8.patch b/bazel/external/v8.patch index 1d9dac15a..4e8c086ab 100644 --- a/bazel/external/v8.patch +++ b/bazel/external/v8.patch @@ -34,7 +34,7 @@ index e0127628ca..ef69dda4a5 100644 build:debug --compilation_mode=dbg build:debug --config=v8_enable_debugging_features diff --git a/BUILD.bazel b/BUILD.bazel -index c9864429a5..b1717e8fda 100644 +index c9864429a5..6ffb23f2b3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,6 +3,8 @@ @@ -87,7 +87,7 @@ index c9864429a5..b1717e8fda 100644 ":is_v8_enable_backtrace", ], ) -@@ -290,37 +285,41 @@ v8_config( +@@ -290,43 +285,43 @@ v8_config( "V8_ADVANCED_BIGINT_ALGORITHMS", "V8_CONCURRENT_MARKING", ] + select({ @@ -137,8 +137,14 @@ index c9864429a5..b1717e8fda 100644 + "@v8//bazel/config:is_windows": [ "V8_HAVE_TARGET_OS", "V8_TARGET_OS_WIN", - "UNICODE", -@@ -622,7 +621,7 @@ filegroup( +- "UNICODE", +- "_UNICODE", +- "_CRT_RAND_S", +- "_WIN32_WINNT=0x0602", + ], + }) + select({ + ":is_v8_enable_pointer_compression": [ +@@ -622,7 +617,7 @@ filegroup( "src/base/vlq-base64.h", "src/base/platform/yield-processor.h", ] + select({ @@ -147,7 +153,7 @@ index c9864429a5..b1717e8fda 100644 "src/base/platform/platform-posix.cc", "src/base/platform/platform-posix.h", "src/base/platform/platform-posix-time.cc", -@@ -630,19 +629,19 @@ filegroup( +@@ -630,19 +625,19 @@ filegroup( ], "//conditions:default": [], }) + select({ @@ -171,7 +177,7 @@ index c9864429a5..b1717e8fda 100644 "src/base/win32-headers.h", "src/base/debug/stack_trace_win.cc", "src/base/platform/platform-win32.cc", -@@ -654,7 +653,6 @@ filegroup( +@@ -654,7 +649,6 @@ filegroup( filegroup( name = "v8_libplatform_files", srcs = [ @@ -179,7 +185,7 @@ index c9864429a5..b1717e8fda 100644 "include/libplatform/libplatform.h", "include/libplatform/libplatform-export.h", "include/libplatform/v8-tracing.h", -@@ -982,7 +980,6 @@ filegroup( +@@ -982,7 +976,6 @@ filegroup( ":v8_cppgc_shared_files", ":v8_bigint", ":generated_bytecode_builtins_list", @@ -187,7 +193,7 @@ index c9864429a5..b1717e8fda 100644 "include/cppgc/common.h", "include/v8-inspector-protocol.h", "include/v8-inspector.h", -@@ -1966,8 +1963,6 @@ filegroup( +@@ -1966,8 +1959,6 @@ filegroup( "src/snapshot/shared-heap-serializer.cc", "src/snapshot/snapshot-compression.cc", "src/snapshot/snapshot-compression.h", @@ -196,7 +202,7 @@ index c9864429a5..b1717e8fda 100644 "src/snapshot/snapshot-data.cc", "src/snapshot/snapshot-data.h", "src/snapshot/snapshot-source-sink.cc", -@@ -2072,7 +2067,7 @@ filegroup( +@@ -2072,7 +2063,7 @@ filegroup( "src/heap/third-party/heap-api.h", "src/heap/third-party/heap-api-stub.cc", ] + select({ @@ -205,7 +211,7 @@ index c9864429a5..b1717e8fda 100644 "src/baseline/ia32/baseline-assembler-ia32-inl.h", "src/baseline/ia32/baseline-compiler-ia32-inl.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", -@@ -2100,7 +2095,7 @@ filegroup( +@@ -2100,7 +2091,7 @@ filegroup( "src/regexp/ia32/regexp-macro-assembler-ia32.h", "src/wasm/baseline/ia32/liftoff-assembler-ia32.h", ], @@ -214,7 +220,7 @@ index c9864429a5..b1717e8fda 100644 "src/baseline/x64/baseline-assembler-x64-inl.h", "src/baseline/x64/baseline-compiler-x64-inl.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", -@@ -2132,7 +2127,7 @@ filegroup( +@@ -2132,7 +2123,7 @@ filegroup( "src/regexp/x64/regexp-macro-assembler-x64.h", "src/wasm/baseline/x64/liftoff-assembler-x64.h", ], @@ -223,7 +229,7 @@ index c9864429a5..b1717e8fda 100644 "src/baseline/arm/baseline-assembler-arm-inl.h", "src/baseline/arm/baseline-compiler-arm-inl.h", "src/codegen/arm/assembler-arm-inl.h", -@@ -2163,7 +2158,7 @@ filegroup( +@@ -2163,7 +2154,7 @@ filegroup( "src/regexp/arm/regexp-macro-assembler-arm.h", "src/wasm/baseline/arm/liftoff-assembler-arm.h", ], @@ -232,7 +238,7 @@ index c9864429a5..b1717e8fda 100644 "src/baseline/arm64/baseline-assembler-arm64-inl.h", "src/baseline/arm64/baseline-compiler-arm64-inl.h", "src/codegen/arm64/assembler-arm64-inl.h", -@@ -2206,31 +2201,59 @@ filegroup( +@@ -2206,31 +2197,59 @@ filegroup( "src/regexp/arm64/regexp-macro-assembler-arm64.h", "src/wasm/baseline/arm64/liftoff-assembler-arm64.h", ], @@ -299,7 +305,7 @@ index c9864429a5..b1717e8fda 100644 "src/diagnostics/unwinding-info-win64.cc", "src/diagnostics/unwinding-info-win64.h", ], -@@ -2712,10 +2735,11 @@ filegroup( +@@ -2712,10 +2731,11 @@ filegroup( "src/interpreter/interpreter-intrinsics-generator.cc", "src/interpreter/interpreter-intrinsics-generator.h", ] + select({ @@ -315,7 +321,7 @@ index c9864429a5..b1717e8fda 100644 }) + select({ ":is_v8_enable_webassembly": [ "src/builtins/builtins-wasm-gen.cc", -@@ -2832,13 +2856,14 @@ filegroup( +@@ -2832,13 +2852,14 @@ filegroup( # Note these cannot be v8_target_is_* selects because these contain # inline assembly that runs inside the executable. Since these are # linked directly into mksnapshot, they must use the actual target cpu. @@ -337,7 +343,7 @@ index c9864429a5..b1717e8fda 100644 }), ) -@@ -2992,16 +3017,17 @@ filegroup( +@@ -2992,16 +3013,17 @@ filegroup( srcs = [ "src/init/setup-isolate-deserialize.cc", ] + select({ @@ -359,7 +365,7 @@ index c9864429a5..b1717e8fda 100644 }), ) -@@ -3010,16 +3036,17 @@ filegroup( +@@ -3010,16 +3032,17 @@ filegroup( srcs = [ "src/init/setup-isolate-deserialize.cc", ] + select({ @@ -381,7 +387,7 @@ index c9864429a5..b1717e8fda 100644 }), ) -@@ -3050,7 +3077,7 @@ v8_torque( +@@ -3050,7 +3073,7 @@ v8_torque( ":is_v8_annotate_torque_ir": ["-annotate-ir"], "//conditions:default": [], }) + select({ @@ -390,7 +396,7 @@ index c9864429a5..b1717e8fda 100644 "//conditions:default": [], }), extras = [ -@@ -3079,9 +3106,39 @@ v8_torque( +@@ -3079,9 +3102,39 @@ v8_torque( noicu_srcs = [":noicu/torque_files"], ) @@ -431,7 +437,7 @@ index c9864429a5..b1717e8fda 100644 outs = [ "include/inspector/Debugger.h", "include/inspector/Runtime.h", -@@ -3102,10 +3159,27 @@ genrule( +@@ -3102,10 +3155,27 @@ genrule( "src/inspector/protocol/Schema.cpp", "src/inspector/protocol/Schema.h", ], @@ -462,7 +468,7 @@ index c9864429a5..b1717e8fda 100644 ) filegroup( -@@ -3218,7 +3292,7 @@ cc_library( +@@ -3218,7 +3288,7 @@ cc_library( ":torque_base_files", ], copts = select({ @@ -471,7 +477,7 @@ index c9864429a5..b1717e8fda 100644 "//conditions:default": [], }), features = ["-use_header_modules"], -@@ -3236,7 +3310,7 @@ v8_library( +@@ -3236,7 +3306,7 @@ v8_library( ], icu_deps = [ ":icu/generated_torque_headers", @@ -480,7 +486,7 @@ index c9864429a5..b1717e8fda 100644 ], icu_srcs = [ ":generated_regexp_special_case", -@@ -3251,23 +3325,29 @@ v8_library( +@@ -3251,23 +3321,29 @@ v8_library( ], deps = [ ":v8_libbase", @@ -511,7 +517,7 @@ index c9864429a5..b1717e8fda 100644 deps = [":noicu/v8"], ) -@@ -3314,7 +3394,7 @@ v8_binary( +@@ -3314,7 +3390,7 @@ v8_binary( "UNISTR_FROM_CHAR_EXPLICIT=", ], deps = [ @@ -520,7 +526,7 @@ index c9864429a5..b1717e8fda 100644 ], ) -@@ -3325,12 +3405,12 @@ v8_binary( +@@ -3325,12 +3401,12 @@ v8_binary( ":torque_base_files", ], copts = select({ @@ -535,7 +541,7 @@ index c9864429a5..b1717e8fda 100644 "//conditions:default": [], }), deps = ["v8_libbase"], -@@ -3341,7 +3421,7 @@ v8_binary( +@@ -3341,7 +3417,7 @@ v8_binary( srcs = [":mksnapshot_files"], icu_deps = [":icu/v8_libshared"], linkopts = select({ @@ -784,7 +790,7 @@ index 2d5d241ebf..72aae9e270 100644 if cpu_type in allowed_values: return V8CpuTypeInfo(value = cpu_type) diff --git a/bazel/defs.bzl b/bazel/defs.bzl -index 53fccf92e7..a4e7fd6068 100644 +index 53fccf92e7..f63d492d06 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -89,7 +89,7 @@ def _default_args(): @@ -796,7 +802,7 @@ index 53fccf92e7..a4e7fd6068 100644 "UNICODE", "_UNICODE", "_CRT_RAND_S", -@@ -98,29 +98,70 @@ def _default_args(): +@@ -98,29 +98,77 @@ def _default_args(): "//conditions:default": [], }), copts = select({ @@ -847,6 +853,9 @@ index 53fccf92e7..a4e7fd6068 100644 + "/DNOSERVICE", + "/DNOSOUND", + "/DNOMCX", ++ "/D_CRT_RAND_S", ++ "/D_UNICODE", ++ "/DUNICODE", + "/std:c++17", + ], + "//conditions:default": [], @@ -856,6 +865,10 @@ index 53fccf92e7..a4e7fd6068 100644 + # of recursive inlining of "always_inline" functions. + "-O1", + ], ++ "@v8//bazel/config:is_windows": [ ++ # Workaround for .lib exceeding 4 GiB (error LNK1248). ++ "/Os", ++ ], + "//conditions:default": [], }), includes = ["include"], @@ -871,7 +884,7 @@ index 53fccf92e7..a4e7fd6068 100644 "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"], }) + select({ ":should_add_rdynamic": ["-rdynamic"], -@@ -248,8 +289,10 @@ def v8_library( +@@ -248,8 +296,10 @@ def v8_library( ) def _torque_impl(ctx): @@ -884,7 +897,7 @@ index 53fccf92e7..a4e7fd6068 100644 # Arguments args = [] -@@ -301,7 +344,6 @@ _v8_torque = rule( +@@ -301,7 +351,6 @@ _v8_torque = rule( cfg = "exec", ), "args": attr.string_list(), @@ -892,7 +905,7 @@ index 53fccf92e7..a4e7fd6068 100644 }, ) -@@ -313,7 +355,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): +@@ -313,7 +362,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): args = args, extras = extras, tool = select({ @@ -901,7 +914,7 @@ index 53fccf92e7..a4e7fd6068 100644 "//conditions:default": ":torque", }), ) -@@ -324,7 +366,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): +@@ -324,7 +373,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): args = args, extras = extras, tool = select({ @@ -910,7 +923,7 @@ index 53fccf92e7..a4e7fd6068 100644 "//conditions:default": ":torque", }), ) -@@ -334,7 +376,9 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -334,7 +383,9 @@ def _v8_target_cpu_transition_impl(settings, attr): "haswell": "x64", "k8": "x64", "x86_64": "x64", @@ -920,7 +933,7 @@ index 53fccf92e7..a4e7fd6068 100644 "x86": "ia32", "ppc": "ppc64", "arm64-v8a": "arm64", -@@ -342,14 +386,14 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -342,14 +393,14 @@ def _v8_target_cpu_transition_impl(settings, attr): "armeabi-v7a": "arm32", } v8_target_cpu = mapping[settings["//command_line_option:cpu"]] From 1e62fd23d7a2dbee34b9804d42d94fdbcc9a3f8a Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 20:05:52 -0800 Subject: [PATCH 12/13] review: revert incomplete Windows support. Signed-off-by: Piotr Sikora --- .bazelrc | 3 +- .github/workflows/cpp.yml | 2 - bazel/external/v8.patch | 94 ++++++++++++++------------------------- 3 files changed, 36 insertions(+), 63 deletions(-) diff --git a/.bazelrc b/.bazelrc index 3829ab82d..e0247e90e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,6 +11,7 @@ build:linux --linkopt=-ldl build:macos --cxxopt=-std=c++17 -build:windows --cxxopt=/std:c++17 +# TODO(mathetake): Windows build is not verified yet. +# build:windows --cxxopt="/std:c++17" # See https://bytecodealliance.github.io/wasmtime/c-api/ # build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib" diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 6b25e16e3..fd8712ff2 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -70,8 +70,6 @@ jobs: include: - os: macos-11 runtime: 'v8' - - os: windows-2019 - runtime: 'v8' steps: - uses: actions/checkout@v2 diff --git a/bazel/external/v8.patch b/bazel/external/v8.patch index 4e8c086ab..0f227f32a 100644 --- a/bazel/external/v8.patch +++ b/bazel/external/v8.patch @@ -34,7 +34,7 @@ index e0127628ca..ef69dda4a5 100644 build:debug --compilation_mode=dbg build:debug --config=v8_enable_debugging_features diff --git a/BUILD.bazel b/BUILD.bazel -index c9864429a5..6ffb23f2b3 100644 +index c9864429a5..b1717e8fda 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,6 +3,8 @@ @@ -87,7 +87,7 @@ index c9864429a5..6ffb23f2b3 100644 ":is_v8_enable_backtrace", ], ) -@@ -290,43 +285,43 @@ v8_config( +@@ -290,37 +285,41 @@ v8_config( "V8_ADVANCED_BIGINT_ALGORITHMS", "V8_CONCURRENT_MARKING", ] + select({ @@ -137,14 +137,8 @@ index c9864429a5..6ffb23f2b3 100644 + "@v8//bazel/config:is_windows": [ "V8_HAVE_TARGET_OS", "V8_TARGET_OS_WIN", -- "UNICODE", -- "_UNICODE", -- "_CRT_RAND_S", -- "_WIN32_WINNT=0x0602", - ], - }) + select({ - ":is_v8_enable_pointer_compression": [ -@@ -622,7 +617,7 @@ filegroup( + "UNICODE", +@@ -622,7 +621,7 @@ filegroup( "src/base/vlq-base64.h", "src/base/platform/yield-processor.h", ] + select({ @@ -153,7 +147,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/base/platform/platform-posix.cc", "src/base/platform/platform-posix.h", "src/base/platform/platform-posix-time.cc", -@@ -630,19 +625,19 @@ filegroup( +@@ -630,19 +629,19 @@ filegroup( ], "//conditions:default": [], }) + select({ @@ -177,7 +171,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/base/win32-headers.h", "src/base/debug/stack_trace_win.cc", "src/base/platform/platform-win32.cc", -@@ -654,7 +649,6 @@ filegroup( +@@ -654,7 +653,6 @@ filegroup( filegroup( name = "v8_libplatform_files", srcs = [ @@ -185,7 +179,7 @@ index c9864429a5..6ffb23f2b3 100644 "include/libplatform/libplatform.h", "include/libplatform/libplatform-export.h", "include/libplatform/v8-tracing.h", -@@ -982,7 +976,6 @@ filegroup( +@@ -982,7 +980,6 @@ filegroup( ":v8_cppgc_shared_files", ":v8_bigint", ":generated_bytecode_builtins_list", @@ -193,7 +187,7 @@ index c9864429a5..6ffb23f2b3 100644 "include/cppgc/common.h", "include/v8-inspector-protocol.h", "include/v8-inspector.h", -@@ -1966,8 +1959,6 @@ filegroup( +@@ -1966,8 +1963,6 @@ filegroup( "src/snapshot/shared-heap-serializer.cc", "src/snapshot/snapshot-compression.cc", "src/snapshot/snapshot-compression.h", @@ -202,7 +196,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/snapshot/snapshot-data.cc", "src/snapshot/snapshot-data.h", "src/snapshot/snapshot-source-sink.cc", -@@ -2072,7 +2063,7 @@ filegroup( +@@ -2072,7 +2067,7 @@ filegroup( "src/heap/third-party/heap-api.h", "src/heap/third-party/heap-api-stub.cc", ] + select({ @@ -211,7 +205,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/baseline/ia32/baseline-assembler-ia32-inl.h", "src/baseline/ia32/baseline-compiler-ia32-inl.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", -@@ -2100,7 +2091,7 @@ filegroup( +@@ -2100,7 +2095,7 @@ filegroup( "src/regexp/ia32/regexp-macro-assembler-ia32.h", "src/wasm/baseline/ia32/liftoff-assembler-ia32.h", ], @@ -220,7 +214,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/baseline/x64/baseline-assembler-x64-inl.h", "src/baseline/x64/baseline-compiler-x64-inl.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", -@@ -2132,7 +2123,7 @@ filegroup( +@@ -2132,7 +2127,7 @@ filegroup( "src/regexp/x64/regexp-macro-assembler-x64.h", "src/wasm/baseline/x64/liftoff-assembler-x64.h", ], @@ -229,7 +223,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/baseline/arm/baseline-assembler-arm-inl.h", "src/baseline/arm/baseline-compiler-arm-inl.h", "src/codegen/arm/assembler-arm-inl.h", -@@ -2163,7 +2154,7 @@ filegroup( +@@ -2163,7 +2158,7 @@ filegroup( "src/regexp/arm/regexp-macro-assembler-arm.h", "src/wasm/baseline/arm/liftoff-assembler-arm.h", ], @@ -238,7 +232,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/baseline/arm64/baseline-assembler-arm64-inl.h", "src/baseline/arm64/baseline-compiler-arm64-inl.h", "src/codegen/arm64/assembler-arm64-inl.h", -@@ -2206,31 +2197,59 @@ filegroup( +@@ -2206,31 +2201,59 @@ filegroup( "src/regexp/arm64/regexp-macro-assembler-arm64.h", "src/wasm/baseline/arm64/liftoff-assembler-arm64.h", ], @@ -305,7 +299,7 @@ index c9864429a5..6ffb23f2b3 100644 "src/diagnostics/unwinding-info-win64.cc", "src/diagnostics/unwinding-info-win64.h", ], -@@ -2712,10 +2731,11 @@ filegroup( +@@ -2712,10 +2735,11 @@ filegroup( "src/interpreter/interpreter-intrinsics-generator.cc", "src/interpreter/interpreter-intrinsics-generator.h", ] + select({ @@ -321,7 +315,7 @@ index c9864429a5..6ffb23f2b3 100644 }) + select({ ":is_v8_enable_webassembly": [ "src/builtins/builtins-wasm-gen.cc", -@@ -2832,13 +2852,14 @@ filegroup( +@@ -2832,13 +2856,14 @@ filegroup( # Note these cannot be v8_target_is_* selects because these contain # inline assembly that runs inside the executable. Since these are # linked directly into mksnapshot, they must use the actual target cpu. @@ -343,7 +337,7 @@ index c9864429a5..6ffb23f2b3 100644 }), ) -@@ -2992,16 +3013,17 @@ filegroup( +@@ -2992,16 +3017,17 @@ filegroup( srcs = [ "src/init/setup-isolate-deserialize.cc", ] + select({ @@ -365,7 +359,7 @@ index c9864429a5..6ffb23f2b3 100644 }), ) -@@ -3010,16 +3032,17 @@ filegroup( +@@ -3010,16 +3036,17 @@ filegroup( srcs = [ "src/init/setup-isolate-deserialize.cc", ] + select({ @@ -387,7 +381,7 @@ index c9864429a5..6ffb23f2b3 100644 }), ) -@@ -3050,7 +3073,7 @@ v8_torque( +@@ -3050,7 +3077,7 @@ v8_torque( ":is_v8_annotate_torque_ir": ["-annotate-ir"], "//conditions:default": [], }) + select({ @@ -396,7 +390,7 @@ index c9864429a5..6ffb23f2b3 100644 "//conditions:default": [], }), extras = [ -@@ -3079,9 +3102,39 @@ v8_torque( +@@ -3079,9 +3106,39 @@ v8_torque( noicu_srcs = [":noicu/torque_files"], ) @@ -437,7 +431,7 @@ index c9864429a5..6ffb23f2b3 100644 outs = [ "include/inspector/Debugger.h", "include/inspector/Runtime.h", -@@ -3102,10 +3155,27 @@ genrule( +@@ -3102,10 +3159,27 @@ genrule( "src/inspector/protocol/Schema.cpp", "src/inspector/protocol/Schema.h", ], @@ -468,7 +462,7 @@ index c9864429a5..6ffb23f2b3 100644 ) filegroup( -@@ -3218,7 +3288,7 @@ cc_library( +@@ -3218,7 +3292,7 @@ cc_library( ":torque_base_files", ], copts = select({ @@ -477,7 +471,7 @@ index c9864429a5..6ffb23f2b3 100644 "//conditions:default": [], }), features = ["-use_header_modules"], -@@ -3236,7 +3306,7 @@ v8_library( +@@ -3236,7 +3310,7 @@ v8_library( ], icu_deps = [ ":icu/generated_torque_headers", @@ -486,7 +480,7 @@ index c9864429a5..6ffb23f2b3 100644 ], icu_srcs = [ ":generated_regexp_special_case", -@@ -3251,23 +3321,29 @@ v8_library( +@@ -3251,23 +3325,29 @@ v8_library( ], deps = [ ":v8_libbase", @@ -517,7 +511,7 @@ index c9864429a5..6ffb23f2b3 100644 deps = [":noicu/v8"], ) -@@ -3314,7 +3390,7 @@ v8_binary( +@@ -3314,7 +3394,7 @@ v8_binary( "UNISTR_FROM_CHAR_EXPLICIT=", ], deps = [ @@ -526,7 +520,7 @@ index c9864429a5..6ffb23f2b3 100644 ], ) -@@ -3325,12 +3401,12 @@ v8_binary( +@@ -3325,12 +3405,12 @@ v8_binary( ":torque_base_files", ], copts = select({ @@ -541,7 +535,7 @@ index c9864429a5..6ffb23f2b3 100644 "//conditions:default": [], }), deps = ["v8_libbase"], -@@ -3341,7 +3417,7 @@ v8_binary( +@@ -3341,7 +3421,7 @@ v8_binary( srcs = [":mksnapshot_files"], icu_deps = [":icu/v8_libshared"], linkopts = select({ @@ -790,7 +784,7 @@ index 2d5d241ebf..72aae9e270 100644 if cpu_type in allowed_values: return V8CpuTypeInfo(value = cpu_type) diff --git a/bazel/defs.bzl b/bazel/defs.bzl -index 53fccf92e7..f63d492d06 100644 +index 53fccf92e7..14fff6f049 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -89,7 +89,7 @@ def _default_args(): @@ -802,7 +796,7 @@ index 53fccf92e7..f63d492d06 100644 "UNICODE", "_UNICODE", "_CRT_RAND_S", -@@ -98,29 +98,77 @@ def _default_args(): +@@ -98,29 +98,59 @@ def _default_args(): "//conditions:default": [], }), copts = select({ @@ -842,20 +836,6 @@ index 53fccf92e7..f63d492d06 100644 + "-std=gnu++17", + ], + "@v8//bazel/config:is_windows": [ -+ "/DNTDDI_VERSION=0x0A000000", -+ "/D_WIN32_WINNT=0x0A00", -+ "/DWINVER=0x0A00", -+ "/DWIN32", -+ "/DWIN32_LEAN_AND_MEAN", -+ "/DNOMINMAX", -+ "/DNOKERNEL", -+ "/DNOUSER", -+ "/DNOSERVICE", -+ "/DNOSOUND", -+ "/DNOMCX", -+ "/D_CRT_RAND_S", -+ "/D_UNICODE", -+ "/DUNICODE", + "/std:c++17", + ], + "//conditions:default": [], @@ -865,10 +845,6 @@ index 53fccf92e7..f63d492d06 100644 + # of recursive inlining of "always_inline" functions. + "-O1", + ], -+ "@v8//bazel/config:is_windows": [ -+ # Workaround for .lib exceeding 4 GiB (error LNK1248). -+ "/Os", -+ ], + "//conditions:default": [], }), includes = ["include"], @@ -884,7 +860,7 @@ index 53fccf92e7..f63d492d06 100644 "//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"], }) + select({ ":should_add_rdynamic": ["-rdynamic"], -@@ -248,8 +296,10 @@ def v8_library( +@@ -248,8 +278,10 @@ def v8_library( ) def _torque_impl(ctx): @@ -897,7 +873,7 @@ index 53fccf92e7..f63d492d06 100644 # Arguments args = [] -@@ -301,7 +351,6 @@ _v8_torque = rule( +@@ -301,7 +333,6 @@ _v8_torque = rule( cfg = "exec", ), "args": attr.string_list(), @@ -905,7 +881,7 @@ index 53fccf92e7..f63d492d06 100644 }, ) -@@ -313,7 +362,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): +@@ -313,7 +344,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): args = args, extras = extras, tool = select({ @@ -914,7 +890,7 @@ index 53fccf92e7..f63d492d06 100644 "//conditions:default": ":torque", }), ) -@@ -324,7 +373,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): +@@ -324,7 +355,7 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras): args = args, extras = extras, tool = select({ @@ -923,17 +899,15 @@ index 53fccf92e7..f63d492d06 100644 "//conditions:default": ":torque", }), ) -@@ -334,7 +383,9 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -334,6 +365,7 @@ def _v8_target_cpu_transition_impl(settings, attr): "haswell": "x64", "k8": "x64", "x86_64": "x64", + "darwin": "x64", "darwin_x86_64": "x64", -+ "x64_windows": "x64", "x86": "ia32", "ppc": "ppc64", - "arm64-v8a": "arm64", -@@ -342,14 +393,14 @@ def _v8_target_cpu_transition_impl(settings, attr): +@@ -342,14 +374,14 @@ def _v8_target_cpu_transition_impl(settings, attr): "armeabi-v7a": "arm32", } v8_target_cpu = mapping[settings["//command_line_option:cpu"]] From 23ba330ae4df9c6935ec1e6f7ffb3d5dc65679c1 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Mon, 3 Jan 2022 23:52:08 -0800 Subject: [PATCH 13/13] review: fix signature test rebuilding V8 from scratch. Signed-off-by: Piotr Sikora --- .github/workflows/cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index fc6e9d266..547fdfc64 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -113,4 +113,4 @@ jobs: - name: Test (signed Wasm module) run: | - bazel test --test_output=errors --define runtime=${{ matrix.runtime }} --per_file_copt=//...@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" //test:signature_util_test + bazel test --test_output=errors --define runtime=${{ matrix.runtime }} --per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\" //test:signature_util_test