← Back to Pull requests

bazel: Windows resource compiler from the toolchain, not PATH #4039

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 17, 2026 22:53 UTC
Author

Summary

cc_dynamic_lib (Windows, with rc_file)
  _compile_windows_resource
    rc tool      <- rc_toolchain_type, set at configure time
                    clang-cl: llvm-rc
                    icx, MSVC cl: rc.exe
    env          <- cc_common.get_environment_variables(cpp_compile)
    run          the rc tool directly (no cmd.exe, no use_default_shell_env)

 ALLOWED = {
     ("use_default_shell_env", "dev/bazel/release.bzl", "_copy"): (...),
-    ("use_default_shell_env", "dev/bazel/cc.bzl", "_compile_windows_resource"): (...),
 }

  • New dev/bazel/toolchains/rc_toolchain.bzl: the rc_toolchain rule and RC_TOOLCHAIN_TYPE. The Windows toolchain repository registers one rc_toolchain_win per LLVM and MSVC template, next to the cc toolchain. Linux registers none, and cc_dynamic_lib declares the type optional.

  • cc_toolchain_win.bzl: _find_resource_compiler finds the tool with find_tool(mandatory = False); the tool is an input of the tool identity on the LLVM path.

  • cc.bzl: the cmd.exe call is gone; the env is the toolchain's compile env, as the archive merge in cc/link.bzl.

  • TODO.md and AGENTS.md: the remaining use_default_shell_env site is release.bzl's copy.
  • Evidence

  • Before: python3 dev/bazel/tests/check_starlark_policy.py . on bazel-hermetic-fixes reports OK (2 allowed site(s)).

  • After: the same command on this branch reports OK (1 allowed site(s)).
  • Linux (analysis and host tests): bazel test //dev/bazel/tests:all: 19 of 19 pass. bazel test --config=host //cpp/oneapi/dal/algo/pca:tests: 7 of 7 pass. The .bzl loads on Linux, so config_common.toolchain_type and the optional type resolve there.

  • Windows: not run locally; the PR's CI is the check (clang-cl, icx and cl resource builds).

  • Windows, same patch on an earlier head: Azure build 66254 (CI (WindowsBazel) on 27bbdbe31, passed) compiled dll.rc and onedal_dll.rc in its release step, with rc.exe getting the same env as now (no SystemRoot or TEMP passthrough): Build completed successfully, 6732 total actions.
  • Merge Danger

    Door: two-way. The change is revertable and writes no persisted format.

    The rc tool is now resolved from the configure-time PATH and passed as an absolute path, the same way as the archiver. A target with rc_file fails at analysis when no resource compiler is found.

    Blast Radius: Windows builds of DLLs that link a version resource.

    Ramifications:

  • The rc action no longer inherits the full shell environment (SYSTEMROOT, TEMP and TMP are not passed). If rc.exe or llvm-rc needs one of them, the Windows CI shows it and the fix is one more variable in the action env.

  • Arguments reach the tool directly, not through cmd.exe, so rc_defines and include paths with spaces or cmd metacharacters are no longer re-parsed.

  • llvm-rc is looked up in the clang-cl toolchain directory and then on PATH, as the other LLVM tools are; with neither, a target with rc_file fails at analysis.

  • Empty INCLUDE at configure time fails at analysis for a target with rc_file, instead of rc.exe failing on windows.h.
  • 🤖 Generated with Claude Code

    ---

    <details>
    <summary>Checklist:</summary>

    Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.

  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary. (dev/bazel/TODO.md, dev/bazel/AGENTS.md)

  • Git commit message contains an appropriate signed-off-by string.

  • I have resolved any merge conflicts that might occur with the base branch. (Rebased onto origin/main f0b5f38d6; no conflicts. Re-checked against origin/main b63dcd536: merges clean.)
  • Testing

  • I have run it locally and tested the changes extensively. (Linux: bazel test //dev/bazel/tests:all on head 98fd425ac: 19 of 19 pass, exit 0, run for this update. Windows: the Azure CI (WindowsBazel) run on this head, build 66416, passed, with CI (WindowsMakeVC) in the same build.)

  • All CI jobs are green or I have provided justification why they aren't. (Every completed check is success or neutral. The GitHub Windows Bazel jobs are skipped on pull_request by their if:; Azure CI (WindowsBazel) is green.)

  • I have extended testing suite if new functionality was introduced in this PR. (n/a: the rc_toolchain rule and the resource action are reached only through a Windows cc toolchain. _compile_windows_resource runs after _init_cc_rule resolves the cc toolchain, and Linux registers no Windows cc toolchain, so an analysis test on Linux cannot reach the resource tool choice or the empty-INCLUDE failure. The Windows build above covers that path.)
  • Performance

  • I have measured performance for affected algorithms using scikit-learn_bench and provided at least a summary table with measured data, if performance change is expected. (n/a: no performance change expected.)

  • I have provided justification why performance and/or quality metrics have changed or why changes are not expected. (Not expected: build rules and toolchain configuration only; no kernel or runtime code changed.)

  • I have extended the benchmarking suite and provided a corresponding scikit-learn_bench PR if new measurable functionality was introduced in this PR. (n/a: none introduced.)
  • </details>

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: Alexandr-Solovev Review duration: 7041m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4039"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%