Add native Windows MSVC V8 source archive builds (#57269)

## Why

The Bazel V8 source build supported Windows GNU but lacked an MSVC-targeting toolchain to produce `*-pc-windows-msvc` archives.

## What changed

- Add opt-in archive targets for native Windows x64 and ARM64 hosts, selected by `//third_party/v8:rusty_v8_native_windows_archive_for_target`.
- Fetch pinned LLVM and scope its `clang-cl` toolchain to V8 artifacts, using the installed Microsoft SDK. Bundle Chromium libc++ and compiler-rt builtins into the resulting `.lib`.
- Adapt V8 dependencies, assembly, snapshot generation, and platform feature settings for MSVC, and derive test metadata from the selected engine features.
- Document the native build workflow. Existing MSVC consumers continue using prebuilt artifacts; generated Rust bindings and publishing integration remain separate.

GitOrigin-RevId: abd5049245aece90a116fc3bfeac2b158a76f6af
This commit is contained in:
Sean Huang
2026-10-26 21:30:41 +00:00
committed by copyberry
parent fcb3ba7558
commit 0818b91867
20 changed files with 661 additions and 199 deletions
+19
View File
@@ -151,6 +151,14 @@ bazel_dep(name = "rules_cc", version = "0.2.18")
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")
single_version_override(
module_name = "rules_cc",
patch_strip = 1,
patches = [
"//patches:rules_cc_windows_native_llvm.patch",
],
)
bazel_dep(name = "rules_platform", version = "0.1.0")
bazel_dep(name = "rules_pkg", version = "1.0.1")
bazel_dep(name = "aws-lc", version = "5.1.0.bcr.1")
@@ -845,6 +853,17 @@ pip.parse(
)
use_repo(pip, "v8_python_deps")
native_windows_llvm = use_repo_rule("//third_party/v8:native_windows.bzl", "native_windows_llvm")
native_windows_llvm(name = "v8_native_windows_llvm")
native_windows_cc = use_repo_rule("//third_party/v8:native_windows.bzl", "native_windows_cc")
native_windows_cc(
name = "v8_native_windows_cc",
native_llvm = "@v8_native_windows_llvm//:BUILD.bazel",
)
v8_dependencies = use_extension("//third_party/v8:dependencies.bzl", "dependencies")
use_repo(
v8_dependencies,
+1
View File
@@ -1,4 +1,5 @@
exports_files([
"rules_cc_windows_native_llvm.patch",
"abseil_windows_gnullvm_thread_identity.patch",
"bzip2_windows_stack_args.patch",
"llvm_rusty_v8_custom_libcxx.patch",
@@ -0,0 +1,37 @@
# Reuse rules_cc's installed SDK setup with an explicitly declared LLVM repo.
# Only the V8 repository has native_llvm; ordinary local_config_cc behaves
# exactly as upstream, including the caller's BAZEL_LLVM/USE_CLANG_CL.
# Preserve DUMPBIN when selecting clang-cl; the upstream MSVC template uses it.
diff --git a/cc/private/toolchain/windows_cc_configure.bzl b/cc/private/toolchain/windows_cc_configure.bzl
--- a/cc/private/toolchain/windows_cc_configure.bzl
+++ b/cc/private/toolchain/windows_cc_configure.bzl
@@ -539,6 +539,12 @@
The path to the LLVM installation, or None if not found.
"""
+ # Codex's opt-in V8 toolchain supplies a Bazel-fetched compiler.
+ # Ordinary cc_autoconf repositories have no such attribute.
+ llvm_label = getattr(repository_ctx.attr, "native_llvm", None)
+ if llvm_label:
+ return str(repository_ctx.path(llvm_label).dirname).replace("/", "\\")
+
# 1. Check if BAZEL_LLVM is already set by user.
bazel_llvm = _get_path_env_var(repository_ctx, "BAZEL_LLVM")
if bazel_llvm:
@@ -602,7 +608,7 @@
def _use_clang_cl(repository_ctx):
"""Returns True if USE_CLANG_CL is set to 1."""
- return _get_env_var(repository_ctx, "USE_CLANG_CL", default = "0") == "1"
+ return getattr(repository_ctx.attr, "native_llvm", None) != None or _get_env_var(repository_ctx, "USE_CLANG_CL", default = "0") == "1"
def _find_missing_llvm_tools(repository_ctx, llvm_path):
"""Check if any required tool is missing under given LLVM path."""
@@ -716,6 +722,7 @@
build_tools["CL"] = find_llvm_tool(repository_ctx, llvm_path, "clang-cl.exe")
build_tools["ML"] = find_msvc_tool(repository_ctx, vc_path, "ml64.exe", "x64")
+ build_tools["DUMPBIN"] = find_msvc_tool(repository_ctx, vc_path, "dumpbin.exe", target_arch)
build_tools["LINK"] = find_llvm_tool(repository_ctx, llvm_path, "lld-link.exe")
if not build_tools["LINK"]:
build_tools["LINK"] = find_msvc_tool(repository_ctx, vc_path, "link.exe", "x64")
-122
View File
@@ -179,128 +179,6 @@ index 8c824e3..f8144d0 100644
#else
UNREACHABLE();
#endif
diff --git a/orig/v8-15.0.245.2/src/heap/base/asm/x64/push_registers_masm.asm b/mod/v8-15.0.245.2/src/heap/base/asm/x64/push_registers_masm.asm
index d0d0563..f3f5952 100644
--- a/orig/v8-15.0.245.2/src/heap/base/asm/x64/push_registers_masm.asm
+++ b/mod/v8-15.0.245.2/src/heap/base/asm/x64/push_registers_masm.asm
@@ -1,70 +1,47 @@
-;; Copyright 2020 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.
-
-;; MASM syntax
-;; https://docs.microsoft.com/en-us/cpp/assembler/masm/microsoft-macro-assembler-reference?view=vs-2019
-
-public PushAllRegistersAndIterateStack
-
-.code
-PushAllRegistersAndIterateStack proc frame
- ;; Push all callee-saved registers to get them on the stack for conservative
- ;; stack scanning.
- ;;
- ;; We maintain 16-byte alignment at calls. There is an 8-byte return address
- ;; on the stack and we push 232 bytes which maintains 16-byte stack
- ;; alignment at the call.
- ;; Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention
- ;;
- ;; rbp is callee-saved. Maintain proper frame pointer for debugging.
- push rbp
- .pushreg rbp
- mov rbp, rsp
- .setframe rbp, 0
- push 0CDCDCDh ;; Dummy for alignment.
- .allocstack 8
- push rsi
- .pushreg rsi
- push rdi
- .pushreg rdi
- push rbx
- .pushreg rbx
- push r12
- .pushreg r12
- push r13
- .pushreg r13
- push r14
- .pushreg r14
- push r15
- .pushreg r15
- sub rsp, 160
- .allocstack 160
- .endprolog
- ;; Use aligned instrs as we are certain that the stack is properly aligned.
- movdqa xmmword ptr [rsp + 144], xmm6
- movdqa xmmword ptr [rsp + 128], xmm7
- movdqa xmmword ptr [rsp + 112], xmm8
- movdqa xmmword ptr [rsp + 96], xmm9
- movdqa xmmword ptr [rsp + 80], xmm10
- movdqa xmmword ptr [rsp + 64], xmm11
- movdqa xmmword ptr [rsp + 48], xmm12
- movdqa xmmword ptr [rsp + 32], xmm13
- movdqa xmmword ptr [rsp + 16], xmm14
- movdqa xmmword ptr [rsp], xmm15
- ;; Pass 1st parameter (rcx) unchanged (Stack*).
- ;; Pass 2nd parameter (rdx) unchanged (StackVisitor*).
- ;; Save 3rd parameter (r8; IterateStackCallback)
- mov r9, r8
- ;; Pass 3rd parameter as rsp (stack pointer).
- mov r8, rsp
- ;; Call the callback.
- call r9
- ;; Pop the callee-saved registers.
- add rsp, 224
- ;; Restore rbp as it was used as frame pointer.
- pop rbp
- ret
- PushAllRegistersAndIterateStack endp
-
-end
+.text
+.globl PushAllRegistersAndIterateStack
+.seh_proc PushAllRegistersAndIterateStack
+PushAllRegistersAndIterateStack:
+ push %rbp
+ .seh_pushreg %rbp
+ mov %rsp, %rbp
+ .seh_setframe %rbp, 0
+ push $0xCDCDCD
+ .seh_stackalloc 8
+ push %rsi
+ .seh_pushreg %rsi
+ push %rdi
+ .seh_pushreg %rdi
+ push %rbx
+ .seh_pushreg %rbx
+ push %r12
+ .seh_pushreg %r12
+ push %r13
+ .seh_pushreg %r13
+ push %r14
+ .seh_pushreg %r14
+ push %r15
+ .seh_pushreg %r15
+ sub $160, %rsp
+ .seh_stackalloc 160
+ # Preserve Windows unwind metadata even though this is now GNU syntax.
+ # Without the .seh_* directives, SEH and stack walking can mis-handle
+ # unwinding across this callback frame.
+ .seh_endprologue
+ movdqa %xmm6, 144(%rsp)
+ movdqa %xmm7, 128(%rsp)
+ movdqa %xmm8, 112(%rsp)
+ movdqa %xmm9, 96(%rsp)
+ movdqa %xmm10, 80(%rsp)
+ movdqa %xmm11, 64(%rsp)
+ movdqa %xmm12, 48(%rsp)
+ movdqa %xmm13, 32(%rsp)
+ movdqa %xmm14, 16(%rsp)
+ movdqa %xmm15, 0(%rsp)
+ mov %r8, %r9
+ mov %rsp, %r8
+ call *%r9
+ add $224, %rsp
+ pop %rbp
+ ret
+.seh_endproc
diff --git a/orig/v8-15.0.245.2/src/libplatform/default-thread-isolated-allocator.cc b/mod/v8-15.0.245.2/src/libplatform/default-thread-isolated-allocator.cc
index bda0e43..b44f1d9 100644
--- a/orig/v8-15.0.245.2/src/libplatform/default-thread-isolated-allocator.cc
+116 -9
View File
@@ -19,10 +19,21 @@ exports_files([
"fp16.BUILD.bazel",
"highway.BUILD.bazel",
"icu.BUILD.bazel",
"libcxx_rules.bzl",
"native_windows.bzl",
"push_registers_gnullvm.S",
"simdutf.BUILD.bazel",
"v8_defs.patch",
])
config_setting(
name = "platform_windows_msvc",
constraint_values = [
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
)
config_setting(
name = "platform_aarch64_unknown_linux_musl",
constraint_values = [
@@ -48,6 +59,17 @@ config_setting(
},
)
config_setting(
name = "use_rusty_v8_custom_libcxx_native_windows",
constraint_values = [
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
flag_values = {
"@v8//:v8_use_rusty_v8_custom_libcxx": "True",
},
)
alias(
name = "v8_152_2_0_x86_64_pc_windows_msvc",
actual = "@rusty_v8_152_2_0_x86_64_pc_windows_msvc_archive//file",
@@ -208,9 +230,20 @@ alias(
}),
)
V8_COPTS = ["-std=c++20"]
V8_COPTS = select({
":platform_windows_msvc": [
"/std:c++20",
"/Zc:__cplusplus",
],
"//conditions:default": ["-std=c++20"],
})
V8_CUSTOM_LIBCXX_COPTS = select({
":use_rusty_v8_custom_libcxx_native_windows": [
"/D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"/D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"/D_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
],
":use_rusty_v8_custom_libcxx": [
"-nostdinc++",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
@@ -239,19 +272,19 @@ cc_library(
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"@rusty_v8_libcxx//:headers",
"@rusty_v8_libcxxabi//:headers",
],
deps = ["@rusty_v8_libcxx//:headers"] + select({
":use_rusty_v8_custom_libcxx_native_windows": [],
"//conditions:default": ["@rusty_v8_libcxxabi//:headers"],
}),
)
cc_library(
name = "rusty_v8_custom_libcxx_runtime",
visibility = ["//visibility:public"],
deps = [
"@rusty_v8_libcxx//:libcxx",
"@rusty_v8_libcxxabi//:libcxxabi",
],
deps = ["@rusty_v8_libcxx//:libcxx"] + select({
":use_rusty_v8_custom_libcxx_native_windows": [],
"//conditions:default": ["@rusty_v8_libcxxabi//:libcxxabi"],
}),
)
genrule(
@@ -313,6 +346,80 @@ cc_library(
}),
)
alias(
name = "native_windows_compiler_builtins",
actual = "@v8_native_windows_llvm//:builtins",
tags = ["manual"],
target_compatible_with = select({
":platform_windows_msvc": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
)
# Compile the pinned Chromium libc++ into V8 with the Microsoft CRT.
cc_static_library(
name = "v8_152_2_0_native_windows_objects",
features = V8_STATIC_LIBRARY_FEATURES,
tags = ["manual"],
target_compatible_with = select({
":platform_windows_msvc": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
":rusty_v8_custom_libcxx_runtime",
":v8_152_2_0_binding",
],
)
# cc_static_library only collects object files, not prebuilt libraries.
# The Rust build script receives one .lib without Bazel's CcInfo/linkdeps, so
# merge compiler-rt into the staged artifact explicitly.
genrule(
name = "v8_152_2_0_native_windows_library",
srcs = [
":v8_152_2_0_native_windows_objects",
"@v8_native_windows_llvm//:builtins_archive",
],
outs = ["rusty_v8_native_windows.lib"],
cmd_bat = '""$(location @v8_native_windows_llvm//:llvm-lib)" /NOLOGO /OUT:"$@" "$(location :v8_152_2_0_native_windows_objects)" "$(location @v8_native_windows_llvm//:builtins_archive)""',
tags = ["manual"],
target_compatible_with = [
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
tools = ["@v8_native_windows_llvm//:llvm-lib"],
)
[
v8_artifact_files(
name = "v8_152_2_0_%s_pc_windows_msvc_bazel" % arch,
srcs = [":v8_152_2_0_native_windows_library"],
profile = "sandbox_release",
tags = ["manual"],
target_compatible_with = [
"@platforms//cpu:%s" % arch,
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
v8_cpu = cpu,
)
for arch, cpu in [
("x86_64", "x64"),
("aarch64", "arm64"),
]
]
# Producer selectors never fall back to published inputs. Keep them separate
# from the consumer aliases so a version upgrade can build before publishing.
alias(
name = "rusty_v8_native_windows_archive_for_target",
actual = select({
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":v8_152_2_0_aarch64_pc_windows_msvc_bazel",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":v8_152_2_0_x86_64_pc_windows_msvc_bazel",
}),
tags = ["manual"],
)
cc_static_library(
name = "_v8_152_2_0_aarch64_apple_darwin_bazel",
features = V8_STATIC_LIBRARY_FEATURES,
+38 -5
View File
@@ -130,10 +130,43 @@ This depends on libc++'s shared exception-object ABI; updates to either libc++
revision must keep the native GNU link/runtime checks passing. The Bazel pair targets above still point directly to source
targets so a new release or canary never depends on an older published copy.
MSVC is not part of the Bazel-produced matrix yet. The repository's current
hermetic Windows C++ platform is `windows-gnullvm`/`x86_64-w64-windows-gnu`, so
it cannot truthfully reproduce upstream's `*-pc-windows-msvc` archives until we
add a real MSVC-targeting C++ toolchain to the Bazel graph.
Native Windows x64 and ARM64 hosts can build sandbox archives with pinned
clang-cl and the installed Microsoft SDK using
`//third_party/v8:v8_152_2_0_x86_64_pc_windows_msvc_bazel` and
`//third_party/v8:v8_152_2_0_aarch64_pc_windows_msvc_bazel`.
`//third_party/v8:rusty_v8_native_windows_archive_for_target` selects these source
outputs directly. These targets bundle Chromium libc++ and compiler builtins,
and fix pointer compression and sandboxing to the published Windows contract.
The owned engine policy also preserves the GN MSVC defaults for GC-managed
microtask queues, random Wasm module generation, disabled imminent-deprecation
warnings, and external TypedArray backing stores. Other source targets retain
the published Unix policy, including a 64-byte inline TypedArray threshold.
These are fixed platform choices, not additional developer build switches.
Matching generated Rust bindings, consumer selection, and publishing integration
are added separately; existing MSVC consumers continue using the prebuilt pair.
Use a native Visual Studio Developer PowerShell with the C++ tools and Windows
SDK available. The SDK supplies headers, libraries, `dumpbin.exe`, and the
assembler. From the repo root, build the archive for that host:
```powershell
bazel build --config=ci-windows-msvc `
--host_platform=//:local_windows_msvc --platforms=//:local_windows_msvc `
//third_party/v8:rusty_v8_native_windows_archive_for_target
```
Bazel fetches and verifies LLVM 22.1.8 for the host, the same major and patch
version as the libclang that generates bindings. The V8 artifact profile selects
clang-cl, lld-link, llvm-lib and compiler-rt only for its Windows MSVC source
archive and bindings, together with the installed SDK. Other C++ dependencies
in the same `ci-windows-msvc` build keep the installed MSVC compiler. Selecting
the explicit source target is the opt-in; no whole-build V8 compiler flag is
needed.
This is a native Windows build, not an x64-to-ARM64 or remote Linux build:
V8's snapshot generator must execute on the target architecture. The repository
inputs pinned in #4009 are MSVC/SDK files, not a registered clang-cl toolchain;
making them replace the installed SDK is the separate hermetic MSVC migration.
Release and CI Cargo builds for Darwin and Linux use `RUSTY_V8_ARCHIVE` plus a
downloaded `RUSTY_V8_SRC_BINDING_PATH` to point at those `openai/codex` release
@@ -146,7 +179,7 @@ the exact resolved `v8` crate version in `codex-rs/Cargo.lock`.
## Source dependency ownership
The Darwin, Linux GNU/musl and Windows GNU source targets consume Codex-owned
The Darwin, Linux GNU/musl and Windows source targets consume Codex-owned
Abseil, Highway, simdutf, ICU, fast_float, dragonbox and fp16 repositories.
`dependencies.bzl` declares the pinned imports; the `*.BUILD.bazel` overlays
here declare the targets V8 uses. Abseil, Highway and simdutf apply their C++ runtime
+23 -4
View File
@@ -9,24 +9,32 @@ _POINTER_COMPRESSION = "@v8//:v8_enable_pointer_compression"
_SANDBOX = "@v8//:v8_enable_sandbox"
_LIBCXX = "@v8//:v8_use_rusty_v8_custom_libcxx"
_TARGET_CPU = "@v8//bazel/config:v8_target_cpu"
_TOOLCHAINS = "//command_line_option:extra_toolchains"
_NATIVE_WINDOWS_TOOLCHAINS = [
str(Label("@v8_native_windows_cc//:cc-toolchain-x64_windows")),
str(Label("@v8_native_windows_cc//:cc-toolchain-arm64_windows")),
]
_CPU_CONSTRAINTS = {
"arm64": Label("@platforms//cpu:aarch64"),
"x64": Label("@platforms//cpu:x86_64"),
}
def _artifact_profile_impl(_settings, attr):
def _artifact_profile_impl(settings, attr):
sandbox = attr.profile != "release"
return {
_POINTER_COMPRESSION: "True" if sandbox else "False",
_SANDBOX: sandbox,
_LIBCXX: attr.profile != "source",
_TARGET_CPU: attr.v8_cpu,
# Select clang-cl only below the V8 archive/binding boundary. Keep the
# caller's toolchains (including the ordinary MSVC compiler) elsewhere.
_TOOLCHAINS: settings[_TOOLCHAINS] + (_NATIVE_WINDOWS_TOOLCHAINS if attr.native_windows else []),
}
_artifact_profile = transition(
implementation = _artifact_profile_impl,
inputs = [],
outputs = [_POINTER_COMPRESSION, _SANDBOX, _LIBCXX, _TARGET_CPU],
inputs = [_TOOLCHAINS],
outputs = [_POINTER_COMPRESSION, _SANDBOX, _LIBCXX, _TARGET_CPU, _TOOLCHAINS],
)
def _profiled_files_impl(ctx):
@@ -48,6 +56,7 @@ _v8_artifact_files = rule(
implementation = _profiled_files_impl,
doc = "Build a source archive or release pair under its named V8 profile.",
attrs = {
"native_windows": attr.bool(mandatory = True),
"profile": attr.string(
mandatory = True,
values = ["source", "release", "sandbox_release"],
@@ -73,4 +82,14 @@ def v8_artifact_files(name, v8_cpu, **kwargs):
"""
if type(v8_cpu) == "string":
kwargs.setdefault("target_compatible_with", [_CPU_CONSTRAINTS[v8_cpu]])
_v8_artifact_files(name = name, v8_cpu = v8_cpu, **kwargs)
_v8_artifact_files(
name = name,
# Derived from the target platform; callers cannot set this knob.
native_windows = select({
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": True,
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": True,
"//conditions:default": False,
}),
v8_cpu = v8_cpu,
**kwargs
)
+5
View File
@@ -5,6 +5,11 @@ profile is active. Shared libraries such as Abseil remain separate.
"""
RUSTY_V8_DEPENDENCY_COPTS = select({
"@@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [
"/D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"/D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"/D_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
],
"@@//third_party/v8:use_rusty_v8_custom_libcxx": [
"-nostdinc++",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
+60 -17
View File
@@ -2,14 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("@@//third_party/v8:engine_rules.bzl", "v8_fixed_source_features")
load("@@//third_party/v8:engine_rules.bzl", "v8_build_config", "v8_fixed_source_features")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load(
"@v8//:bazel/defs.bzl",
"v8_binary",
"v8_build_config",
"v8_config",
"v8_flag",
"v8_library",
@@ -25,7 +24,7 @@ exports_files(["bazel/requirements.txt"])
# Codex V8 source policy. Only ABI, runtime and target CPU vary, selected by
# artifact profiles. CPU selection lives in bazel/config.
# Upstream experiments, profiling and debug flags use their pinned 15.2 defaults.
# Platform feature choices preserve the published Bazel Unix and GN MSVC builds.
# ICU and no-ICU remain separate targets for the engine and its generators.
v8_flag(name = "v8_enable_sandbox")
@@ -115,13 +114,11 @@ v8_config(
conditional_defines = {"v8_enable_sandbox": "V8_ENABLE_SANDBOX"},
defines = [
"V8_DEPRECATION_WARNINGS",
"V8_IMMINENT_DEPRECATION_WARNINGS",
"V8_ENABLE_LAZY_SOURCE_POSITIONS",
"V8_ENABLE_TURBOFAN",
"V8_ENABLE_WEBASSEMBLY",
"V8_ENABLE_UNDEFINED_DOUBLE",
"V8_USE_HOST_CPU_ARM_FEATURES",
"V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64",
] + [
"GOOGLE3",
"V8_ADVANCED_BIGINT_ALGORITHMS",
@@ -131,6 +128,18 @@ v8_config(
"V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA",
"V8_TLS_USED_IN_LIBRARY",
] + select({
# The published MSVC artifacts used GN's CppGC queue and Wasm fuzzers.
# Keep these choices in the owned policy, including snapshot generators.
"@@//third_party/v8:platform_windows_msvc": [
"V8_CPPGC_MICROTASK_QUEUE",
"V8_WASM_RANDOM_FUZZERS",
"V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=0",
],
"//conditions:default": [
"V8_IMMINENT_DEPRECATION_WARNINGS",
"V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64",
],
}) + select({
"@v8//bazel/config:is_debug": [
"DEBUG",
"V8_ENABLE_CHECKS",
@@ -287,11 +296,20 @@ alias(
alias(
name = "is_v8_wasm_random_fuzzers",
actual = ":disabled_pinned_source_feature",
actual = "@@//third_party/v8:platform_windows_msvc",
)
# @CODEX_V8_UPSTREAM_FILEGROUPS@
filegroup(
name = "windows_x64_stack_assembly",
# The import preserves upstream MASM; only GNU builds use our GAS source.
srcs = select({
"@@//third_party/v8:platform_windows_msvc": ["src/heap/base/asm/x64/push_registers_masm.asm"],
"//conditions:default": ["@@//third_party/v8:push_registers_gnullvm.S"],
}),
)
alias(
name = "lib_dragonbox",
actual = "@v8_dragonbox//:dragonbox",
@@ -425,7 +443,9 @@ genrule(
"src/inspector/protocol/Schema.cpp",
"src/inspector/protocol/Schema.h",
],
cmd = "INSPECTOR_PROTOCOL_DIR=$$(dirname $(execpath third_party/inspector_protocol/code_generator.py)); \
cmd = select({
"@@//third_party/v8:platform_windows_msvc": "$(execpath :code_generator) --jinja_dir . --inspector_protocol_dir $$(dirname $(execpath third_party/inspector_protocol/code_generator.py)) --config $(location :src/inspector/inspector_protocol_config.json) --config_value protocol.path=$(location :include/js_protocol.pdl) --config_value crdtp.dir=third_party/inspector_protocol/crdtp --output_base $(@D)/src/inspector",
"//conditions:default": "INSPECTOR_PROTOCOL_DIR=$$(dirname $(execpath third_party/inspector_protocol/code_generator.py)); \
PYTHONPATH=$$INSPECTOR_PROTOCOL_DIR:external/rules_python++pip+v8_python_deps_311_jinja2/site-packages:external/rules_python++pip+v8_python_deps_311_markupsafe/site-packages:$${PYTHONPATH-} \
$(execpath @rules_python//python/bin:python) $(execpath third_party/inspector_protocol/code_generator.py) --jinja_dir . \
--inspector_protocol_dir $$INSPECTOR_PROTOCOL_DIR \
@@ -433,12 +453,16 @@ genrule(
--config_value protocol.path=$(location :include/js_protocol.pdl) \
--config_value crdtp.dir=third_party/inspector_protocol/crdtp \
--output_base $(@D)/src/inspector",
}),
message = "Generating inspector files",
tools = [
"@rules_python//python/bin:python",
requirement("jinja2"),
requirement("markupsafe"),
],
tools = select({
"@@//third_party/v8:platform_windows_msvc": [":code_generator"],
"//conditions:default": [
"@rules_python//python/bin:python",
requirement("jinja2"),
requirement("markupsafe"),
],
}),
)
filegroup(
@@ -753,20 +777,31 @@ v8_binary(
":mksnapshot_files",
] + [],
copts = ["-Wno-implicit-fallthrough"],
icu_deps = [":icu/v8_libshared"],
icu_srcs = [
":icu/generated_torque_initializers",
":icu/v8_initializers_files",
],
# Match GN's mksnapshot `disable_icf` config. If the linker folds distinct
# external-reference helpers together while producing the snapshot, the
# final embedder binary may not fold the same pair and startup
# deserialization will reject the snapshot.
# GN also increases the x64 Windows stack reserve because constructing the
# snapshot overflows the linker's 1 MiB default.
# The MSVC toolchain adds /OPT:ICF after user linkopts in opt mode.
# Disable that feature so the snapshot remains usable in debug embedders.
features = select({
"@@//third_party/v8:platform_windows_msvc": ["-smaller_binary"],
"//conditions:default": [],
}),
icu_deps = [":icu/v8_libshared"],
icu_srcs = [
":icu/generated_torque_initializers",
":icu/v8_initializers_files",
],
linkopts = select({
"@v8//bazel/config:is_android": ["-llog"],
"@v8//bazel/config:is_macos": ["-Wl,-no_deduplicate"],
"@@//third_party/v8:platform_windows_msvc": [
"/OPT:NOICF",
"/OPT:REF",
"/STACK:2097152",
],
"@v8//bazel/config:is_windows": [
"-Wl,/OPT:NOICF",
"-Wl,/STACK:2097152",
@@ -931,3 +966,11 @@ py_test(
"nosan",
],
)
# V8's existing converter builds snapshot assembly as C++ for clang-cl.
py_binary(
name = "native_windows_inline_asm",
srcs = ["tools/snapshot/asm_to_inline_asm.py"],
main = "tools/snapshot/asm_to_inline_asm.py",
tags = ["manual"],
)
+7
View File
@@ -58,6 +58,13 @@ def _engine_repository_impl(ctx):
stripPrefix = ctx.attr.strip_prefix,
)
inventory = _upstream_filegroups(ctx.read("BUILD.bazel"))
# MSVC and GNU Windows require different x64 stack scanners. Keep that one
# choice in our graph while taking all other membership from the V8 pin.
msvc_scanner = '"src/heap/base/asm/x64/push_registers_masm.asm"'
if inventory.count(msvc_scanner) != 1:
fail("V8 source import: expected one x64 MSVC scanner input; review the Windows stack selector")
inventory = inventory.replace(msvc_scanner, '":windows_x64_stack_assembly"')
template = ctx.read(ctx.attr._engine_build)
if template.count(_INVENTORY_SLOT) != 1:
fail("Codex V8 BUILD template must contain exactly one upstream filegroup slot")
+34 -2
View File
@@ -1,6 +1,7 @@
"""Codex's fixed selection for branches of the imported V8 source inventory."""
"""Owned V8 source selection and test metadata derived from the engine policy."""
load("@v8//:bazel/defs.bzl", "FlagInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load("@v8//:bazel/defs.bzl", "FlagInfo", "build_config_content")
def _options_impl(ctx):
return FlagInfo(value = ctx.build_setting_value)
@@ -11,3 +12,34 @@ v8_fixed_source_features = rule(
implementation = _options_impl,
build_setting = config.bool(flag = False),
)
def _v8_build_config_impl(ctx):
config = json.decode(build_config_content(json.encode(ctx.attr.arch), "true" if ctx.attr.icu else "false"))
defines = ctx.attr.config[CcInfo].compilation_context.defines.to_list()
config.update({
"cppgc_microtask_queue": "V8_CPPGC_MICROTASK_QUEUE" in defines,
"wasm_random_fuzzers": "V8_WASM_RANDOM_FUZZERS" in defines,
})
ctx.actions.write(ctx.outputs.out, json.encode(config) + "\n")
return [DefaultInfo(files = depset([ctx.outputs.out]))]
_v8_build_config = rule(
implementation = _v8_build_config_impl,
attrs = {
"arch": attr.string(mandatory = True),
"config": attr.label(mandatory = True, providers = [CcInfo]),
"icu": attr.bool(mandatory = True),
"out": attr.output(mandatory = True),
},
)
def v8_build_config(name, arch):
"""Keep upstream test metadata aligned with the owned platform features."""
for mode in ["icu", "noicu"]:
_v8_build_config(
name = mode + "/" + name,
arch = arch,
config = ":define_flags",
icu = mode == "icu",
out = mode + "/" + name + ".json",
)
+14 -1
View File
@@ -31,10 +31,23 @@ config_setting(
)
config_setting(
name = "compiler_clangcl",
name = "compiler_lexan",
flag_values = {"@bazel_tools//tools/cpp:compiler": "lexan"},
)
config_setting(
name = "compiler_clang_cl",
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang-cl"},
)
selects.config_setting_group(
name = "compiler_clangcl",
match_any = [
":compiler_clang_cl",
":compiler_lexan",
],
)
config_setting(
name = "compiler_msvc",
flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc-cl"},
+20 -2
View File
@@ -6,6 +6,11 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
# ICU must use the same C++ runtime as the V8 artifact and its host generators.
_ICU_V8_COPTS = select({
"@@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [
"/D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"/D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"/D_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
],
"@@//third_party/v8:use_rusty_v8_custom_libcxx": [
"-nostdinc++",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
@@ -16,6 +21,18 @@ _ICU_V8_COPTS = select({
"//conditions:default": [],
})
_ICU_MSVC_COPTS = [
"/wd4005",
"/wd4068",
"/wd4267",
"/utf-8",
]
_ICU_LIBRARY_COPTS = select({
"@@//third_party/v8:platform_windows_msvc": _ICU_MSVC_COPTS,
"//conditions:default": ["-Wno-deprecated-declarations"],
}) + _ICU_V8_COPTS
_ICU_V8_RUNTIME_DEPS = select({
"@@//third_party/v8:use_rusty_v8_custom_libcxx": [
"@@//third_party/v8:rusty_v8_custom_libcxx_headers",
@@ -36,7 +53,7 @@ cc_library(
"source/common/**/*.h",
"source/common/**/*.cpp",
]),
copts = ["-Wno-deprecated-declarations"] + _ICU_V8_COPTS,
copts = _ICU_LIBRARY_COPTS,
data = [":icudata"],
defines = [
"HAVE_DLOPEN=0",
@@ -76,7 +93,7 @@ cc_library(
"source/i18n/**/*.h",
"source/i18n/**/*.cpp",
]),
copts = ["-Wno-deprecated-declarations"] + _ICU_V8_COPTS,
copts = _ICU_LIBRARY_COPTS,
local_defines = [
"U_I18N_IMPLEMENTATION",
],
@@ -95,6 +112,7 @@ cc_library(
"source/i18n/unicode/*.h",
]),
copts = select({
"@@//third_party/v8:platform_windows_msvc": _ICU_MSVC_COPTS,
"@platforms//os:windows": [
"-Wno-deprecated-declarations",
],
+53 -17
View File
@@ -1,4 +1,4 @@
load("@llvm//toolchain/runtimes:cc_runtime_library.bzl", "cc_runtime_stage0_library")
load("@//third_party/v8:libcxx_rules.bzl", "libcxx_library")
load("@rules_cc//cc:defs.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
@@ -79,9 +79,12 @@ cc_library(
includes = ["src"],
)
cc_runtime_stage0_library(
libcxx_library(
name = "libcxx",
srcs = LIBCXX_SRCS + select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [
"src/filesystem/filesystem_clock.cpp",
],
":is_linux": [
"src/filesystem/directory_entry.cpp",
"src/filesystem/filesystem_clock.cpp",
@@ -95,32 +98,54 @@ cc_runtime_stage0_library(
],
"//conditions:default": [],
}),
copts = [
"-fexceptions",
"-frtti",
"-fstrict-aliasing",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-nostdinc++",
"-std=c++23",
"-Wno-nullability-completeness",
"-Wno-unused-parameter",
"-Wundef",
] + select({
copts = select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [
"/EHsc",
"/GR",
"/std:c++latest",
"/Zc:__cplusplus",
"/clang:-fstrict-aliasing",
"/clang:-Wno-nullability-completeness",
"/clang:-Wno-unused-parameter",
"/clang:-Wundef",
# libc++ uses the Microsoft exception implementation with /MT.
"/clang:-Xclang",
"/clang:--dependent-lib=libcpmt",
"/wd4005",
],
"//conditions:default": [
"-fexceptions",
"-frtti",
"-fstrict-aliasing",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
"-nostdinc++",
"-std=c++23",
"-Wno-nullability-completeness",
"-Wno-unused-parameter",
"-Wundef",
],
}) + select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [],
":is_windows": ["-Wno-macro-redefined"],
"//conditions:default": ["-fPIC"],
}),
defines = [
"CR_LIBCXX_REVISION=b16984ce99c702355a5b2b4c52574e82cec41fb9",
"LIBCXX_BUILDING_LIBCXXABI",
"LIBC_NAMESPACE=__llvm_libc_cr",
"_LIBCPP_BUILDING_LIBRARY",
"_LIBCPP_CONSTINIT=constinit",
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
"_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
"_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
] + select({
# The Windows build uses the Microsoft ABI, never Itanium libc++abi.
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [],
"//conditions:default": [
"LIBCXX_BUILDING_LIBCXXABI",
"_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
],
}) + select({
"@llvm//platforms/config:musl": [
# Chromium's checked-in __config_site uses this switch to enable
# libc++'s musl-specific configuration.
@@ -128,6 +153,7 @@ cc_runtime_stage0_library(
],
"//conditions:default": [],
}) + select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [],
":is_windows": [
"NTDDI_VERSION=NTDDI_WIN7",
"WINVER=_WIN32_WINNT_WIN7",
@@ -138,9 +164,11 @@ cc_runtime_stage0_library(
implementation_deps = [
":headers",
":internal_headers",
"@rusty_v8_libcxxabi//:headers",
"@rusty_v8_llvm_libc//:headers",
] + select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [],
"//conditions:default": ["@rusty_v8_libcxxabi//:headers"],
}) + select({
":is_linux": [
"@@llvm++kernel_headers+kernel_headers//:kernel_headers",
],
@@ -155,4 +183,12 @@ cc_runtime_stage0_library(
"//conditions:default": [],
}),
includes = ["src"],
local_defines = select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [
"NTDDI_VERSION=NTDDI_WIN7",
"WINVER=_WIN32_WINNT_WIN7",
"_WIN32_WINNT=_WIN32_WINNT_WIN7",
],
"//conditions:default": [],
}),
)
+26
View File
@@ -0,0 +1,26 @@
"""Select the installed SDK-capable toolchain for native Windows libc++."""
load("@llvm//toolchain/runtimes:cc_runtime_library.bzl", "cc_runtime_stage0_library")
load("@rules_cc//cc:defs.bzl", "cc_library")
def libcxx_library(name, **kwargs):
cc_runtime_stage0_library(
name = name + "_stage0",
**kwargs
)
cc_library(
name = name + "_native_windows",
linkstatic = True,
target_compatible_with = select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
**kwargs
)
native.alias(
name = name,
actual = select({
"@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": ":" + name + "_native_windows",
"//conditions:default": ":" + name + "_stage0",
}),
)
+84
View File
@@ -0,0 +1,84 @@
"""Inputs for the native Windows V8 build, using rules_cc's installed SDK."""
load("@llvm//toolchain:selects.bzl", "LLVM_VERSION")
load("@rules_cc//cc/private/toolchain:cc_configure.bzl", "MSVC_ENVVARS")
load("@rules_cc//cc/private/toolchain:windows_cc_configure.bzl", "configure_windows_toolchain")
# Match @llvm 0.8.11's bindgen compiler. Unlike its minimal bootstrap seed,
# these official distributions also contain the MSVC compiler-rt builtins.
_LLVM_WINDOWS = {
"x86_64": "d96c2cc1736f4eb7fa43cb9bbdf56d93551a9ae0a9aadb9c99c3c3b2b712a234",
"aarch64": "de718c58ebbc5f61d58c17b90457fcf42983bc2c4a4aba3e010d108713bfd7f1",
}
def _native_windows_llvm_impl(repository_ctx):
if repository_ctx.os.name.lower().find("windows") != -1:
arch = repository_ctx.os.arch.lower()
arch = {"amd64": "x86_64", "arm64": "aarch64"}.get(arch, arch)
if arch not in _LLVM_WINDOWS:
fail("V8's native Windows build supports x64 and arm64, got " + arch)
filename = "clang+llvm-%s-%s-pc-windows-msvc" % (LLVM_VERSION, arch)
repository_ctx.download_and_extract(
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-%s/%s.tar.xz" % (LLVM_VERSION, filename.replace("+", "%2B")),
sha256 = _LLVM_WINDOWS[arch],
stripPrefix = filename,
)
# Native-only inputs are empty on other hosts, without fetching Windows
# archives on Linux/macOS during //... queries or public lockfile checks.
repository_ctx.file("BUILD.bazel", """
load("@rules_cc//cc:defs.bzl", "cc_import")
package(default_visibility = ["//visibility:public"])
exports_files(["BUILD.bazel"])
filegroup(name = "llvm-readobj", srcs = glob(["bin/llvm-readobj.exe"], allow_empty = True))
filegroup(name = "llvm-lib", srcs = glob(["bin/llvm-lib.exe"], allow_empty = True))
[
filegroup(
name = "builtins_" + arch,
srcs = glob(["lib/clang/*/lib/windows/clang_rt.builtins-%s.lib" % arch], allow_empty = True),
)
for arch in ["x86_64", "aarch64"]
]
filegroup(
name = "builtins_archive",
srcs = select({
"@platforms//cpu:x86_64": [":builtins_x86_64"],
"@platforms//cpu:aarch64": [":builtins_aarch64"],
}),
)
cc_import(
name = "builtins",
static_library = ":builtins_archive",
)
""")
native_windows_llvm = repository_rule(
implementation = _native_windows_llvm_impl,
)
def _native_windows_cc_impl(repository_ctx):
if repository_ctx.os.name.lower().find("windows") != -1:
configure_windows_toolchain(repository_ctx)
else:
repository_ctx.file("BUILD.bazel", "# Native Windows toolchains are only available on Windows.\n")
native_windows_cc = repository_rule(
implementation = _native_windows_cc_impl,
attrs = {
# A Bazel repo label rather than a user's ambient installation path.
# The rules_cc pin patch reads this only for this opt-in repository.
"native_llvm": attr.label(allow_single_file = True, mandatory = True),
},
environ = MSVC_ENVVARS + [
"BAZEL_CONLYOPTS",
"BAZEL_COPTS",
"BAZEL_CXXOPTS",
"BAZEL_LINKOPTS",
"BAZEL_SH",
"BAZEL_WIN32_WINNT",
"SYSTEMROOT",
"PROGRAMFILES",
],
configure = True,
local = True,
)
+7
View File
@@ -0,0 +1,7 @@
// __powidf2 is in compiler-rt's generic builtins on both x64 and arm64.
// MSVC must resolve it from the staged V8 archive without any LLVM search path.
extern double __powidf2(double, int);
int main(void) {
return __powidf2(3.0, 4) == 81.0 ? 0 : 1;
}
+47
View File
@@ -0,0 +1,47 @@
.text
.globl PushAllRegistersAndIterateStack
.seh_proc PushAllRegistersAndIterateStack
PushAllRegistersAndIterateStack:
push %rbp
.seh_pushreg %rbp
mov %rsp, %rbp
.seh_setframe %rbp, 0
push $0xCDCDCD
.seh_stackalloc 8
push %rsi
.seh_pushreg %rsi
push %rdi
.seh_pushreg %rdi
push %rbx
.seh_pushreg %rbx
push %r12
.seh_pushreg %r12
push %r13
.seh_pushreg %r13
push %r14
.seh_pushreg %r14
push %r15
.seh_pushreg %r15
sub $160, %rsp
.seh_stackalloc 160
# Preserve Windows unwind metadata even though this is now GNU syntax.
# Without the .seh_* directives, SEH and stack walking can mis-handle
# unwinding across this callback frame.
.seh_endprologue
movdqa %xmm6, 144(%rsp)
movdqa %xmm7, 128(%rsp)
movdqa %xmm8, 112(%rsp)
movdqa %xmm9, 96(%rsp)
movdqa %xmm10, 80(%rsp)
movdqa %xmm11, 64(%rsp)
movdqa %xmm12, 48(%rsp)
movdqa %xmm13, 32(%rsp)
movdqa %xmm14, 16(%rsp)
movdqa %xmm15, 0(%rsp)
mov %r8, %r9
mov %rsp, %r8
call *%r9
add $224, %rsp
pop %rbp
ret
.seh_endproc
+8 -1
View File
@@ -8,7 +8,14 @@ cc_library(
name = "simdutf",
srcs = ["src/simdutf.cpp"],
hdrs = glob(["include/**/*.h"]),
copts = ["-std=c++20"] + RUSTY_V8_DEPENDENCY_COPTS,
# Match V8's C++20 feature macros, including atomic_ref for the base64 API.
copts = select({
"@@//third_party/v8:platform_windows_msvc": [
"/std:c++20",
"/Zc:__cplusplus",
],
"//conditions:default": ["-std=c++20"],
}) + RUSTY_V8_DEPENDENCY_COPTS,
features = ["-module_maps"],
include_prefix = "third_party/simdutf",
includes = [
+62 -19
View File
@@ -10,8 +10,7 @@
diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bzl
--- a/orig/v8-15.2.124.1/bazel/defs.bzl
+++ b/mod/v8-15.2.124.1/bazel/defs.bzl
@@ -18,16 +18,16 @@
return FlagInfo(value = ctx.build_setting_value)
@@ -19,7 +19,7 @@
_create_option_flag = rule(
implementation = _options_impl,
@@ -20,7 +19,7 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
attrs = {
"scope": attr.string(),
},
)
@@ -27,7 +27,7 @@
_create_option_string = rule(
implementation = _options_impl,
@@ -66,7 +65,7 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
def v8_int(name, default = 0):
_create_option_int(name = name, build_setting_default = default, scope = "universal")
@@ -106,7 +124,13 @@
@@ -106,7 +124,18 @@
def _default_args():
return struct(
@@ -77,11 +76,16 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
+ "@@//third_party/v8:rusty_v8_custom_libcxx_runtime",
+ ],
+ "//conditions:default": [],
+ }) + select({
+ "@@//third_party/v8:platform_windows_msvc": [
+ "@@//third_party/v8:native_windows_compiler_builtins",
+ ],
+ "//conditions:default": [],
+ }),
defines = select({
"@v8//bazel/config:is_windows": [
"UNICODE",
@@ -136,12 +160,15 @@
@@ -136,11 +165,27 @@
],
"//conditions:default": [],
}) + select({
@@ -90,7 +94,11 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
- "-Wno-deprecated-this-capture",
- "-Wno-deprecated-declarations",
- "-std=c++20",
- ],
+ "@@//third_party/v8:use_rusty_v8_custom_libcxx_native_windows": [
+ "/D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
+ "/D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
+ "/D_LIBCPP_INSTRUMENTED_WITH_ASAN=0",
+ ],
+ "@v8//:is_v8_use_rusty_v8_custom_libcxx": [
+ "-nostdinc++",
+ "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
@@ -100,10 +108,17 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
+ ],
+ "//conditions:default": [],
+ }) + select({
+ "@@//third_party/v8:platform_windows_msvc": [
+ "/std:c++20",
+ "/Zc:__cplusplus",
+ "/clang:-fconstexpr-steps=2000000",
+ "/clang:-Wno-deprecated-declarations",
+ "/clang:-Wno-deprecated-this-capture",
+ "/clang:-Wno-invalid-offsetof",
],
"@v8//bazel/config:is_gcc": [
"-Wno-extra",
"-Wno-array-bounds",
@@ -161,9 +188,17 @@
@@ -161,9 +206,17 @@
"-std=gnu++2a",
],
"@v8//bazel/config:is_windows": [
@@ -124,17 +139,21 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
}) + select({
"@v8//bazel/config:is_gcc_fastbuild": [
# Non-debug builds without optimizations fail because
@@ -187,15 +222,12 @@
@@ -186,16 +239,18 @@
}),
includes = ["include"],
linkopts = select({
"@v8//bazel/config:is_windows": [
- "Winmm.lib",
- "DbgHelp.lib",
- "Advapi32.lib",
- "@v8//bazel/config:is_windows": [
+ "@@//third_party/v8:platform_windows_msvc": [
"Winmm.lib",
"DbgHelp.lib",
"Advapi32.lib",
],
+ "@v8//bazel/config:is_windows": [
+ "-lwinmm",
+ "-ldbghelp",
+ "-ladvapi32",
],
+ ],
"@v8//bazel/config:is_macos": ["-pthread"],
- "//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"],
- }) + select({
@@ -144,7 +163,7 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
}),
)
@@ -466,6 +498,12 @@
@@ -466,6 +521,12 @@
def _mksnapshot(ctx):
prefix = ctx.attr.prefix
suffix = ctx.attr.suffix
@@ -157,7 +176,7 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
outs = [
ctx.actions.declare_file(prefix + "/snapshot" + suffix + ".cc"),
ctx.actions.declare_file(prefix + "/embedded" + suffix + ".S"),
@@ -483,7 +521,7 @@
@@ -483,9 +544,22 @@
"--embedded_src",
outs[1].path,
] + ctx.attr.args,
@@ -165,8 +184,23 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
+ executable = tool,
progress_message = "Running mksnapshot",
)
+ if ctx.attr.inline_asm_converter:
+ # The installed Windows toolchain sends .S files to MASM. V8 provides
+ # this conversion for clang-cl so its generated assembly is compiled
+ # as C++, using the same target flags as the rest of the engine.
+ embedded_cc = ctx.actions.declare_file(prefix + "/embedded" + suffix + ".cc")
+ ctx.actions.run(
+ executable = ctx.attr.inline_asm_converter[DefaultInfo].files_to_run,
+ inputs = [outs[1]],
+ outputs = [embedded_cc],
+ arguments = [outs[1].path, embedded_cc.path],
+ mnemonic = "V8NativeWindowsInlineAssembly",
+ )
+ outs = [outs[0], embedded_cc]
return [DefaultInfo(files = depset(outs))]
@@ -498,6 +536,12 @@
_v8_mksnapshot = rule(
@@ -498,6 +572,13 @@
executable = True,
cfg = "exec",
),
@@ -176,22 +210,31 @@ diff --git a/orig/v8-15.2.124.1/bazel/defs.bzl b/mod/v8-15.2.124.1/bazel/defs.bz
+ executable = True,
+ cfg = "target",
+ ),
+ "inline_asm_converter": attr.label(executable = True, cfg = "exec"),
"target_os": attr.string(mandatory = True),
"prefix": attr.string(mandatory = True),
"suffix": attr.string(mandatory = True),
@@ -511,6 +555,7 @@
@@ -511,6 +592,11 @@
args = args,
prefix = "noicu",
tool = ":noicu/mksnapshot" + suffix,
+ target_tool = ":noicu/mksnapshot" + suffix,
+ inline_asm_converter = select({
+ "@@//third_party/v8:platform_windows_msvc": ":native_windows_inline_asm",
+ "//conditions:default": None,
+ }),
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
@@ -523,6 +568,7 @@
@@ -523,6 +609,11 @@
args = args,
prefix = "icu",
tool = ":icu/mksnapshot" + suffix,
+ target_tool = ":icu/mksnapshot" + suffix,
+ inline_asm_converter = select({
+ "@@//third_party/v8:platform_windows_msvc": ":native_windows_inline_asm",
+ "//conditions:default": None,
+ }),
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",