Files
codex/patches/rules_rust_windows_execroot_separators.patch
T
zbarsky-openai 1099fe0694 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
2026-11-10 03:02:25 +00:00

56 lines
2.2 KiB
Diff

--- a/cargo/private/cargo_build_script_runner/lib.rs
+++ b/cargo/private/cargo_build_script_runner/lib.rs
@@ -377,14 +377,23 @@
return "${pwd}".to_owned();
}
- value
+ let redacted = value
.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.
+ let root = exec_root.replace('\\', "/");
+ redacted
+ .replace(&format!("{root}/"), "${pwd}/")
+ .replace(&format!("{root}\\"), "${pwd}\\")
+ };
+ redacted
}
/// Redact for env vars: uses the generic `${out_dir}` token, resolved
@@ -736,6 +745,26 @@
cdylib_link_flags: "".to_owned(),
bin_link_flags: "".to_owned(),
}
+ );
+ }
+
+ #[cfg(windows)]
+ #[test]
+ fn windows_include_metadata_redacts_both_root_spellings() {
+ 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"
+ ))];
+ assert_eq!(
+ BuildScriptOutput::outputs_to_dep_env(&outputs, "glib", root),
+ format!("DEP_GLIB_INCLUDE=${{pwd}}/include;${{pwd}}\\lib;{forward}-other/include")
+ );
+ let outputs = vec![BuildScriptOutput::DepEnv(format!("INCLUDE={forward}/."))];
+ assert_eq!(
+ BuildScriptOutput::nonhermetic_absolute_paths(&outputs, root, ""),
+ Vec::<String>::new()
);
}