Use hermetic LLVM for Windows MSVC Bazel builds (#60507)

## Why

Windows MSVC builds relied on installed C++ toolchains, and V8 snapshot generation required native Windows execution. Cross-compiling V8 also needs a Windows snapshot generator to preserve Windows unwind metadata.

## What changed

- Use the registered hermetic LLVM toolchain and declared Microsoft SDK for Windows MSVC builds, with static CRT linkage and the toolchain's declared `lld-link` for Rust.
- Run Windows V8 snapshot generators natively or through `rules_wine` on Linux, preserving target CPU, OS, and sandbox settings. Keep separate archive and binding pairs for the workspace's ISO stdio ABI and the distributed MSVC stdio ABI.
- Update build dependencies and bindgen, scope V8's Chromium libc++ settings to its own targets, and adapt native voice dependencies for clang-cl and Windows ARM64.
- Build SQLite directly with Bazel and give `openssl-sys` an explicit build using Bazel's OpenSSL.
- Remove build-worker source-directory dependencies from Bazel resource lookup, schema output discovery, and snapshot paths; embed assets in debug builds as well.

GitOrigin-RevId: fd224d9d28d73a67baf90f6d73c6079d60f20351
This commit is contained in:
zbarsky-openai
2026-11-10 03:02:25 +00:00
committed by copyberry
parent 3cd64c8d7c
commit 1099fe0694
60 changed files with 1224 additions and 801 deletions
+5 -6
View File
@@ -18,8 +18,8 @@ common --experimental_platform_in_output_dir
# Match Cargo's MSVC static CRT policy and V8's allocator linkage. Only the
# MSVC C/C++ toolchain consumes this feature; other toolchains ignore it.
# Include host dependencies so native build tools use the same runtime.
build --features=static_link_msvcrt
build --host_features=static_link_msvcrt
build --features=-dynamic_link_msvcrt --features=static_link_msvcrt
build --host_features=-dynamic_link_msvcrt --host_features=static_link_msvcrt
build --workspace_status_command=./scripts/workspace-status.sh
build:windows --workspace_status_command=./scripts/workspace-status.cmd
@@ -222,12 +222,11 @@ common:ci-v8 --config=ci
common:ci-v8 --build_metadata=TAG_workflow=v8
common:ci-v8 --build_metadata=TAG_os=linux
# Native Windows MSVC builds inherit the runner's MSVC SDK environment.
# Native Windows MSVC builds use the registered LLVM toolchain and its SDK.
# Voice's separately declared native build tools still need the runner environment.
# Client environment capture and repository discovery happen before target
# transitions, so these runner settings cannot live in runtime_package.bzl.
# Hermetic LLVM targets the GNU ABI on Windows even on an MSVC platform.
build:ci-windows-msvc --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
build:ci-windows-msvc --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows,@local_config_cc//:cc-toolchain-arm64_windows
build:ci-windows-msvc --repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1
build:ci-windows-msvc --action_env=PATH
build:ci-windows-msvc --host_action_env=PATH
build:ci-windows-msvc --action_env=INCLUDE
+1 -2
View File
@@ -260,8 +260,7 @@ jobs:
-- \
test --config=release \
--platforms=//:local_windows_msvc \
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows,@local_config_cc//:cc-toolchain-arm64_windows,//third_party/voice:windows_pkg_config_toolchain,//third_party/voice:windows_cmake_toolchain \
--repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0 \
--extra_toolchains=//third_party/voice:windows_pkg_config_toolchain,//third_party/voice:windows_cmake_toolchain \
--repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1 \
--inject_repository="voice_windows_tools=$VOICE_WINDOWS_BAZEL_REPOSITORY" \
--//third_party/voice:windows_installed_tools=@voice_windows_tools//:tools \
+105 -90
View File
@@ -4,21 +4,34 @@ bazel_dep(name = "bazel_lib", version = "3.2.2")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
# Expose rules_rs's existing dependency for the openssl-sys replacement's SBOM.
bazel_dep(name = "package_metadata", version = "0.0.7")
# Expose the public protobuf rules already used transitively by rules_rs.
bazel_dep(name = "protobuf", version = "34.0.bcr.1", repo_name = "com_google_protobuf")
# Backport protobuf#31266 (849e1cbf91af): MSVC also needs the ARM64 SEH workaround.
single_version_override(
module_name = "protobuf",
patch_strip = 1,
patches = ["//patches:protobuf_windows_arm64_seh.patch"],
)
bazel_dep(name = "llvm", version = "0.8.11")
bazel_dep(name = "windows_support", version = "0.2.0")
bazel_dep(name = "with_cfg.bzl", version = "0.12.0")
# Patch hermetic LLVM for Codex's custom libc++ and Windows gnullvm runtime
# needs that have not landed upstream.
single_version_override(
# Merged target-scoped C++ standard-library opt-outs for V8's private libc++.
# https://github.com/hermeticbuild/hermetic-llvm/pull/903
# Includes explicit MSVC CRT startup-library selection for dependency-provided main.
# https://github.com/hermeticbuild/hermetic-llvm/pull/914
archive_override(
module_name = "llvm",
integrity = "sha256-KTjljFEA8dmXkOoVz6Wv3yqkMfqrbS5iDv/ef4GYsu0=",
patch_strip = 1,
patches = [
"//patches:llvm_rusty_v8_custom_libcxx.patch",
"//patches:llvm_windows_arm64_powl.patch",
"//patches:llvm_windows_mingw_compat.patch",
],
patches = ["//patches:llvm_mingw_import_warnings.patch"],
strip_prefix = "hermetic-llvm-d27493f0386c9d4d28f7b12630cb91b0cdfd20f1",
urls = ["https://github.com/hermeticbuild/hermetic-llvm/archive/d27493f0386c9d4d28f7b12630cb91b0cdfd20f1.tar.gz"],
)
# Preserve case-only SDK aliases when native Windows repository setup feeds
@@ -145,23 +158,10 @@ use_repo(osx, "macos_sdk")
# Needed to disable xcode...
bazel_dep(name = "apple_support", version = "2.1.0")
bazel_dep(name = "rules_cc", version = "0.2.18")
# Windows voice jobs explicitly select the installed MSVC C toolchains.
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_cc", version = "0.2.25")
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")
bazel_dep(name = "aws-lc", version = "5.1.0.bcr.3")
bazel_dep(name = "rules_rs", version = "0.0.96")
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
single_version_override(
@@ -204,35 +204,31 @@ use_repo(pip, "schema_python")
register_toolchains("@rules_foreign_cc//toolchains:built_make_toolchain")
foreign_cc_tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
use_repo(foreign_cc_tools, "cmake-3.31.8-windows-x86_64", "pkgconfig_src")
use_repo(foreign_cc_tools, "cmake-3.31.8-windows-x86_64", "ninja_1.13.0_win", "pkgconfig_src")
single_version_override(
register_toolchains("//third_party/voice:windows_ninja_toolchain")
archive_override(
module_name = "rules_rs",
integrity = "sha256-b8sUj9EvM72+so/q4uRH91ed7QwOO8EoGbdL8NyBjE4=",
patch_strip = 1,
patches = [
"//patches:rules_rs_bindgen_v0_0_4.patch",
"//patches:rules_rs_build_script_deps_annotation.patch",
"//patches:rules_rs_rust_debug_modes.patch",
"//patches:rules_rs_windows_msvc_linker.patch",
"//patches:rules_rs_workspace_package_version.patch",
"//patches:rules_rs_zlib_snapshot_urls.patch",
],
version = "0.0.96",
strip_prefix = "rules_rs-7a05511772a8a85db5382ff7536bf2f1e6a8dde3",
urls = ["https://github.com/hermeticbuild/rules_rs/archive/7a05511772a8a85db5382ff7536bf2f1e6a8dde3.tar.gz"],
)
rules_rust = use_extension("@rules_rs//rs:rules_rust.bzl", "rules_rust")
rules_rust.patch(
patches = [
# Carry the OpenAI setup fix that makes build-script tools available
# through their runfiles after the rules_rs upgrade.
"//patches:rules_rust_build_script_tools_transition.patch",
# Opt-in release profile compatibility for native Cargo build scripts.
"//patches:rules_rust_release_build_script_profile.patch",
# Prefer Rust's direct linker for Windows/MSVC and keep hermetic
# LLVM's non-.lib runtime artifacts compatible with it.
"//patches:rules_rust_windows_msvc_direct_link_args.patch",
# Skip transient native-Windows linker outputs while consolidating
# dependency search paths.
"//patches:rules_rust_windows_process_wrapper_skip_temp_outputs.patch",
# Refreshed upstream PR #92; forwarding comes from merged #102.
"//patches:rules_rust_declared_msvc_linker.patch",
# Spill wrapper arguments to a params file to avoid Windows command-line limits.
"//patches:rules_rust_process_wrapper_param_file.patch",
"//patches:rules_rust_windows_execroot_separators.patch",
@@ -329,7 +325,7 @@ toolchains.toolchain(
)
use_repo(toolchains, "default_rust_toolchains")
register_toolchains("@default_rust_toolchains//:all")
register_toolchains("@default_rust_toolchains//...")
register_toolchains("@rust_toolchains//:all")
@@ -385,6 +381,11 @@ crate.from_cargo(
bazel_dep(name = "zstd", version = "1.5.7.bcr.2")
crate.annotation(
# Debug builds must also embed assets instead of reading the worker's source tree.
crate = "rust-embed",
crate_features = ["debug-embed"],
)
crate.annotation(
# Keep Windows proxy authentication aligned with codex-rs/.cargo/config.toml.
build_script_env = {"CFLAGS": "-DCURL_ENABLE_NTLM"},
@@ -394,13 +395,18 @@ crate.annotation(
# Daemon tests repeatedly hash large CLI binaries, even in fastbuild mode.
# Optimize the native backends as well as the Rust implementation.
build_script_env = {"OPT_LEVEL": "3"},
# The Windows lint toolchain cannot reliably materialize blake3's native x86 assembly archives.
crate = "blake3",
crate_features_select = {
"x86_64-pc-windows-gnullvm": ["pure"],
},
rustc_flags = ["-Copt-level=3"],
)
crate.annotation_select(
# Avoid native x86 assembly tools unavailable when cross-compiling Windows.
crate = "blake3",
crate_features = ["pure"],
triples = [
"x86_64-pc-windows-gnullvm",
"x86_64-pc-windows-msvc",
],
)
# Match the CodeModeHost response-compression benchmark's zstd level.
crate.annotation(
@@ -492,25 +498,6 @@ bazel_dep(name = "openssl", version = "3.5.4.bcr.0")
inject_repo(crate, "xz")
crate.annotation(
build_script_data = [
"@openssl//:gen_dir",
],
# Build scripts compile in Bazel's exec configuration, so target-specific
# optional build deps are otherwise dropped for the musl release platforms.
build_script_deps = [
"@crates//:openssl-src-300.6.1+3.6.3",
],
build_script_env = {
"OPENSSL_DIR": "$(execpath @openssl//:gen_dir)",
"OPENSSL_NO_VENDOR": "1",
"OPENSSL_STATIC": "1",
},
crate = "openssl-sys",
data = ["@openssl//:gen_dir"],
gen_build_script = "on",
)
inject_repo(crate, "openssl")
crate.annotation(
@@ -539,6 +526,22 @@ crate.annotation(
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Cargo keeps vendored OpenSSL for musl; Bazel already supplies its own OpenSSL.
# Replace this crate's generated build, not Cargo's feature resolution.
http_archive(
name = "openssl_sys_bazel",
build_file = "//third_party/openssl:openssl_sys.BUILD.bazel",
sha256 = "19c413d6ec9ebaf5e1c829d355cb3e9f783778d700f135be0921d52fce3c60ae",
strip_prefix = "openssl-sys-0.9.118",
type = "tar.gz",
urls = ["https://static.crates.io/crates/openssl-sys/openssl-sys-0.9.118.crate"],
)
override_repo(
crate,
**{"crates__openssl-sys-0.9.118": "openssl_sys_bazel"}
)
codex_release_archive = use_repo_rule("//bazel/extensions:codex_release_archive.bzl", "codex_release_archive")
codex_release_archive(
@@ -557,6 +560,14 @@ new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.
include("//bazel/modules:wine.MODULE.bazel")
# Run V8's Windows snapshot generator natively or with the executor's Wine.
bazel_dep(name = "rules_wine", version = "0.1.3")
wine = use_extension("@rules_wine//wine/extension:wine.bzl", "wine")
use_repo(wine, "wine_toolchains")
register_toolchains("@wine_toolchains//:all")
voice_sources = use_extension("//third_party/voice:extensions.bzl", "voice_sources")
use_repo(
voice_sources,
@@ -600,25 +611,29 @@ crate.annotation(
"RUSTY_V8_SRC_BINDING_PATH": "$(execpath @v8_targets//:rusty_v8_binding_for_target)",
},
crate = "v8",
# Keep the Rust feature aligned with the sandbox archive/binding pairs.
crate_features_select = {
"aarch64-apple-darwin": ["v8_enable_sandbox"],
"aarch64-pc-windows-gnullvm": ["v8_enable_sandbox"],
"aarch64-pc-windows-msvc": ["v8_enable_sandbox"],
"aarch64-unknown-linux-gnu": ["v8_enable_sandbox"],
"aarch64-unknown-linux-musl": ["v8_enable_sandbox"],
"x86_64-apple-darwin": ["v8_enable_sandbox"],
"x86_64-pc-windows-gnullvm": ["v8_enable_sandbox"],
"x86_64-pc-windows-msvc": ["v8_enable_sandbox"],
"x86_64-unknown-linux-gnu": ["v8_enable_sandbox"],
"x86_64-unknown-linux-musl": ["v8_enable_sandbox"],
},
gen_build_script = "on",
patch_args = ["-p1"],
patches = [
"//patches:rusty_v8_prebuilt_out_dir.patch",
],
)
crate.annotation_select(
# Keep the Rust feature aligned with the sandbox archive/binding pairs.
crate = "v8",
crate_features = ["v8_enable_sandbox"],
triples = [
"aarch64-apple-darwin",
"aarch64-pc-windows-gnullvm",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"x86_64-apple-darwin",
"x86_64-pc-windows-gnullvm",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
],
)
inject_repo(crate, "v8_targets")
@@ -626,11 +641,17 @@ llvm = use_extension("@llvm//extensions:llvm.bzl", "llvm")
use_repo(llvm, "llvm-project")
crate.annotation(
# Disable SQLite intrinsics that can crash at startup on older x64 Windows CPUs.
build_script_env_select = {
"x86_64-pc-windows-msvc": '{"LIBSQLITE3_FLAGS": "SQLITE_DISABLE_INTRINSIC"}',
},
additive_build_file = "//third_party/sqlite:libsqlite3_sys.BUILD.bazel",
crate = "libsqlite3-sys",
extra_aliased_targets = {
"libsqlite3_sys_bindings": "sqlite3/bindgen_bundled_version.rs",
"libsqlite3_sys_headers": "sqlite3_headers",
"libsqlite3_sys_source": "sqlite3/sqlite3.c",
},
gen_build_script = "off",
repositories = ["crates"],
version = "0.39.1",
deps = ["//third_party/sqlite:libsqlite3_sys_build_info"],
)
crate.annotation(
# Provide the hermetic SDK path so the build script doesn't try to invoke an unhermetic `xcrun --show-sdk-path`.
@@ -672,7 +693,11 @@ crate.annotation(
],
crate = "opusic-sys",
patch_args = ["-p1"],
patches = ["//patches:opusic_sys_install_headers.patch"],
patches = [
"//patches:opusic_sys_install_headers.patch",
# Presuming NEON must include its implementations without requiring RTCD.
"//patches:opusic-sys_presume_neon.patch",
],
)
# The musl CLI's allocator needs declared native tools and consistent header flags.
@@ -835,6 +860,7 @@ engine_repository(
"//patches:v8_source_portability.patch",
"//patches:v8_array_sort_elements_kind.patch",
"//third_party/v8:v8_defs.patch",
"//third_party/v8:v8_windows_snapshot_wine.patch",
],
strip_prefix = "v8-15.2.124.1",
urls = ["https://github.com/v8/v8/archive/refs/tags/15.2.124.1.tar.gz"],
@@ -853,17 +879,6 @@ 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,
+42 -39
View File
File diff suppressed because one or more lines are too long
+1 -6
View File
@@ -16,7 +16,6 @@ _PROFILE_INPUTS = [
"//command_line_option:host_action_env",
"//command_line_option:macos_minimum_os",
"//command_line_option:host_platform",
"//command_line_option:extra_toolchains",
_RUSTC_FLAGS,
_EXEC_RUSTC_FLAGS,
]
@@ -61,12 +60,8 @@ def _release_profile_impl(settings, attr):
# Compatibility with the Cargo musl release: aws-lc jitter can hang.
profile["//command_line_option:copt"] += ["-DDISABLE_CPU_JITTER_ENTROPY"]
elif attr.platform_os == "windows" and "@platforms//os:windows" in HOST_CONSTRAINTS:
# Native MSVC supplies the SDK and host tools for both architectures.
# Build tools run natively with the registered LLVM MSVC toolchain.
profile["//command_line_option:host_platform"] = "//:local_windows_msvc"
profile["//command_line_option:extra_toolchains"] += [
"@local_config_cc//:cc-toolchain-x64_windows",
"@local_config_cc//:cc-toolchain-arm64_windows",
]
if attr.linux_x86_64_musl:
# Match the Cargo release linker for x86-64 static PIEs.
profile[_RUSTC_FLAGS] += [
+1
View File
@@ -2315,6 +2315,7 @@ dependencies = [
"codex-core",
"codex-otel",
"codex-protocol",
"codex-utils-cargo-bin",
"codex-utils-cli",
"pretty_assertions",
"serde",
+2 -2
View File
@@ -594,8 +594,8 @@ zstd = "0.13"
wiremock = "0.6"
zeroize = "1.8.2"
[workspace.lints]
rust = {}
[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(codex_bazel)'] }
[workspace.lints.clippy]
await_holding_invalid_type = "deny"
@@ -3,4 +3,5 @@ load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "app-server-test-client",
crate_name = "codex_app_server_test_client",
lib_data_extra = ["scripts/live_elicitation_hold.sh"],
)
@@ -14,6 +14,7 @@ codex-app-server-protocol = { workspace = true }
codex-core = { workspace = true }
codex-otel = { workspace = true }
codex-protocol = { workspace = true }
codex-utils-cargo-bin = { workspace = true }
codex-utils-cli = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
+4 -5
View File
@@ -1272,11 +1272,10 @@ fn live_elicitation_timeout_pause(
(None, None) => "ws://127.0.0.1:4222".to_string(),
};
let script_path = script.unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("scripts")
.join("live_elicitation_hold.sh")
});
let script_path = match script {
Some(script) => script,
None => codex_utils_cargo_bin::find_resource!("scripts/live_elicitation_hold.sh")?,
};
if !script_path.is_file() {
bail!("helper script not found: {}", script_path.display());
}
+24 -3
View File
@@ -14,9 +14,30 @@ struct Args {
fn main() -> Result<()> {
let args = Args::parse();
let out_path = args.out.unwrap_or_else(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../core/config.schema.json")
});
let out_path = match args.out {
Some(path) => path,
None => default_out_path()?,
};
codex_config::schema::write_config_schema(&out_path)?;
Ok(())
}
fn default_out_path() -> Result<PathBuf> {
// Cargo supplies this when running the tool, including from outside the checkout.
if let Some(manifest_dir) = std::env::var_os("CARGO_MANIFEST_DIR") {
return Ok(PathBuf::from(manifest_dir).join("../core/config.schema.json"));
}
let cwd = std::env::current_dir()?;
for directory in cwd.ancestors() {
for workspace in [directory.to_path_buf(), directory.join("codex-rs")] {
if workspace.join("config-schema/Cargo.toml").is_file()
&& workspace.join("core/Cargo.toml").is_file()
{
return Ok(workspace.join("core/config.schema.json"));
}
}
}
anyhow::bail!("could not locate the Codex checkout; specify the schema output with --out")
}
@@ -1,9 +1,29 @@
use std::path::PathBuf;
fn main() -> anyhow::Result<()> {
let schema_root = std::env::args_os()
.nth(1)
.map(PathBuf::from)
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("schema"));
let schema_root = match std::env::args_os().nth(1) {
Some(path) => PathBuf::from(path),
None => default_schema_root()?,
};
codex_hooks::write_schema_fixtures(&schema_root)
}
fn default_schema_root() -> anyhow::Result<PathBuf> {
// Preserve Cargo's default without retaining its compile-time source path.
if let Some(manifest_dir) = std::env::var_os("CARGO_MANIFEST_DIR") {
return Ok(PathBuf::from(manifest_dir).join("schema"));
}
let cwd = std::env::current_dir()?;
for directory in cwd.ancestors() {
for workspace in [directory.to_path_buf(), directory.join("codex-rs")] {
if workspace.join("hooks/Cargo.toml").is_file()
&& workspace.join("core/Cargo.toml").is_file()
{
return Ok(workspace.join("hooks/schema"));
}
}
}
anyhow::bail!("could not locate the Codex checkout; specify the schema output directory")
}
+1
View File
@@ -13,5 +13,6 @@ codex_rust_crate(
rustc_env = {
"CODEX_REPO_ROOT_MARKER": "$(rlocationpath :repo_root.marker)",
},
rustc_flags_extra = ["--cfg=codex_bazel"],
test_data_extra = ["repo_root.marker"],
)
+8 -3
View File
@@ -12,9 +12,14 @@ Function behavior:
Bazel) and resolves them via the runfiles manifest when `RUNFILES_MANIFEST_FILE`
is present. When not under runfiles, it only accepts absolute paths from
`CARGO_BIN_EXE_*` and returns an error otherwise.
- `find_resource!`: used by tests to locate fixtures. It chooses the Bazel
runfiles resolution path when `RUNFILES_MANIFEST_FILE` is set, otherwise it
falls back to a `CARGO_MANIFEST_DIR`-relative path for Cargo runs.
- `find_resource!`: used by tests to locate fixtures relative to the calling
package. Bazel compiles this helper with `codex_bazel`, selecting runfiles
lookup without embedding the build worker's Cargo source directory. Missing
runfiles produce an error. Cargo builds retain the `CARGO_MANIFEST_DIR`-relative
fallback when runfiles are unavailable.
- `resolve_cargo_runfile`: retains source-directory lookup for Cargo builds;
Bazel builds return an unsupported-operation error. This also prevents
`repo_root` from falling back to a build worker's source directory.
Background:
+22
View File
@@ -125,6 +125,19 @@ fn resolve_bin_from_env(key: &str, value: OsString) -> Result<PathBuf, CargoBinE
///
/// This is expected to be used exclusively in test code because Codex CLI is a
/// standalone binary with no packaged resources.
#[cfg(codex_bazel)]
#[macro_export]
macro_rules! find_resource {
($resource:expr) => {{
// Capture the caller's package, not the package of this helper crate.
$crate::resolve_bazel_runfile(
option_env!("BAZEL_PACKAGE"),
std::path::Path::new(&$resource),
)
}};
}
#[cfg(not(codex_bazel))]
#[macro_export]
macro_rules! find_resource {
($resource:expr) => {{
@@ -170,11 +183,20 @@ pub fn resolve_bazel_runfile(
))
}
#[cfg(not(codex_bazel))]
pub fn resolve_cargo_runfile(resource: &Path) -> std::io::Result<PathBuf> {
let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Ok(manifest_dir.join(resource))
}
#[cfg(codex_bazel)]
pub fn resolve_cargo_runfile(_resource: &Path) -> std::io::Result<PathBuf> {
Err(io::Error::new(
io::ErrorKind::Unsupported,
"Cargo source-directory lookup is unavailable in Bazel builds; use runfiles",
))
}
pub fn repo_root() -> io::Result<PathBuf> {
let marker = if runfiles_available() {
let runfiles = runfiles::Runfiles::create()
@@ -77,10 +77,9 @@ fn sandbox_cwd() -> PathBuf {
return PathBuf::from(workspace_root);
}
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("repo root")
.to_path_buf()
codex_utils_cargo_bin::repo_root()
.expect("resolve repository root")
.join("codex-rs")
}
fn sandbox_home(name: &str) -> TempDir {
@@ -776,6 +775,10 @@ fn legacy_workspace_write_delete_is_limited_to_writable_roots() {
.expect("write delete script");
let env_map = HashMap::from([
(
"SystemRoot".to_string(),
std::env::var("SystemRoot").expect("Windows SystemRoot"),
),
("TEMP".to_string(), temp_root.to_string_lossy().into_owned()),
("TMP".to_string(), tmp_root.to_string_lossy().into_owned()),
(
+9 -5
View File
@@ -322,6 +322,10 @@ def codex_rust_crate(
"CARGO_PKG_NAME": package_data["package_name"],
} | rustc_env
# Insta also reads this during macro expansion. Match the test launcher's
# workspace-relative root instead of embedding CARGO_MANIFEST_DIR.
test_rustc_env = rustc_env | {"INSTA_WORKSPACE_ROOT": "."}
manifest_relpath = native.package_name()
if manifest_relpath.startswith("codex-rs/"):
manifest_relpath = manifest_relpath[len("codex-rs/"):]
@@ -389,7 +393,7 @@ def codex_rust_crate(
"--remap-path-prefix=../codex-rs=",
"--remap-path-prefix=codex-rs=",
],
rustc_env = rustc_env,
rustc_env = test_rustc_env,
data = test_data_extra + [binary for binary in extra_binaries if binary not in test_data_extra],
tags = test_tags + ["manual"],
version = crate_version,
@@ -475,7 +479,7 @@ def codex_rust_crate(
"--remap-path-prefix=../codex-rs=",
"--remap-path-prefix=codex-rs=",
],
rustc_env = rustc_env,
rustc_env = test_rustc_env,
data = test_data_extra,
tags = test_tags + ["manual"],
version = crate_version,
@@ -612,7 +616,7 @@ def codex_rust_crate(
"--remap-path-prefix=../codex-rs=",
"--remap-path-prefix=codex-rs=",
],
rustc_env = rustc_env,
rustc_env = test_rustc_env,
target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE,
tags = test_tags + ["manual"],
version = crate_version,
@@ -653,7 +657,7 @@ def codex_rust_crate(
"--remap-path-prefix=../codex-rs=",
"--remap-path-prefix=codex-rs=",
],
rustc_env = rustc_env,
rustc_env = test_rustc_env,
env = integration_test_cargo_env,
target_compatible_with = WINDOWS_GNULLVM_INCOMPATIBLE,
tags = test_tags,
@@ -726,7 +730,7 @@ def codex_rust_crate(
"--remap-path-prefix=../codex-rs=",
"--remap-path-prefix=codex-rs=",
],
rustc_env = rustc_env,
rustc_env = test_rustc_env,
env = integration_test_cargo_env,
target_compatible_with = WINDOWS_GNULLVM_ONLY,
tags = test_tags + ["manual"],
+5 -9
View File
@@ -1,27 +1,23 @@
exports_files([
"opusic_sys_install_headers.patch",
"rules_cc_windows_native_llvm.patch",
"protobuf_windows_arm64_seh.patch",
"opusic-sys_presume_neon.patch",
"llvm_mingw_import_warnings.patch",
"rules_rust_declared_msvc_linker.patch",
"rules_rs_bindgen_v0_0_4.patch",
"abseil_windows_gnullvm_thread_identity.patch",
"bzip2_windows_stack_args.patch",
"llvm_rusty_v8_custom_libcxx.patch",
"llvm_windows_arm64_powl.patch",
"llvm_windows_mingw_compat.patch",
"mxc-sdk_utf8_resources.patch",
"rules_rust_build_script_tools_transition.patch",
"rules_rust_compiler_thp.patch",
"rules_rust_process_wrapper_param_file.patch",
"rules_rust_release_build_script_profile.patch",
"rules_rust_windows_execroot_separators.patch",
"rules_rust_windows_msvc_direct_link_args.patch",
"rules_rust_windows_process_wrapper_skip_temp_outputs.patch",
"rules_foreign_cc_make_cppflags.patch",
"rules_foreign_cc_make_xcompile.patch",
"rules_foreign_cc_make_msvc_stdint.patch",
"rules_rs_build_script_deps_annotation.patch",
"rules_rs_rust_debug_modes.patch",
"rules_rs_windows_msvc_linker.patch",
"rules_rs_workspace_package_version.patch",
"rules_rs_zlib_snapshot_urls.patch",
"rusty_v8_prebuilt_out_dir.patch",
"ring_windows_msvc_include_dirs.patch",
"tikv-jemalloc-sys_make_env.patch",
+12
View File
@@ -0,0 +1,12 @@
diff --git a/runtimes/mingw/import_libs.bzl b/runtimes/mingw/import_libs.bzl
--- a/runtimes/mingw/import_libs.bzl
+++ b/runtimes/mingw/import_libs.bzl
@@ -30,6 +30,8 @@
# ucrtbase-common.def.in:1800:28: warning: missing terminating ' character [-Winvalid-pp-token]
# 1800 | F_LD64(_o_remainderl) ; Can't use long double functions from the CRT on x86
args.add("-Wno-invalid-pp-token")
+ # MinGW 14 func.def.in uses #ifndef F_X86_NATIVE(x).
+ args.add("-Wno-extra-tokens")
args.add("-o", ctx.outputs.out)
args.add(undecorated)
-108
View File
@@ -1,108 +0,0 @@
diff --git a/toolchain/BUILD.bazel b/toolchain/BUILD.bazel
index fa00156236..c9e4348172 100644
--- a/toolchain/BUILD.bazel
+++ b/toolchain/BUILD.bazel
@@ -1,5 +1,6 @@
load("@bazel_lib//:bzl_library.bzl", "bzl_library")
+load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag", "string_setting")
load("@rules_cc//cc/toolchains:actions.bzl", "cc_action_type_set")
load("@rules_cc//cc/toolchains:artifacts.bzl", "cc_artifact_name_pattern")
load("@rules_cc//cc/toolchains/impl:documented_api.bzl", "cc_args_list")
@@ -64,6 +65,15 @@ config_setting(
visibility = ["//visibility:public"],
)
-
+
+selects.config_setting_group(
+ name = "runtimes_all_with_rusty_v8_custom_libcxx",
+ match_all = [
+ ":runtimes_all",
+ "@@//third_party/v8:use_rusty_v8_custom_libcxx",
+ ],
+ visibility = ["//visibility:public"],
+)
+
config_setting(
name = "runtimes_stage1",
flag_values = {
@@ -270,11 +280,16 @@ cc_args_list(
# TODO(cerisier): extract those into proper semantic args list.
# TODO(zbarsky): This must match llvm/toolchains/llvm.bzl
+_DEFAULT_CXXSTDLIB_HEADER_ARGS = select({
+ "@@//third_party/v8:use_rusty_v8_custom_libcxx": [],
+ "//conditions:default": [
+ "//toolchain/args:cxxstdlib_headers_include_search_paths",
+ ],
+})
+
cc_args_list(
name = "linux_toolchain_args",
- args = [
- "//toolchain/args:cxxstdlib_headers_include_search_paths",
- ] + select({
+ args = _DEFAULT_CXXSTDLIB_HEADER_ARGS + select({
"//platforms/config:musl": [
"//toolchain/args/linux:kernel_headers_include_search_paths",
"//toolchain/args/linux:musl_libc_headers_include_search_paths",
@@ -302,8 +317,7 @@ cc_args_list(
# TODO(zbarsky): This must match llvm/toolchains/llvm.bzl
cc_args_list(
name = "windows_toolchain_args",
- args = [
- "//toolchain/args:cxxstdlib_headers_include_search_paths",
+ args = _DEFAULT_CXXSTDLIB_HEADER_ARGS + [
"//toolchain/args/windows:mingw_headers_include_search_paths",
],
)
diff --git a/toolchain/llvm/llvm.bzl b/toolchain/llvm/llvm.bzl
index d36d8b94bd..900aa908d5 100644
--- a/toolchain/llvm/llvm.bzl
+++ b/toolchain/llvm/llvm.bzl
@@ -297,18 +297,23 @@ def declare_llvm_targets(*, suffix = ""):
],
)
+ default_cxxstdlib_target_headers = select({
+ "@llvm//toolchain:runtimes_all_with_rusty_v8_custom_libcxx": [],
+ "@llvm//toolchain:runtimes_stage1": [],
+ "@llvm//toolchain:runtimes_stage1_hosted": [],
+ "@llvm//toolchain:runtimes_none": [],
+ "//conditions:default": [
+ "@llvm//runtimes/cxxstdlib:headers_include_search_directory",
+ "@llvm//runtimes/cxxstdlib:abi_headers_include_search_directory",
+ ],
+ })
+
# This must match //toolchain:linux_toolchain_args
include_path(
name = "linux_target_headers",
srcs = [
":builtin_resource_dir",
- ] + select({
- "@llvm//toolchain:runtimes_all": [
- "@llvm//runtimes/cxxstdlib:headers_include_search_directory",
- "@llvm//runtimes/cxxstdlib:abi_headers_include_search_directory",
- ],
- "//conditions:default": [],
- }) + [
+ ] + default_cxxstdlib_target_headers + [
"@kernel_headers//:kernel_headers_directory",
"@llvm//sanitizers:sanitizers_headers_include_search_directory",
] + select({
@@ -324,13 +329,7 @@ def declare_llvm_targets(*, suffix = ""):
name = "windows_target_headers",
srcs = [
":builtin_resource_dir",
- ] + select({
- "@llvm//toolchain:runtimes_all": [
- "@llvm//runtimes/cxxstdlib:headers_include_search_directory",
- "@llvm//runtimes/cxxstdlib:abi_headers_include_search_directory",
- ],
- "//conditions:default": [],
- }) + [
+ ] + default_cxxstdlib_target_headers + [
"@mingw//:mingw_generated_headers_crt_directory",
"@mingw//:mingw_w64_headers_include_directory",
"@mingw//:mingw_w64_headers_crt_directory",
-25
View File
@@ -1,25 +0,0 @@
# What: provide and link MinGW's ARM64 long-double `powl` compatibility shim.
# Why: Windows ARM64 uses 64-bit long doubles, but LLVM's Bazel source list
# omits the upstream `powl -> pow` implementation and its default link flags
# omit the MinGW extension archive that owns the shim.
diff --git a/runtimes/mingw/crt_sources.bzl b/runtimes/mingw/crt_sources.bzl
--- a/runtimes/mingw/crt_sources.bzl
+++ b/runtimes/mingw/crt_sources.bzl
@@ -420,4 +420,5 @@
MINGWEX_ARM64_SRCS = [
+ "math/arm-common/powl.c",
"math/sincos.c",
"math/sincosf.c",
"math/arm-common/sincosl.c",
diff --git a/toolchain/args/windows/BUILD.bazel b/toolchain/args/windows/BUILD.bazel
--- a/toolchain/args/windows/BUILD.bazel
+++ b/toolchain/args/windows/BUILD.bazel
@@ -45,5 +45,6 @@ cc_args(
args = [
"-L{mingw_import_library_search_path}",
"-L{mingw_crt_library_search_path}",
-
+ "-lmingwex",
+
# Clang will respect the user's chosen CRT variant.
-50
View File
@@ -1,50 +0,0 @@
# What: provide MinGW compatibility archives required by Windows gnullvm links.
# Why: clang and prebuilt MSVC archives can request these names even though the
# hermetic MinGW runtime does not publish them by default.
diff --git a/runtimes/mingw/BUILD.bazel b/runtimes/mingw/BUILD.bazel
--- a/runtimes/mingw/BUILD.bazel
+++ b/runtimes/mingw/BUILD.bazel
@@ -386,14 +386,42 @@ stub_library(
name = "stdc++",
)
+# Clang may inject -lssp and -lssp_nonshared for windows-gnu links.
+# Provide compatibility archives in the MinGW runtime search directory.
+stub_library(
+ name = "ssp",
+)
+
+stub_library(
+ name = "ssp_nonshared",
+)
+
+# Prebuilt MSVC archives can carry /DEFAULTLIB:libcmt.lib and
+# /DEFAULTLIB:oldnames.lib directives. Provide MinGW-compatible stand-ins so
+# lld can satisfy the lookup under windows-gnullvm.
+stub_library(
+ name = "libcmt",
+)
+
+copy_file(
+ name = "oldnames",
+ src = ":moldname",
+ out = "liboldnames.a",
+ visibility = ["//visibility:public"],
+)
+
copy_to_directory(
name = "mingw_crt_library_search_directory",
srcs = [
+ ":libcmt",
":m",
":mingw32",
":mingwex",
":moldname",
+ ":oldnames",
":pthread",
+ ":ssp",
+ ":ssp_nonshared",
":stdc++",
":uuid",
":winpthread",
+12
View File
@@ -0,0 +1,12 @@
diff --git a/opus/CMakeLists.txt b/opus/CMakeLists.txt
--- a/opus/CMakeLists.txt
+++ b/opus/CMakeLists.txt
@@ -598,6 +598,8 @@
if(OPUS_PRESUME_NEON)
target_compile_definitions(opus
PRIVATE
+ OPUS_ARM_MAY_HAVE_NEON
+ OPUS_ARM_MAY_HAVE_NEON_INTR
OPUS_ARM_PRESUME_NEON
OPUS_ARM_PRESUME_NEON_INTR)
endif()
+11
View File
@@ -0,0 +1,11 @@
--- a/upb/wire/encode.c
+++ b/upb/wire/encode.c
@@ -187,7 +187,7 @@
"br %[addr]\n"
// Work around llvm/llvm-project#47432, where alignment directives inside
// functions crash the compiler when generating SEH info on windows.
- #ifndef __SEH__
+ #if !defined(__SEH__) && !defined(_WIN32)
".p2align " UPB_BTI_SHIFT_IMM
#endif
"0:\n"
+13 -15
View File
@@ -30,22 +30,20 @@ diff --git a/build.rs b/build.rs
} else {
generate_sources_and_preassemble(
&out_dir,
@@ -561,7 +581,13 @@
let compiler = c.get_compiler();
// FIXME: On Windows AArch64 we currently must use Clang to compile C code
let compiler = if target.os == WINDOWS && target.arch == AARCH64 && !compiler.is_like_clang() {
@@ -561,14 +581,21 @@
- let compiler = c.get_compiler();
- // FIXME: On Windows AArch64 we currently must use Clang to compile C code
- let compiler = if target.os == WINDOWS && target.arch == AARCH64 && !compiler.is_like_clang() {
- let _ = c.compiler("clang");
+ // Keep inherited MSVC flags compatible with the selected Clang driver.
+ let clang = if compiler.is_like_msvc() {
+ "clang-cl"
+ } else {
+ "clang"
+ };
+ let _ = c.compiler(clang);
c.get_compiler()
} else {
compiler
@@ -569,6 +595,15 @@
- c.get_compiler()
- } else {
- compiler
+ // FIXME: On Windows AArch64 we currently must use Clang to compile C code.
+ // clang-cl emulates the cl.exe command line, `$CFLAGS`, etc.
+ if target.os == WINDOWS && target.arch == AARCH64 {
+ let _: &_ = c.prefer_clang_cl_over_msvc(true);
};
+ let compiler = c.get_compiler();
let _ = c.include(c_root_dir.join("include"));
let _ = c.include(include_dir);
-109
View File
@@ -1,109 +0,0 @@
# Reuse rules_cc's installed SDK setup with an explicitly declared LLVM repo.
# Only the V8 repository has native_llvm; ordinary local_config_cc keeps its
# installed compiler and input files. Track the fetched LLVM tools and resources
# as action inputs so changes to the pin invalidate cached compilation and links.
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")
@@ -923,6 +930,12 @@
)
template_vars = dict()
+ native_llvm = getattr(repository_ctx.attr, "native_llvm", None)
+ for group in ["compiler_files", "linker_files", "archiver_files", "all_files"]:
+ files = [str(native_llvm.same_package_label(group))] if native_llvm else []
+ if native_llvm and group == "all_files":
+ files.append(":msvc_compiler_files")
+ template_vars["%{native_llvm_" + group + "}"] = repr(files)
msvc_vars_x64 = _get_msvc_vars(repository_ctx, paths, "x64")
template_vars.update(msvc_vars_x64)
template_vars.update(_get_clang_cl_vars(repository_ctx, paths, msvc_vars_x64, "x64"))
diff --git a/cc/private/toolchain/BUILD.windows.tpl b/cc/private/toolchain/BUILD.windows.tpl
--- a/cc/private/toolchain/BUILD.windows.tpl
+++ b/cc/private/toolchain/BUILD.windows.tpl
@@ -67,7 +67,22 @@
"%{msvc_deps_scanner_wrapper_path_x64}",
"%{msvc_deps_scanner_wrapper_path_arm}",
"%{msvc_deps_scanner_wrapper_path_arm64}",
- ]
+ ] + %{native_llvm_compiler_files}
+)
+
+filegroup(
+ name = "msvc_all_files",
+ srcs = %{native_llvm_all_files},
+)
+
+filegroup(
+ name = "msvc_linker_files",
+ srcs = %{native_llvm_linker_files},
+)
+
+filegroup(
+ name = "msvc_archiver_files",
+ srcs = %{native_llvm_archiver_files},
)
# Hardcoded toolchain, legacy behaviour.
@@ -301,12 +316,12 @@
name = "cc-compiler-x64_windows",
toolchain_identifier = "msvc_x64",
toolchain_config = ":msvc_x64",
- all_files = ":empty",
- ar_files = ":empty",
+ all_files = ":msvc_all_files",
+ ar_files = ":msvc_archiver_files",
as_files = ":msvc_compiler_files",
compiler_files = ":msvc_compiler_files",
dwp_files = ":empty",
- linker_files = ":empty",
+ linker_files = ":msvc_linker_files",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 1,
@@ -526,12 +541,12 @@
name = "cc-compiler-arm64_windows",
toolchain_identifier = "msvc_arm64",
toolchain_config = ":msvc_arm64",
- all_files = ":empty",
- ar_files = ":empty",
+ all_files = ":msvc_all_files",
+ ar_files = ":msvc_archiver_files",
as_files = ":msvc_compiler_files",
compiler_files = ":msvc_compiler_files",
dwp_files = ":empty",
- linker_files = ":empty",
+ linker_files = ":msvc_linker_files",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 1,
+62
View File
@@ -0,0 +1,62 @@
# Adopt bindgen v0.0.4 with embedded LLVM 23.1.2 libclang.
# https://github.com/hermeticbuild/bindgen/releases/tag/v0.0.4
diff --git a/rs/rules_rust_bindgen.bzl b/rs/rules_rust_bindgen.bzl
--- a/rs/rules_rust_bindgen.bzl
+++ b/rs/rules_rust_bindgen.bzl
@@ -189,7 +189,7 @@
name = "rules_rust_bindgen_" + prebuilt.name,
build_file_content = 'exports_files(["%s"])\n' % bindgen_binary_name(prebuilt.os),
sha256 = prebuilt.sha256,
- url = "https://github.com/hermeticbuild/bindgen/releases/download/v0.0.2/bindgen_{}.tar.zst".format(prebuilt.name),
+ url = "https://github.com/hermeticbuild/bindgen/releases/download/v0.0.4/bindgen_{}.tar.zst".format(prebuilt.name),
)
toolchain_repositories = {"rules_rust_bindgen": True}
diff --git a/rs/toolchains/declare_bindgen_toolchains.bzl b/rs/toolchains/declare_bindgen_toolchains.bzl
--- a/rs/toolchains/declare_bindgen_toolchains.bzl
+++ b/rs/toolchains/declare_bindgen_toolchains.bzl
@@ -5,37 +5,37 @@
name = "darwin_amd64",
cpu = "x86_64",
os = "macos",
- sha256 = "9effe0323d0441d6f541497e0590b970beb15b9104c7e034ac4557942202f869",
+ sha256 = "c541cffb54e6a4f683578147780f3fefaaba7a133da97f7d1a1a52dcf1cbaa6d",
),
struct(
name = "darwin_arm64",
cpu = "aarch64",
os = "macos",
- sha256 = "456ab5235685c498455ddc2fafeba32eb1d93758346e585e8da5e09c19cc680c",
+ sha256 = "218d25da4d153dbc87daf64a029af3de17cee6a0f6291fdb0a5d9eff44243399",
),
struct(
name = "linux_amd64",
cpu = "x86_64",
os = "linux",
- sha256 = "ec2b39a56443142a34dc76ec32a17cb099c6c09137c3fbac893310c623cb10ac",
+ sha256 = "146372dfdf4defd556ac9d7a6322cd49e397f663ef1a9f0144e108d4793b42fc",
),
struct(
name = "linux_arm64",
cpu = "aarch64",
os = "linux",
- sha256 = "d4da684d021d1ebf40bb3819c1521c96c3ca51d22d911ee71731a358bd768594",
+ sha256 = "db19983cda00966857eace073e189b23304696cb6a7812c5a31c094cfda9ebac",
),
struct(
name = "windows_amd64",
cpu = "x86_64",
os = "windows",
- sha256 = "beede8f802ab96a2cce0de84c560150dcbc89c96db94f7c17519dd164ac983fd",
+ sha256 = "20b895218d505efec3fb20d8cd457f8e9fbaabb643fa15d75d5eb25928b054a2",
),
struct(
name = "windows_arm64",
cpu = "aarch64",
os = "windows",
- sha256 = "0885047b40b119e58fcca4491a2bd00331de131f41183de2a9b563ca407f9109",
+ sha256 = "8d61e41594d9e6ff29ce57a3177a8333a72c2c999e6fd030ab57324f7dab1a30",
),
]
@@ -4,28 +4,29 @@
diff --git a/rs/extensions.bzl b/rs/extensions.bzl
--- a/rs/extensions.bzl
+++ b/rs/extensions.bzl
@@ -321,7 +321,7 @@ def _generate_hub_and_spokes(
@@ -359,8 +359,8 @@ def _generate_hub_and_spokes(
kwargs = dict(
hub_name = hub_name,
crate_visibility = visibility_with_internal_access(annotation.visibility, internal_packages),
gen_build_script = annotation.gen_build_script,
- build_script_deps = [],
+ build_script_deps = annotation.build_script_deps,
build_script_deps_select = _select(feature_resolutions.build_deps),
build_script_data = annotation.build_script_data,
build_script_data_select = annotation.build_script_data_select,
@@ -881,9 +881,9 @@ _annotation = tag_class(
"build_script_data_select": _label_list_dict(
doc = "Labels to add to a crate's `cargo_build_script::data` attribute, keyed by platform triplet.",
),
@@ -1094,9 +1094,9 @@ _annotation = tag_class(
# "build_script_data_glob": attr.string_list(
# doc = "A list of glob patterns to add to a crate's `cargo_build_script::data` attribute",
# ),
- # "build_script_deps": attr.label_list(
- # doc = "A list of labels to add to a crate's `cargo_build_script::deps` attribute.",
- # ),
+ "build_script_deps": attr.string_list(
+ doc = "A list of labels to add to a crate's `cargo_build_script::deps` attribute.",
+ ),
"build_script_env": attr.string_dict(
doc = "Additional environment variables to set on a crate's `cargo_build_script::env` attribute.",
),
"build_script_env_files": attr.label_list(
doc = "Files containing additional environment variables for a crate's `cargo_build_script`.",
allow_files = True,
diff --git a/rs/private/annotations.bzl b/rs/private/annotations.bzl
--- a/rs/private/annotations.bzl
+++ b/rs/private/annotations.bzl
+4 -5
View File
@@ -1,10 +1,9 @@
diff --git a/rs/toolchains/declare_rustc_toolchains.bzl b/rs/toolchains/declare_rustc_toolchains.bzl
--- a/rs/toolchains/declare_rustc_toolchains.bzl
+++ b/rs/toolchains/declare_rustc_toolchains.bzl
@@ -45,6 +45,14 @@
},
)
source_stdlib_building_select[config_setting] = "@rules_rs//rs/private:empty_stdlib"
@@ -132,5 +132,13 @@
"//conditions:default": rust_std_label,
})
+
+ # Apple targets default to packed dSYMs and invoke dsymutil at link time.
+ # The Linux remote Rust action has no dsymutil. Match Cargo release's
@@ -15,7 +14,7 @@ diff --git a/rs/toolchains/declare_rustc_toolchains.bzl b/rs/toolchains/declare_
+ })
-
+
for triple in execs:
for triple in exec_triples:
exec_triple = _parse_triple(triple)
@@ -152,8 +160,20 @@
"//conditions:default": [],
@@ -1,15 +0,0 @@
# What: use Rust's bundled direct linker for Windows x86_64 and ARM64 MSVC toolchains.
# Scope: standard and bootstrap rules_rs Rust toolchains targeting x86_64 and ARM64 MSVC.
diff --git a/rs/toolchains/declare_rustc_toolchains.bzl b/rs/toolchains/declare_rustc_toolchains.bzl
--- a/rs/toolchains/declare_rustc_toolchains.bzl
+++ b/rs/toolchains/declare_rustc_toolchains.bzl
@@ -88,6 +88,8 @@ def declare_rustc_toolchains(
llvm_cov = "@llvm//tools:llvm-cov",
llvm_profdata = "@llvm//tools:llvm-profdata",
linker = select({
+ "@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": "{}rust-lld".format(rustc_repo_label),
+ "@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": "{}rust-lld".format(rustc_repo_label),
"@platforms//cpu:wasm32": "{}rust-lld".format(rustc_repo_label),
"@platforms//cpu:wasm64": "{}rust-lld".format(rustc_repo_label),
"//conditions:default": None,
@@ -4,11 +4,12 @@
diff --git a/rs/private/cargo_workspace_graph.bzl b/rs/private/cargo_workspace_graph.bzl
--- a/rs/private/cargo_workspace_graph.bzl
+++ b/rs/private/cargo_workspace_graph.bzl
@@ -762,6 +762,8 @@ def workspace_dep_data(
@@ -762,7 +762,9 @@ def workspace_dep_data(
"deps": deps,
"deps_by_platform": deps_by_platform,
"dev_deps": dev_deps,
"dev_deps_by_platform": dev_deps_by_platform,
"edition": package.get("edition", "2015"),
+ "package_name": package["name"],
"shared_libraries": shared_libraries,
+ "version": package["version"],
-27
View File
@@ -1,27 +0,0 @@
# Fetch Linux zlib from Launchpad with the pinned Ubuntu snapshot as a fallback.
# Follow https://github.com/hermeticbuild/rules_rs/commit/ee9a99d0a8e7784b3104dd188123750443cf2c26
# while keeping this rules_rs version's package versions and SHA-256 hashes.
diff --git a/rs/private/rustc_repository.bzl b/rs/private/rustc_repository.bzl
--- a/rs/private/rustc_repository.bzl
+++ b/rs/private/rustc_repository.bzl
@@ -11,11 +11,17 @@ _LINUX_ZLIB = {
"aarch64": struct(
libdir = "usr/lib/aarch64-linux-gnu",
sha256 = "cbe3d39ec32d3cc27c021ae4af11e7c67bdf9d700d573207e0941d4038056278",
- url = "https://ports.ubuntu.com/ubuntu-ports/pool/main/z/zlib/zlib1g_1.3.dfsg-3.1ubuntu2.1_arm64.deb",
+ url = [
+ "https://launchpad.net/ubuntu/+archive/primary/+files/zlib1g_1.3.dfsg-3.1ubuntu2.1_arm64.deb",
+ "https://snapshot.ubuntu.com/ubuntu/20260801T000000Z/pool/main/z/zlib/zlib1g_1.3.dfsg-3.1ubuntu2.1_arm64.deb",
+ ],
),
"x86_64": struct(
libdir = "usr/lib/x86_64-linux-gnu",
sha256 = "7074b6a2f6367a10d280c00a1cb02e74277709180bab4f2491a2f355ab2d6c20",
- url = "https://archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g_1.3.dfsg-3.1ubuntu2.1_amd64.deb",
+ url = [
+ "https://launchpad.net/ubuntu/+archive/primary/+files/zlib1g_1.3.dfsg-3.1ubuntu2.1_amd64.deb",
+ "https://snapshot.ubuntu.com/ubuntu/20260801T000000Z/pool/main/z/zlib/zlib1g_1.3.dfsg-3.1ubuntu2.1_amd64.deb",
+ ],
),
}
@@ -1,19 +0,0 @@
diff --git a/cargo/private/cargo_build_script.bzl b/cargo/private/cargo_build_script.bzl
--- a/cargo/private/cargo_build_script.bzl
+++ b/cargo/private/cargo_build_script.bzl
@@ -396,3 +396,8 @@ def _cargo_build_script_impl(ctx):
+ script_tools = []
+ for target in ctx.attr.tools:
+ script_tools.append(target[DefaultInfo].files)
+ script_tools.append(target[DefaultInfo].default_runfiles.files)
+
workspace_name = ctx.label.workspace_name
if not workspace_name:
workspace_name = ctx.workspace_name
@@ -581,5 +586,5 @@ def _cargo_build_script_impl(ctx):
direct = [
ctx.executable._cargo_build_script_runner,
] + ([toolchain.target_json] if toolchain.target_json else []),
- transitive = script_data + toolchain_tools,
+ transitive = script_data + script_tools + toolchain_tools,
)
@@ -0,0 +1,107 @@
# rules_rust PR #92, commit 100616343e949f6744c5f01733cc42bf36c86d5e.
# Use the selected C++ toolchain's declared lld-link for rustc.
# Cargo retains clang-cl; explicit Rust linker preferences remain unchanged.
diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl
index 5b206a6c0..a79bb6108 100644
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -412,6 +412,7 @@ _LinkerConfigInfo = provider(fields = [
"action_name",
"feature_configuration",
"is_direct_driver",
+ "msvc_lld_link",
"rpaths",
"rust_linker",
"target_abi",
@@ -420,7 +421,14 @@ _LinkerConfigInfo = provider(fields = [
"variables",
])
-def _get_linker_config(ctx, crate_type, toolchain, cc_toolchain, feature_configuration, rpaths, add_flags_for_binary):
+def _get_cc_linker_files(cc_toolchain):
+ if not cc_toolchain:
+ return depset()
+ if hasattr(cc_toolchain, "_linker_files"):
+ return cc_toolchain._linker_files
+ return cc_toolchain.linker_files()
+
+def _get_linker_config(ctx, crate_type, toolchain, cc_toolchain, feature_configuration, rpaths, add_flags_for_binary, for_rustc = False):
user_link_flags = get_cc_user_link_flags(ctx)
cc_linker = None
@@ -463,6 +471,19 @@ def _get_linker_config(ctx, crate_type, toolchain, cc_toolchain, feature_configu
if use_rust_linker and not toolchain.linker:
fail("No linker available for rustc. Either `rust_toolchain.linker` must be set or a `cc_toolchain` configured for the current configuration.")
+ msvc_lld_link = None
+ if for_rustc and not use_rust_linker and toolchain.target_os == "windows" and toolchain.target_abi == "msvc" and paths.basename(cc_linker).lower() in ("clang-cl", "clang-cl.exe"):
+ # rustc's MSVC interface sends LINK arguments, not clang-cl arguments.
+ # Keep Cargo's C/C++ driver unchanged and use only a declared sibling.
+ executable = "lld-link.exe" if cc_linker.lower().endswith(".exe") else "lld-link"
+ linker_path = paths.join(paths.dirname(cc_linker), executable)
+ for file in _get_cc_linker_files(cc_toolchain).to_list():
+ if file.path == linker_path:
+ msvc_lld_link = file
+ break
+ if not msvc_lld_link:
+ fail("Rust MSVC linking requires {} in cc_toolchain.linker_files when the C++ linker is {}. Alternatively, configure a direct MSVC linker in the Rust toolchain and set linker_preference = \"rust\".".format(linker_path, cc_linker))
+
# Keep CcToolchainVariables and the Rust linker File until map_each runs so
# cc_common and File.path use the Rustc action's path mapper.
return _LinkerConfigInfo(
@@ -470,7 +491,8 @@ def _get_linker_config(ctx, crate_type, toolchain, cc_toolchain, feature_configu
action_name = action_name,
variables = link_variables,
rust_linker = toolchain.linker if use_rust_linker else None,
- is_direct_driver = use_rust_linker and toolchain.linker_type == "direct",
+ msvc_lld_link = msvc_lld_link,
+ is_direct_driver = bool(msvc_lld_link) or (use_rust_linker and toolchain.linker_type == "direct"),
target_abi = toolchain.target_abi,
target_arch = toolchain.target_arch,
target_os = toolchain.target_os,
@@ -480,6 +502,8 @@ def _get_linker_config(ctx, crate_type, toolchain, cc_toolchain, feature_configu
def _get_linker_path(linker_config):
if linker_config.rust_linker:
return linker_config.rust_linker.path
+ if linker_config.msvc_lld_link:
+ return linker_config.msvc_lld_link.path
return cc_common.get_tool_for_action(
feature_configuration = linker_config.feature_configuration,
action_name = linker_config.action_name,
@@ -538,7 +562,7 @@ def _get_linker_args(linker_config):
variables = linker_config.variables,
))
- if linker_config.rust_linker:
+ if linker_config.rust_linker or linker_config.msvc_lld_link:
# Make sure we include RPATHs for Rust ABI dylibs even when no cc_toolchain.
if linker_config.variables == None and linker_config.rpaths:
for rpath in linker_config.rpaths.to_list():
@@ -915,17 +939,7 @@ def collect_inputs(
"""
linker_script = getattr(file, "linker_script", None)
- # TODO: As of writing this comment Bazel used Java CcToolchainInfo.
- # However there is ongoing work to rewrite provider in Starlark.
- # rules_rust is not coupled with Bazel release. Remove conditional and change to
- # _linker_files once Starlark CcToolchainInfo is visible to Bazel.
- # https://github.com/bazelbuild/rules_rust/issues/2425
- if not cc_toolchain:
- linker_depset = depset()
- elif hasattr(cc_toolchain, "_linker_files"):
- linker_depset = cc_toolchain._linker_files
- else:
- linker_depset = cc_toolchain.linker_files()
+ linker_depset = _get_cc_linker_files(cc_toolchain)
compilation_mode = ctx.var["COMPILATION_MODE"]
use_pic = should_use_pic(
@@ -1586,6 +1600,7 @@ def construct_arguments(
feature_configuration,
rpaths,
add_flags_for_binary = add_flags_for_binary,
+ for_rustc = True,
)
ld_is_direct_driver = linker_config.is_direct_driver
@@ -7,11 +7,11 @@
+load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")
load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("//rust:defs.bzl", "rust_common")
@@ -11,6 +12,7 @@
# buildifier: disable=bzl-visibility
load("//cargo/private:cargo_toolchain.bzl", "cargo_version_mismatch", "find_cargo")
@@ -12,6 +13,7 @@
load(
"//rust/private:rustc.bzl",
"collect_cfg_query_rustc_flags",
+ "collect_extra_rustc_flags",
"get_compilation_mode_opts",
"get_linker_and_args",
@@ -66,8 +66,23 @@
+ ]
+ return [flag for flag in flags if flag not in profile_defaults]
def get_cc_compile_args_and_env(cc_toolchain, feature_configuration):
def get_cc_compile_args_and_env(ctx, cc_toolchain, feature_configuration):
"""Gather cc environment variables from the given `cc_toolchain`
@@ -94,12 +94,12 @@
c_compile_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
- user_compile_flags = ctx.fragments.cpp.copts + ctx.fragments.cpp.conlyopts,
+ user_compile_flags = [] if _feature_enabled(ctx, "cargo-release-profile") else ctx.fragments.cpp.copts + ctx.fragments.cpp.conlyopts,
)
cxx_compile_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
cc_toolchain = cc_toolchain,
- user_compile_flags = ctx.fragments.cpp.copts + ctx.fragments.cpp.cxxopts,
+ user_compile_flags = [] if _feature_enabled(ctx, "cargo-release-profile") else ctx.fragments.cpp.copts + ctx.fragments.cpp.cxxopts,
)
cc_c_args = cc_common.get_memory_inefficient_command_line(
feature_configuration = feature_configuration,
@@ -469,6 +509,22 @@
env["CARGO_PKG_VERSION_PRE"] = patch[1] if len(patch) > 1 else ""
env["CARGO_PKG_VERSION"] = ctx.attr.version
@@ -88,13 +103,13 @@
+ debug_info = codegen.removeprefix("debuginfo=")
+ env["DEBUG"] = "false" if debug_info in ["0", "none"] else "true"
+
# Pull in env vars which may be required for the cc_toolchain to work (e.g. on OSX, the SDK version).
# We hope that the linker env is sufficient for the whole cc_toolchain.
cc_toolchain, feature_configuration = find_cc_toolchain(ctx)
use_cc_toolchain = _resolve_tristate(
ctx.attr.use_cc_toolchain,
ctx.attr._default_use_cc_toolchain,
@@ -484,6 +540,13 @@
if cc_toolchain:
# MSVC requires INCLUDE to be set
cc_c_args, cc_cxx_args, cc_env = get_cc_compile_args_and_env(cc_toolchain, feature_configuration)
cc_c_args, cc_cxx_args, cc_env = get_cc_compile_args_and_env(ctx, cc_toolchain, feature_configuration)
+ if cargo_release_profile:
+ # Preserve SDK, ABI, CRT and security options. User copts and crate
+ # build_script_env overrides retain precedence over these defaults.
@@ -1,14 +1,19 @@
--- a/cargo/private/cargo_build_script_runner/lib.rs
+++ b/cargo/private/cargo_build_script_runner/lib.rs
@@ -337,9 +337,18 @@
@@ -377,14 +377,23 @@
return "${pwd}".to_owned();
}
- value
+ let redacted = value
.replace(&format!("{exec_root}/"), "${pwd}/")
- .replace(&format!("{exec_root}\\"), "${pwd}\\")
+ .replace(&format!("{exec_root}\\"), "${pwd}\\");
.replace(&format!("{exec_root}\\"), "${pwd}\\")
// Flags such as `--remap-path-prefix=<exec_root>=.` (which build
// scripts see in CARGO_ENCODED_RUSTFLAGS and may echo back as
// `cargo:rustc-env`) follow the exec root with `=`. Leaving it
// unredacted bakes the per-action sandbox path into the output.
- .replace(&format!("{exec_root}="), "${pwd}=")
+ .replace(&format!("{exec_root}="), "${pwd}=");
+ #[cfg(windows)]
+ let redacted = {
+ // pkg-config can emit forward slashes for the same Windows root.
@@ -21,9 +26,9 @@
}
/// Redact for env vars: uses the generic `${out_dir}` token, resolved
@@ -630,6 +639,28 @@
link_search_paths:
"-L${pwd}/${bazel-out/cfg/bin/pkg/_bs.out_dir}\n-L${pwd}/other/path".to_owned(),
@@ -736,6 +745,26 @@
cdylib_link_flags: "".to_owned(),
bin_link_flags: "".to_owned(),
}
+ );
+ }
@@ -31,7 +36,8 @@
+ #[cfg(windows)]
+ #[test]
+ fn windows_include_metadata_redacts_both_root_spellings() {
+ let root = r"D:\o\execroot\_main";
+ let directory = std::env::current_dir().unwrap();
+ let root = directory.to_str().unwrap();
+ let forward = root.replace('\\', "/");
+ let outputs = vec![BuildScriptOutput::DepEnv(format!(
+ "INCLUDE={forward}/include;{root}\\lib;{forward}-other/include"
@@ -40,12 +46,9 @@
+ BuildScriptOutput::outputs_to_dep_env(&outputs, "glib", root),
+ format!("DEP_GLIB_INCLUDE=${{pwd}}/include;${{pwd}}\\lib;{forward}-other/include")
+ );
+ let directory = std::env::current_dir().unwrap();
+ let directory = directory.to_str().unwrap();
+ let forward = directory.replace('\\', "/");
+ let outputs = vec![BuildScriptOutput::DepEnv(format!("INCLUDE={forward}/."))];
+ assert_eq!(
+ BuildScriptOutput::nonhermetic_absolute_paths(&outputs, directory, ""),
+ BuildScriptOutput::nonhermetic_absolute_paths(&outputs, root, ""),
+ Vec::<String>::new()
);
}
@@ -1,109 +0,0 @@
--- a/rust/private/rustc.bzl
+++ b/rust/private/rustc.bzl
@@ -438,4 +438,11 @@
use_bpf_linker = toolchain.target_arch in ("bpfeb", "bpfel") and toolchain.linker
- if not ld or toolchain.linker_preference == "rust" or use_bpf_linker:
+ use_windows_msvc_linker = (
+ toolchain.target_arch in ("x86_64", "aarch64") and
+ toolchain.target_os == "windows" and
+ toolchain.target_abi == "msvc" and
+ toolchain.linker != None and
+ toolchain.linker_preference != "cc"
+ )
+ if not ld or toolchain.linker_preference == "rust" or use_bpf_linker or use_windows_msvc_linker:
ld = toolchain.linker.path
ld_is_direct_driver = toolchain.linker_type == "direct"
@@ -468,11 +468,25 @@
filtered_args.append(version)
# Keep library search path flags
+ elif processed_arg == "-L" and i + 1 < len(link_args):
+ path = link_args[i + 1]
+ if ld_is_direct_driver and toolchain.target_os == "windows" and toolchain.target_abi == "msvc":
+ skip_next = True
+ continue
+ filtered_args.extend([processed_arg, path])
+ skip_next = True
+
elif processed_arg.startswith("-L"):
+ if ld_is_direct_driver and toolchain.target_os == "windows" and toolchain.target_abi == "msvc":
+ continue
filtered_args.append(processed_arg)
# Keep sysroot flags (as single or two-part arguments)
elif processed_arg == "--sysroot" or processed_arg.startswith("--sysroot="):
+ if ld_is_direct_driver and toolchain.target_os == "windows" and toolchain.target_abi == "msvc":
+ if processed_arg == "--sysroot" and i + 1 < len(link_args):
+ skip_next = True
+ continue
filtered_args.append(processed_arg)
if processed_arg == "--sysroot" and i + 1 < len(link_args):
# Two-part argument, keep the next arg too
@@ -2943,8 +2957,10 @@
use_pic,
ambiguous_libs,
get_lib_name,
+ for_windows = False,
for_darwin = False,
- flavor_msvc = False):
+ flavor_msvc = False,
+ use_direct_driver = False):
"""_summary_
Args:
@@ -2952,8 +2968,10 @@
use_pic (_type_): _description_
ambiguous_libs (_type_): _description_
get_lib_name (_type_): _description_
+ for_windows (bool, optional): _description_. Defaults to False.
for_darwin (bool, optional): _description_. Defaults to False.
flavor_msvc (bool, optional): _description_. Defaults to False.
+ use_direct_driver (bool, optional): _description_. Defaults to False.
Returns:
_type_: _description_
@@ -2997,6 +3015,11 @@
):
return [] if for_darwin else ["-lstatic=%s" % get_lib_name(artifact)]
+ if for_windows and flavor_msvc and use_direct_driver and not artifact.basename.endswith(".lib"):
+ return [
+ "-Clink-arg={}".format(artifact.path),
+ ]
+
if flavor_msvc:
return [
"-lstatic=%s" % get_lib_name(artifact),
@@ -3045,7 +3068,7 @@
])
elif include_link_flags:
get_lib_name = get_lib_name_for_windows if flavor_msvc else get_lib_name_default
- ret.extend(portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name, flavor_msvc = flavor_msvc))
+ ret.extend(portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name, for_windows = True, flavor_msvc = flavor_msvc, use_direct_driver = use_direct_driver))
# Windows toolchains can inherit POSIX defaults like -pthread from C deps,
# which fails to link with the MinGW/LLD toolchain. Drop them here.
@@ -3257,11 +3280,18 @@
format_each = "-Lnative=%s",
)
if include_link_flags:
- args.add_all(
- runtime_libs,
- map_each = get_lib_name,
- format_each = static_runtime_link_format,
- )
+ if toolchain.target_os == "windows" and toolchain.target_abi == "msvc" and use_direct_link_driver:
+ for runtime_lib in runtime_libs.to_list():
+ if runtime_lib.basename.endswith(".lib"):
+ args.add(get_lib_name(runtime_lib), format = static_runtime_link_format)
+ else:
+ args.add(runtime_lib.path, format = "--codegen=link-arg=%s")
+ else:
+ args.add_all(
+ runtime_libs,
+ map_each = get_lib_name,
+ format_each = static_runtime_link_format,
+ )
def _get_dirname(file):
"""A helper function for `_add_native_link_flags`.
@@ -1,15 +0,0 @@
--- a/util/process_wrapper/main.rs
+++ b/util/process_wrapper/main.rs
@@ -213,6 +213,12 @@ fn consolidate_dependency_search_paths(
let file_name_lower = file_name
.to_string_lossy()
.to_ascii_lowercase();
+ if file_name_lower.contains(".tmp") || file_name_lower.ends_with(".rcgu.o") {
+ // Native Windows Rust link actions can leave transient `*.exe.tmp*` and
+ // per-codegen-unit `*.rcgu.o` outputs next to the final binary.
+ // Those are not stable linker search-path inputs.
+ continue;
+ }
if !seen.insert(file_name_lower) {
continue;
}
+1
View File
@@ -0,0 +1 @@
exports_files(["openssl_sys.BUILD.bazel"])
+50
View File
@@ -0,0 +1,50 @@
load("@package_metadata//rules:package_metadata.bzl", "package_metadata")
load("@rules_rs//rs:cargo_build_script.bzl", "cargo_build_script")
load("@rules_rs//rs:rust_library.bzl", "rust_library")
package(default_visibility = ["//visibility:public"])
package_metadata(
name = "openssl-sys_package_metadata",
purl = "pkg:cargo/openssl-sys@0.9.118",
)
# Deliberately omit vendored/openssl-src: the native library belongs to @openssl.
# Keep the upstream build script for header checks, cfgs, and link metadata.
cargo_build_script(
name = "build_script",
srcs = glob(["build/*.rs"]),
build_script_env = {
"OPENSSL_DIR": "$(execpath @openssl//:gen_dir)",
"OPENSSL_NO_VENDOR": "1",
"OPENSSL_STATIC": "1",
},
crate_name = "build_script_build",
crate_root = "build/main.rs",
data = glob(["build/**"]) + ["@openssl//:gen_dir"],
edition = "2021",
links = "openssl",
pkg_name = "openssl-sys",
rustc_env = {"CARGO_PKG_VERSION": "0.9.118"},
version = "0.9.118",
deps = [
"@crates//:cc-1.2.55",
"@crates//:pkg-config-0.3.32",
"@crates//:vcpkg-0.2.15",
],
)
rust_library(
name = "openssl-sys",
srcs = glob(["src/**/*.rs"]),
crate_name = "openssl_sys",
crate_root = "src/lib.rs",
data = ["@openssl//:gen_dir"],
edition = "2021",
package_metadata = ["openssl-sys_package_metadata"],
version = "0.9.118",
deps = [
"build_script",
"@crates//:libc-0.2.186",
],
)
+69
View File
@@ -0,0 +1,69 @@
load("@bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("sqlite_build_info.bzl", "sqlite_build_info")
package(default_visibility = ["//visibility:public"])
exports_files([
"libsqlite3_sys.BUILD.bazel",
])
# Use bindings and native code from the same libsqlite3-sys release.
copy_to_directory(
name = "sqlite_bindings",
srcs = ["@crates//:libsqlite3_sys_bindings"],
include_external_repositories = ["*"],
replace_prefixes = {"sqlite3/bindgen_bundled_version.rs": "bindgen.rs"},
)
sqlite_build_info(
name = "libsqlite3_sys_build_info",
cc_lib = "sqlite3",
out_dir = "sqlite_bindings",
)
# Match libsqlite3-sys's bundled build without embedding build.rs's worker path.
# Internal compilation options must not leak into dependent C/C++ targets.
cc_library(
name = "sqlite3",
srcs = ["@crates//:libsqlite3_sys_source"],
linkopts = select({
"@platforms//os:freebsd": ["-lpthread"],
"@platforms//os:linux": [
"-lpthread",
"-ldl",
],
"@platforms//os:netbsd": ["-lpthread"],
"@platforms//os:openbsd": ["-lpthread"],
"//conditions:default": [],
}),
linkstatic = True,
local_defines = [
"SQLITE_CORE",
"SQLITE_DEFAULT_FOREIGN_KEYS=1",
"SQLITE_ENABLE_API_ARMOR",
"SQLITE_ENABLE_COLUMN_METADATA",
"SQLITE_ENABLE_DBSTAT_VTAB",
"SQLITE_ENABLE_FTS3",
"SQLITE_ENABLE_FTS3_PARENTHESIS",
"SQLITE_ENABLE_FTS5",
"SQLITE_ENABLE_JSON1",
"SQLITE_ENABLE_LOAD_EXTENSION=1",
"SQLITE_ENABLE_RTREE",
"SQLITE_ENABLE_STAT4",
"SQLITE_SOUNDEX",
"SQLITE_THREADSAFE=1",
"SQLITE_USE_URI",
"HAVE_USLEEP=1",
"HAVE_ISNAN",
"_POSIX_THREAD_SAFE_FUNCTIONS",
] + select({
"@platforms//os:windows": [],
"//conditions:default": ["HAVE_LOCALTIME_R"],
}) + select({
# Preserve Codex's workaround for older x64 Windows CPUs.
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ["SQLITE_DISABLE_INTRINSIC"],
"//conditions:default": [],
}),
deps = ["@crates//:libsqlite3_sys_headers"],
)
+16
View File
@@ -0,0 +1,16 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
exports_files(
[
"sqlite3/bindgen_bundled_version.rs",
"sqlite3/sqlite3.c",
],
visibility = ["//visibility:public"],
)
cc_library(
name = "sqlite3_headers",
hdrs = ["sqlite3/sqlite3.h"],
includes = ["sqlite3"],
visibility = ["//visibility:public"],
)
+30
View File
@@ -0,0 +1,30 @@
"""Supply libsqlite3-sys's bindings and Bazel-owned native library."""
load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_rust//rust/private:providers.bzl", "BuildInfo")
def _sqlite_build_info_impl(ctx):
out_dir = ctx.file.out_dir
if not out_dir.is_directory:
fail("out_dir must be a directory")
return [
BuildInfo(
compile_data = depset(),
dep_env = None,
flags = None,
linker_flags = None,
link_search_paths = None,
out_dir = out_dir,
rustc_env = None,
),
ctx.attr.cc_lib[CcInfo],
]
sqlite_build_info = rule(
implementation = _sqlite_build_info_impl,
attrs = {
"cc_lib": attr.label(mandatory = True, providers = [CcInfo]),
"out_dir": attr.label(allow_single_file = True, mandatory = True),
},
)
+32 -44
View File
@@ -1,15 +1,17 @@
load("@@//third_party/v8:artifact_profile.bzl", "v8_artifact_files")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@rules_cc//cc:cc_static_library.bzl", "cc_static_library")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")
load("@rules_rs//rs:rules_rust_bindgen.bzl", "rust_bindgen")
package(default_visibility = ["//visibility:public"])
exports_files([
"abseil.BUILD.bazel",
"abseil_lifetime_capture.patch",
"abseil_repository.bzl",
"artifact_profile.bzl",
"binary.bzl",
"dependencies.bzl",
"dependency_config.bzl",
"dragonbox.BUILD.bazel",
@@ -22,6 +24,8 @@ exports_files([
"icu.BUILD.bazel",
"libcxx_rules.bzl",
"native_windows.bzl",
"windows_snapshot.bzl",
"v8_windows_snapshot_wine.patch",
"push_registers_gnullvm.S",
"simdutf.BUILD.bazel",
"v8_defs.patch",
@@ -134,14 +138,14 @@ alias(
actual = select({
"@rules_rs//rs/platforms/config:aarch64-apple-darwin": ":v8_152_2_0_aarch64_apple_darwin_bazel",
"@rules_rs//rs/platforms/config:aarch64-pc-windows-gnullvm": ":v8_152_2_0_aarch64_pc_windows_gnullvm",
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":v8_152_2_0_aarch64_pc_windows_msvc_bazel",
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":v8_152_2_0_aarch64_pc_windows_msvc_workspace",
"@llvm//platforms/config:linux_aarch64_gnu": ":v8_152_2_0_aarch64_unknown_linux_gnu_bazel",
# Rust's compiler-builtins archive does not supply V8's __clear_cache.
# Use the merged archive containing the ARM64 compiler-rt builtins.
"@llvm//platforms/config:linux_aarch64_musl": ":v8_152_2_0_aarch64_unknown_linux_musl_release",
"@rules_rs//rs/platforms/config:x86_64-apple-darwin": ":v8_152_2_0_x86_64_apple_darwin_bazel",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-gnullvm": ":v8_152_2_0_x86_64_pc_windows_gnullvm",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":v8_152_2_0_x86_64_pc_windows_msvc_bazel",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":v8_152_2_0_x86_64_pc_windows_msvc_workspace",
"@llvm//platforms/config:linux_x86_64_gnu": ":v8_152_2_0_x86_64_unknown_linux_gnu_bazel",
"@llvm//platforms/config:linux_x86_64_musl": ":v8_152_2_0_x86_64_unknown_linux_musl_release",
"//conditions:default": ":v8_152_2_0_x86_64_unknown_linux_gnu_bazel",
@@ -173,12 +177,12 @@ alias(
actual = select({
"@rules_rs//rs/platforms/config:aarch64-apple-darwin": ":src_binding_aarch64_apple_darwin_152_2_0_bazel",
"@rules_rs//rs/platforms/config:aarch64-pc-windows-gnullvm": ":src_binding_aarch64_pc_windows_gnullvm_152_2_0_bazel",
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":src_binding_aarch64_pc_windows_msvc_152_2_0_bazel",
"@rules_rs//rs/platforms/config:aarch64-pc-windows-msvc": ":src_binding_aarch64_pc_windows_msvc_152_2_0_workspace",
"@llvm//platforms/config:linux_aarch64_gnu": ":src_binding_aarch64_unknown_linux_gnu_152_2_0_bazel",
"@llvm//platforms/config:linux_aarch64_musl": ":src_binding_aarch64_unknown_linux_musl_152_2_0_bazel",
"@rules_rs//rs/platforms/config:x86_64-apple-darwin": ":src_binding_x86_64_apple_darwin_152_2_0_bazel",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-gnullvm": ":src_binding_x86_64_pc_windows_gnullvm_152_2_0_bazel",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":src_binding_x86_64_pc_windows_msvc_152_2_0_bazel",
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": ":src_binding_x86_64_pc_windows_msvc_152_2_0_workspace",
"@llvm//platforms/config:linux_x86_64_gnu": ":src_binding_x86_64_unknown_linux_gnu_152_2_0_bazel",
"@llvm//platforms/config:linux_x86_64_musl": ":src_binding_x86_64_unknown_linux_musl_152_2_0_bazel",
"//conditions:default": ":src_binding_x86_64_unknown_linux_gnu_152_2_0_bazel",
@@ -301,9 +305,9 @@ cc_library(
}),
)
alias(
cc_import(
name = "native_windows_compiler_builtins",
actual = "@v8_native_windows_llvm//:builtins",
static_library = "@llvm//runtimes/compiler-rt:clang_rt.builtins.static",
tags = ["manual"],
target_compatible_with = select({
":platform_windows_msvc": [],
@@ -326,30 +330,33 @@ cc_static_library(
],
)
# 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.
# cc_static_library does not collect objects from imported archives. Merge the
# source-built compiler-rt archive with the declared exec-platform llvm-lib.
genrule(
name = "v8_152_2_0_native_windows_library",
srcs = [
":v8_152_2_0_native_windows_objects",
"@v8_native_windows_llvm//:builtins_archive",
"@llvm//runtimes/compiler-rt:clang_rt.builtins.static",
],
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)""',
cmd = '"$(execpath @llvm//tools:llvm-lib)" /NOLOGO /OUT:"$@" "$(location :v8_152_2_0_native_windows_objects)" "$(location @llvm//runtimes/compiler-rt:clang_rt.builtins.static)"',
cmd_bat = '""$(execpath @llvm//tools:llvm-lib)" /NOLOGO /OUT:"$@" "$(location :v8_152_2_0_native_windows_objects)" "$(location @llvm//runtimes/compiler-rt:clang_rt.builtins.static)""',
tags = ["manual"],
target_compatible_with = [
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
tools = ["@v8_native_windows_llvm//:llvm-lib"],
tools = ["@llvm//tools:llvm-lib"],
)
# Workspace binaries use the hermetic toolchain's ISO stdio ABI. Distributed
# archives must link with the stock MSVC CRT. Generate a matching binding for
# each archive under the same profile.
[
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",
name = label_pattern % (arch, suffix),
srcs = [source],
profile = profile,
tags = ["manual"],
target_compatible_with = [
"@platforms//cpu:%s" % arch,
@@ -362,6 +369,14 @@ genrule(
("x86_64", "x64"),
("aarch64", "arm64"),
]
for label_pattern, source in [
("v8_152_2_0_%s_pc_windows_msvc_%s", ":v8_152_2_0_native_windows_library"),
("src_binding_%s_pc_windows_msvc_152_2_0_%s", ":binding_generated_152_2_0"),
]
for suffix, profile in [
("workspace", "source"),
("bazel", "sandbox_release"),
]
]
# Producer selectors never fall back to published inputs. Keep them separate
@@ -419,8 +434,7 @@ rust_bindgen(
clang_flags = [
"-x",
"c++",
"-std=c++20",
] + V8_CUSTOM_LIBCXX_COPTS + select({
] + V8_COPTS + V8_CUSTOM_LIBCXX_COPTS + select({
# Match the C++ toolchain. Bindgen asks for C flags and otherwise
# enables C++20 modules, for which the macOS SDK's types are cyclic.
"@platforms//os:osx": [
@@ -444,32 +458,6 @@ rust_bindgen(
tags = ["manual"],
)
v8_artifact_files(
name = "src_binding_aarch64_pc_windows_msvc_152_2_0_bazel",
srcs = [":binding_generated_152_2_0"],
profile = "sandbox_release",
tags = ["manual"],
target_compatible_with = [
"@platforms//cpu:aarch64",
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
v8_cpu = "arm64",
)
v8_artifact_files(
name = "src_binding_x86_64_pc_windows_msvc_152_2_0_bazel",
srcs = [":binding_generated_152_2_0"],
profile = "sandbox_release",
tags = ["manual"],
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@llvm//constraints/windows/abi:msvc",
],
v8_cpu = "x64",
)
v8_artifact_files(
name = "src_binding_aarch64_pc_windows_gnullvm_152_2_0_bazel",
srcs = [":binding_generated_152_2_0"],
+51 -22
View File
@@ -123,16 +123,35 @@ revision must keep the native GNU link/runtime checks passing. The Bazel pair
targets above point directly to source targets so a new release or canary never
depends on an older published copy.
Native Windows x64 and ARM64 hosts can build sandbox archives and matching
Rust bindings with pinned clang-cl and the installed Microsoft SDK using
Windows x64 and ARM64 sandbox archives and matching Rust bindings use the
selected hermetic `@llvm` clang-cl toolchain and its declared Microsoft SDK:
`//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`.
The producer selectors `//third_party/v8:rusty_v8_native_windows_archive_for_target`
and `//third_party/v8:rusty_v8_native_windows_binding_for_target` select source
outputs directly. Both use the same sandbox, pointer compression, target CPU,
and Chromium libc++ profile. The bindings use V8's compiled headers and defines
so their sizes follow the archive, including CppGC members. Bazel MSVC consumers
use the newly built archive and bindings together.
so their sizes follow the archive, including CppGC members.
The Windows distribution archive uses the published MSVC wide-stdio mode
(`_CRT_STDIO_ISO_WIDE_SPECIFIERS=0`) for V8, Chromium libc++ and their native
dependencies. Native Windows CI checks the COFF directives and links and runs a
stock MSVC C++ consumer that includes `<cstdio>` and calls
`v8__V8__IsSandboxEnabled()` on both x64 and ARM64. Cargo runs the V8 runtime
tests against that staged archive and its generated bindings.
In-tree Bazel consumers link a separate source-built archive with the hermetic
toolchain's ISO stdio mode (`1`) and matching bindings. Both pairs use the
same V8 source, sandbox configuration and pinned Chromium libc++.
Binding generation uses the published hermeticbuild bindgen v0.0.4
executables through the standard rules_rs toolchain. Their embedded LLVM
23.1.2 libclang matches the selected LLVM resource headers; Codex does not
build bindgen or libclang from source.
Binding generation reuses `V8_COPTS`, including native `/std:c++20` on MSVC.
The clang-cl bindgen action passes toolchain and caller arguments through in CL
driver mode instead of translating their header-search or warning semantics.
The owned engine policy preserves the GN MSVC defaults for GC-managed microtask
queues, random Wasm module generation, disabled imminent-deprecation warnings,
@@ -142,29 +161,39 @@ bindings use that same threshold; never pair a native 64-byte threshold with
GN's size-zero binding constant. These are fixed platform choices, not additional
developer build switches.
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:
Private libc++ profiles set `@llvm//config:nostdincxx` and explicitly supply
Chromium's pinned libc++ headers and archive. The Windows MSVC profile also
sets `@llvm//config:nostdlibxx`. These settings are target-scoped: unrelated execution
tools retain their default C++ runtime. V8's own generator binaries explicitly
reapply the private-runtime policy after the execution transition. Neither flag
suppresses C headers, the SDK, CRT, compiler-rt, or the independent unwinder.
```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 `
Build with Linux remote execution and the static CRT:
```sh
bazel build --config=buildbuddy-generic-rbe --host_platform=//:rbe \
--platforms=@llvm//platforms:windows_x86_64_msvc \
--extra_execution_platforms=//:rbe \
--repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1 \
--repo_env=BAZEL_WINDOWS_SDK_EULA=1 \
--features=-dynamic_link_msvcrt --features=static_link_msvcrt \
--features=cargo-rebase-json-vfs-overlays \
//third_party/v8:rusty_v8_native_windows_archive_for_target \
//third_party/v8:rusty_v8_native_windows_binding_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. Bazel consumers now
cross this same boundary automatically. Other C++
dependencies in the same `ci-windows-msvc` build keep the installed MSVC
compiler; no whole-build V8 compiler flag is needed.
Torque and other ordinary generators execute on Linux. The MSVC snapshot
generator is a Windows payload compiled with the same `@llvm` toolchain.
`rules_wine` selects direct execution on Windows or its pinned Wine runtime on
Linux. Linux ARM64 workers use the runtime's bundled FEX to run the x64 generator;
both x64 and ARM64 targets use the existing `//:rbe` platform. This keeps V8's
Windows-host unwind writer enabled, including generated `.pdata`/`.xdata`.
Select `@llvm//platforms:windows_aarch64_msvc` for an ARM64 build.
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.
Native Windows ARM64 uses an ARM64 generator for ARM64 snapshots. Other MSVC
combinations use the x64 generator, including V8's x64-hosted ARM64 generator.
The existing GNU snapshot action and its Windows-local CI execution remain
unchanged. The existing MSVC assembly-to-C++ conversion is also retained.
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
+131
View File
@@ -0,0 +1,131 @@
# Backport of abseil/abseil-cpp 0784689a65b4ea1329fbc5174b8a57c88ec796a9.
# Adapted to 20250814.1: prefer Clang 23 lifetime_capture_by_this, retain older compiler fallback.
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -911,6 +911,23 @@
#define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(Owner)
#endif
+// Internal attribute; name and documentation TBD.
+//
+// See the upstream documentation:
+// https://clang.llvm.org/docs/AttributeReference.html#lifetime_capture_by_this
+//
+// Note: ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this) is deprecated. Use
+// ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS instead.
+#if ABSL_HAVE_CPP_ATTRIBUTE(clang::lifetime_capture_by_this)
+#define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS \
+ [[clang::lifetime_capture_by_this]]
+#elif ABSL_HAVE_CPP_ATTRIBUTE(clang::lifetime_capture_by)
+#define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS \
+ ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this)
+#else
+#define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS
+#endif
+
// ABSL_ATTRIBUTE_VIEW indicates that a type is solely a "view" of data that it
// points to, similarly to a span, string_view, or other non-owning reference
// type.
diff --git a/absl/base/internal/spinlock.h b/absl/base/internal/spinlock.h
--- a/absl/base/internal/spinlock.h
+++ b/absl/base/internal/spinlock.h
@@ -242,1 +242,1 @@
- SpinLock& l ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ SpinLock& l ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
diff --git a/absl/container/internal/btree_container.h b/absl/container/internal/btree_container.h
--- a/absl/container/internal/btree_container.h
+++ b/absl/container/internal/btree_container.h
@@ -508,1 +508,1 @@
- ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this)), \
+ ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS), \
@@ -510,1 +510,1 @@
- ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))) \
+ ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)) \
@@ -610,1 +610,1 @@
- ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this)), \
+ ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS), \
@@ -637,1 +637,1 @@
- const key_arg<K> &k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ const key_arg<K> &k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -646,2 +646,1 @@
- mapped_type &operator[](key_arg<K> &&k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(
- this)) ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ mapped_type &operator[](key_arg<K> &&k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS) ABSL_ATTRIBUTE_LIFETIME_BOUND {
diff --git a/absl/container/internal/raw_hash_map.h b/absl/container/internal/raw_hash_map.h
--- a/absl/container/internal/raw_hash_map.h
+++ b/absl/container/internal/raw_hash_map.h
@@ -117,1 +117,1 @@
- ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this)), \
+ ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS), \
@@ -118,2 +118,1 @@
- V VQual v ABSL_INTERNAL_IF_##VValue(ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY( \
- this))) ABSL_ATTRIBUTE_LIFETIME_BOUND { \
+ V VQual v ABSL_INTERNAL_IF_##VValue(ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)) ABSL_ATTRIBUTE_LIFETIME_BOUND { \
@@ -216,1 +215,1 @@
- key_arg<K> &&k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ key_arg<K> &&k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -235,1 +234,1 @@
- const key_arg<K> &k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ const key_arg<K> &k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -249,1 +248,1 @@
- key_arg<K> &&k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ key_arg<K> &&k ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -265,1 +264,1 @@
- ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -305,1 +304,1 @@
- key_arg<K> &&key ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ key_arg<K> &&key ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -322,1 +321,1 @@
- const key_arg<K> &key ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ const key_arg<K> &key ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -2428,1 +2428,1 @@
- T&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ T&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -2457,1 +2457,1 @@
- const T& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ const T& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -2477,1 +2477,1 @@
- init_type&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ init_type&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -2499,1 +2499,1 @@
- T&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ T&& value ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
diff --git a/absl/status/statusor.h b/absl/status/statusor.h
--- a/absl/status/statusor.h
+++ b/absl/status/statusor.h
@@ -408,1 +408,1 @@
- StatusOr& operator=(U&& v ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this)) {
+ StatusOr& operator=(U&& v ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS) {
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -604,1 +604,1 @@
- explicit MutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ explicit MutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -619,1 +619,1 @@
- explicit MutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ explicit MutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -646,1 +646,1 @@
- explicit ReaderMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ explicit ReaderMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -655,1 +655,1 @@
- explicit ReaderMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ explicit ReaderMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -682,1 +682,1 @@
- explicit WriterMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this))
+ explicit WriterMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS)
@@ -692,1 +692,1 @@
- explicit WriterMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ explicit WriterMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
@@ -1096,2 +1096,1 @@
- explicit ReleasableMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(
- this)) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
+ explicit ReleasableMutexLock(Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
@@ -1107,1 +1106,1 @@
- Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this),
+ Mutex& mu ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS,
+5
View File
@@ -13,6 +13,7 @@ def _v8_abseil_repository_impl(repository_ctx):
integrity = "sha256-FpL3fRc5us8/lDNxiLeFg88JurfkINLcbFYFpPhnhaE=",
stripPrefix = "abseil-cpp-20250814.1",
)
repository_ctx.patch(repository_ctx.attr.lifetime_capture_patch, strip = 1)
# Our root BUILD must own all sources beneath absl/. Native Starlark
# filesystem operations work on Windows as well; no shell or Python.
@@ -49,6 +50,10 @@ def _v8_abseil_repository_impl(repository_ctx):
v8_abseil_repository = repository_rule(
implementation = _v8_abseil_repository_impl,
attrs = {
"lifetime_capture_patch": attr.label(
default = Label("//third_party/v8:abseil_lifetime_capture.patch"),
allow_single_file = True,
),
"build_file": attr.label(
default = Label("//third_party/v8:abseil.BUILD.bazel"),
allow_single_file = True,
+35 -13
View File
@@ -1,7 +1,8 @@
"""Complete V8 artifact profiles, enforced at the source archive boundary.
The source profile is for local consumers and uses the workspace C++ runtime.
Published profiles embed the pinned Chromium runtime. Generators inherit the
Native Windows builds embed Chromium libc++ with the consumer's stdio ABI.
Other source profiles use the workspace C++ runtime. Published profiles embed
the pinned Chromium runtime. Generators inherit the
V8 target CPU even when their executable is built for the exec platform.
"""
@@ -9,11 +10,16 @@ _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")),
]
_TARGET_OS = "@v8//:v8_target_os"
_MSVC_PROFILE = "@v8//:v8_windows_msvc_profile"
# The published MSVC archives use the Windows SDK's native wide-stdio mode.
# Apply this after clang-cl's default ISO define to the entire archive graph.
_MSVC_NATIVE_STDIO_COPT = "-U_CRT_STDIO_ISO_WIDE_SPECIFIERS"
_COPT = "//command_line_option:copt"
_NOSTDINCXX = "@llvm//config:nostdincxx"
_NOSTDLIBXX = "@llvm//config:nostdlibxx"
_CPU_CONSTRAINTS = {
"arm64": Label("@platforms//cpu:aarch64"),
"x64": Label("@platforms//cpu:x86_64"),
@@ -21,20 +27,28 @@ _CPU_CONSTRAINTS = {
def _artifact_profile_impl(settings, attr):
sandbox = attr.profile != "release"
use_chromium_libcxx = attr.native_windows or attr.profile != "source"
copts = settings[_COPT]
if attr.native_windows and attr.profile != "source":
copts = copts + [_MSVC_NATIVE_STDIO_COPT]
return {
_COPT: copts,
_POINTER_COMPRESSION: "True" if sandbox else "False",
_SANDBOX: sandbox,
_LIBCXX: attr.profile != "source",
_LIBCXX: use_chromium_libcxx,
_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 []),
# Like GN's target_os, these settings survive the exec transition.
# Windows snapshot generators run under Wine on Linux.
_TARGET_OS: attr.target_os,
_MSVC_PROFILE: attr.native_windows,
_NOSTDINCXX: True if use_chromium_libcxx else settings[_NOSTDINCXX],
_NOSTDLIBXX: True if attr.native_windows else settings[_NOSTDLIBXX],
}
_artifact_profile = transition(
implementation = _artifact_profile_impl,
inputs = [_TOOLCHAINS],
outputs = [_POINTER_COMPRESSION, _SANDBOX, _LIBCXX, _TARGET_CPU, _TOOLCHAINS],
inputs = [_COPT, _NOSTDINCXX, _NOSTDLIBXX],
outputs = [_COPT, _POINTER_COMPRESSION, _SANDBOX, _LIBCXX, _TARGET_CPU, _TARGET_OS, _MSVC_PROFILE, _NOSTDINCXX, _NOSTDLIBXX],
)
def _profiled_files_impl(ctx):
@@ -57,6 +71,7 @@ _v8_artifact_files = rule(
doc = "Build a source archive or release pair under its named V8 profile.",
attrs = {
"native_windows": attr.bool(mandatory = True),
"target_os": attr.string(mandatory = True),
"profile": attr.string(
mandatory = True,
values = ["source", "release", "sandbox_release"],
@@ -90,6 +105,13 @@ def v8_artifact_files(name, v8_cpu, **kwargs):
"@rules_rs//rs/platforms/config:x86_64-pc-windows-msvc": True,
"//conditions:default": False,
}),
target_os = select({
"@platforms//os:windows": "win",
"@platforms//os:macos": "mac",
"@platforms//os:linux": "linux",
"@platforms//os:android": "android",
"//conditions:default": "",
}),
v8_cpu = v8_cpu,
**kwargs
)
+19
View File
@@ -0,0 +1,19 @@
"""Apply V8's private runtime policy after a generator's exec transition."""
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@with_cfg.bzl", "with_cfg")
_PRIVATE_RUNTIME = select({
str(Label("//third_party/v8:use_rusty_v8_custom_libcxx")): True,
"//conditions:default": False,
})
# LLVM's flags are target-scoped. V8 generators intentionally share V8's
# private libc++ profile, but unrelated tools must keep their default runtime.
v8_cc_binary, _v8_cc_binary_internal = with_cfg(cc_binary).set(
Label("@llvm//config:nostdincxx"),
_PRIVATE_RUNTIME,
).set(
Label("@llvm//config:nostdlibxx"),
_PRIVATE_RUNTIME,
).build()
+37 -11
View File
@@ -30,6 +30,28 @@ v8_flag(name = "v8_enable_sandbox")
v8_flag(name = "v8_use_rusty_v8_custom_libcxx")
# Generator code executes on the exec platform but emits target-ABI snapshots.
# Match V8 15.2.124.1 BUILD.gn's target_os (not current_os) definitions.
v8_flag(name = "v8_windows_msvc_profile")
v8_string(
name = "v8_target_os",
visibility = ["//visibility:public"],
)
[
config_setting(
name = "v8_target_os_" + os,
flag_values = {":v8_target_os": os},
)
for os in [
"android",
"linux",
"mac",
"win",
]
]
# Maglev is supported on the two architectures shipped by Codex. Keep the
# architecture tests separate from feature policy for host-tool transitions.
selects.config_setting_group(
@@ -130,7 +152,7 @@ v8_config(
] + 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": [
":is_v8_windows_msvc_profile": [
"V8_CPPGC_MICROTASK_QUEUE",
"V8_WASM_RANDOM_FUZZERS",
"V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=0",
@@ -193,26 +215,31 @@ v8_config(
},
no_match_error = "Please specify a target cpu supported by v8",
) + select({
"@v8//bazel/config:is_android": [
":v8_target_os_android": [
"V8_HAVE_TARGET_OS",
"V8_TARGET_OS_ANDROID",
],
"@v8//bazel/config:is_linux": [
":v8_target_os_linux": [
"V8_HAVE_TARGET_OS",
"V8_TARGET_OS_LINUX",
],
"@v8//bazel/config:is_macos": [
":v8_target_os_mac": [
"V8_HAVE_TARGET_OS",
"V8_TARGET_OS_MACOS",
],
"@v8//bazel/config:is_windows": [
":v8_target_os_win": [
"V8_HAVE_TARGET_OS",
"V8_TARGET_OS_WIN",
],
"//conditions:default": [],
}) + select({
"@v8//bazel/config:is_windows": [
"UNICODE",
"_UNICODE",
"_CRT_RAND_S",
"_WIN32_WINNT=0x0A00",
],
"//conditions:default": [],
}) + select({
":is_v8_enable_pointer_compression": [
"V8_COMPRESS_POINTERS",
@@ -301,18 +328,17 @@ alias(
alias(
name = "is_v8_wasm_random_fuzzers",
actual = "@@//third_party/v8:platform_windows_msvc",
actual = ":is_v8_windows_msvc_profile",
)
# @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"],
}),
# Windows x64 ABI and SEH metadata, assembled by @llvm's integrated assembler.
# The existing GAS translation matches the pinned MASM scanner instruction
# for instruction; its syntax is not a dependency on the GNU Windows ABI.
srcs = ["@@//third_party/v8:push_registers_gnullvm.S"],
)
alias(
+1 -1
View File
@@ -1,4 +1,4 @@
"""Select the installed SDK-capable toolchain for native Windows libc++."""
"""Build Windows libc++ with the selected target toolchain and its declared SDK."""
load("@llvm//toolchain/runtimes:cc_runtime_library.bzl", "cc_runtime_stage0_library")
load("@rules_cc//cc:defs.bzl", "cc_library")
+9
View File
@@ -0,0 +1,9 @@
#include <cstdio>
extern "C" bool v8__V8__IsSandboxEnabled();
int main() {
if (!v8__V8__IsSandboxEnabled()) return 1;
std::puts("V8 sandbox enabled");
return 0;
}
+6
View File
@@ -10,6 +10,12 @@
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
@@ -8,4 +8,4 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
-load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
+load("@@//third_party/v8:binary.bzl", cc_binary = "v8_cc_binary")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
@@ -19,7 +19,7 @@
_create_option_flag = rule(
+66
View File
@@ -0,0 +1,66 @@
--- a/orig/v8-15.2.124.1/bazel/defs.bzl
+++ b/mod/v8-15.2.124.1/bazel/defs.bzl
@@ -6,6 +6,7 @@
This module contains helper functions to compile V8.
"""
+load("@@//third_party/v8:windows_snapshot.bzl", "windows_snapshot_rule")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@@//third_party/v8:binary.bzl", cc_binary = "v8_cc_binary")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
@@ -586,8 +587,45 @@
cfg = v8_target_cpu_transition,
)
+
+_v8_windows_mksnapshot = windows_snapshot_rule(v8_target_cpu_transition)
+
+def _platform_mksnapshot(name, args, tool, **kwargs):
+ _v8_mksnapshot(
+ name = name + "_native",
+ args = args,
+ tool = tool,
+ target_compatible_with = select({
+ "@@//third_party/v8:platform_windows_msvc": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
+ **kwargs
+ )
+ _v8_windows_mksnapshot(
+ name = name + "_windows",
+ args = args,
+ tool = tool,
+ inline_asm_converter = kwargs["inline_asm_converter"],
+ platform_arch = select({
+ "@platforms//cpu:aarch64": "aarch64",
+ "@platforms//cpu:x86_64": "x86_64",
+ }),
+ target_arch = select({
+ "@v8//bazel/config:v8_target_arm64": "arm64",
+ "@v8//bazel/config:v8_target_x64": "x64",
+ }),
+ target_compatible_with = ["@platforms//os:windows", "@llvm//constraints/windows/abi:msvc"],
+ )
+ native.alias(
+ name = name,
+ actual = select({
+ "@@//third_party/v8:platform_windows_msvc": ":" + name + "_windows",
+ "//conditions:default": ":" + name + "_native",
+ }),
+ )
+
def v8_mksnapshot(name, args, suffix = ""):
- _v8_mksnapshot(
+ _platform_mksnapshot(
name = "noicu/" + name,
args = args,
prefix = "noicu",
@@ -604,7 +642,7 @@
"//conditions:default": "",
}),
)
- _v8_mksnapshot(
+ _platform_mksnapshot(
name = "icu/" + name,
args = args,
prefix = "icu",
+100
View File
@@ -0,0 +1,100 @@
"""Run a Windows V8 snapshot generator natively or with declared Wine.
V8 15.2's Windows unwind writer is guarded by the generator's host OS. A Linux
generator with V8_TARGET_OS_WIN would silently omit embedded .pdata/.xdata.
The generator's Windows compilation platform is distinct from its executor.
"""
load("@rules_wine//wine:actions.bzl", "windows_actions")
def _windows_generator_platform_impl(settings, attr):
# Preserve the target's build mode, features and V8 profile. Select the
# executable matching the runner only after toolchain resolution. Only
# that executable is an action input; the other variant is not built.
return {
arch: {
# Keep the caller's platform identity when no CPU change is needed.
# Distinct labels with the same platform name can otherwise produce
# conflicting C++ actions under --experimental_platform_in_output_dir.
"//command_line_option:platforms": settings["//command_line_option:platforms"] if arch == attr.platform_arch else [str(Label(platform))],
}
for arch, platform in {
"x86_64": "@llvm//platforms:windows_x86_64_msvc",
"aarch64": "@llvm//platforms:windows_aarch64_msvc",
}.items()
}
_windows_generator_platform = transition(
implementation = _windows_generator_platform_impl,
inputs = ["//command_line_option:platforms"],
outputs = ["//command_line_option:platforms"],
)
def _windows_snapshot_impl(ctx):
runner = windows_actions.resolve(ctx)
# Wine's ARM64 distribution runs x64 generators through FEX. Native
# Windows ARM64 uses an ARM64 generator for ARM64 snapshots; retain an
# x64 generator for x64 snapshots because V8 has no x64 simulator.
native_arm64 = runner.windows.backend == "native" and runner.windows.arch == "aarch64" and ctx.attr.target_arch == "arm64"
generator_arch = "aarch64" if native_arm64 else "x86_64"
generator = ctx.split_attr.tool[generator_arch][DefaultInfo].files_to_run
outputs = [
ctx.actions.declare_file(ctx.label.name + "/snapshot.cc"),
ctx.actions.declare_file(ctx.label.name + "/embedded.S"),
]
args = ctx.actions.args()
args.add_all([
"--embedded_variant=Default",
"--target_os",
"win",
"--target_arch",
ctx.attr.target_arch,
])
args.add("--startup_src")
windows_actions.add_path(runner, args, outputs[0])
args.add("--embedded_src")
windows_actions.add_path(runner, args, outputs[1])
args.add_all(ctx.attr.args)
windows_actions.run(
ctx,
runner = runner,
executable = generator,
arguments = [args],
outputs = outputs,
mnemonic = "V8WindowsSnapshot",
progress_message = "Generating Windows V8 snapshot",
)
# Preserve the existing clang-cl assembly path, including Windows-native
# toolchains that otherwise send generated .S files to MASM.
embedded_cc = ctx.actions.declare_file(ctx.label.name + "/embedded.cc")
ctx.actions.run(
executable = ctx.attr.inline_asm_converter[DefaultInfo].files_to_run,
inputs = [outputs[1]],
outputs = [embedded_cc],
arguments = [outputs[1].path, embedded_cc.path],
mnemonic = "V8NativeWindowsInlineAssembly",
)
return [DefaultInfo(files = depset([outputs[0], embedded_cc]))]
def windows_snapshot_rule(cpu_transition):
"""Preserve V8's target CPU independently of the generator and its runner."""
return rule(
implementation = _windows_snapshot_impl,
cfg = cpu_transition,
attrs = {
"args": attr.string_list(),
"platform_arch": attr.string(mandatory = True, values = ["aarch64", "x86_64"]),
"target_arch": attr.string(mandatory = True, values = ["arm64", "x64"]),
"tool": attr.label(
mandatory = True,
cfg = _windows_generator_platform,
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"inline_asm_converter": attr.label(executable = True, cfg = "exec", mandatory = True),
},
toolchains = [windows_actions.toolchain_type],
)
+10
View File
@@ -157,6 +157,16 @@ toolchain(
visibility = ["//visibility:public"],
)
# Like the pinned Windows CMake, this executable can run under x64 emulation
# on Windows ARM64. Avoid foreign_cc's fallback bootstrap through ambient cl.exe.
toolchain(
name = "windows_ninja_toolchain",
exec_compatible_with = ["@platforms//os:windows"],
toolchain = "@ninja_1.13.0_win//:ninja_tool",
toolchain_type = "@rules_foreign_cc//toolchains:ninja_toolchain",
visibility = ["//visibility:public"],
)
filegroup(
name = "archives",
srcs = [
+11
View File
@@ -294,9 +294,19 @@ class NativeBuild:
for name, flags in self.flags.items()
}
)
languages = {"c": "CFLAGS", "cpp": "CXXFLAGS"}
if self.args.target.endswith("apple-darwin"):
self.environment["OBJC"] = str(self.toolchain["cc"])
self.environment["OBJCFLAGS"] = self.environment["CFLAGS"]
languages["objc"] = "CFLAGS"
# Environment CFLAGS are also linked for Autotools compatibility. Use
# Meson's phase-specific options to preserve Bazel's toolchain contract.
meson_flags = []
for language, variable in languages.items():
meson_flags += [
f"-D{language}_args={json.dumps([*self.flags[variable], include])}",
f"-D{language}_link_args={json.dumps([*self.flags['LDFLAGS'], *link])}",
]
self.run(
name + "-configure",
[
@@ -311,6 +321,7 @@ class NativeBuild:
"-Dauto_features=disabled",
"-Ddefault_library=shared",
"-Dpkgconfig.relocatable=true",
*meson_flags,
*options,
],
)
+2 -2
View File
@@ -42,8 +42,8 @@ runs:
if [[ "$RUNNER_OS" == Windows ]]; then
wrapper+=(--windows-msvc-host-platform)
flags+=(--platforms=//:local_windows_msvc
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows,@local_config_cc//:cc-toolchain-arm64_windows,//third_party/voice:windows_pkg_config_toolchain,//third_party/voice:windows_cmake_toolchain
--repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0 --repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1
--extra_toolchains=//third_party/voice:windows_pkg_config_toolchain,//third_party/voice:windows_cmake_toolchain
--repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1
--inject_repository="voice_windows_tools=$VOICE_WINDOWS_BAZEL_REPOSITORY"
--//third_party/voice:windows_installed_tools=@voice_windows_tools//:tools
--action_env="SystemRoot=$VOICE_WINDOWS_SYSTEM_ROOT" --host_action_env="SystemRoot=$VOICE_WINDOWS_SYSTEM_ROOT"
+6
View File
@@ -11,4 +11,10 @@ else()
set(CMAKE_SYSTEM_NAME Linux)
endif()
string(REGEX REPLACE "-.*" "" CMAKE_SYSTEM_PROCESSOR "$ENV{TARGET}")
if("$ENV{TARGET}" STREQUAL "aarch64-pc-windows-msvc")
# NEON is guaranteed on Windows ARM64. Opus's optional runtime probe emits
# ARM32 instructions through MSVC's __emit, which clang-cl does not support.
set(OPUS_PRESUME_NEON ON CACHE BOOL "" FORCE)
set(OPUS_MAY_HAVE_NEON OFF CACHE BOOL "" FORCE)
endif()
# Compiler, SDK and linker inputs remain supplied by Bazel's target toolchain.
+5 -5
View File
@@ -33,12 +33,12 @@
},
{
"name": "pcre2",
"version": "10.47",
"version": "10.48",
"role": "native-library",
"archive": "pcre2-10.47.tar",
"root": "pcre2-10.47",
"url": "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.47/pcre2-10.47.tar.gz",
"sha256": "c08ae2388ef333e8403e670ad70c0a11f1eed021fd88308d7e02f596fcd9dc16",
"archive": "pcre2-10.48.tar",
"root": "pcre2-10.48",
"url": "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.48/pcre2-10.48.tar.gz",
"sha256": "ebcc25aadf2a51fa1fefa9b8bc9e7a79b3dae86870a0f1152a22e42befd46888",
"provenance": "GitHub release asset digest"
},
{