You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
quality: clang-tidy on MSVC actions runs without the MSYS no-conversion env, so bash rewrites /I and /D flags into paths #8733
P1Bugs in existing featuresmodel:sonnetAgent lane: scoped change with stated design, Sonnetneeds-hostNeeds macOS, Windows, GPU, or signing secrets; not doable on Linux
On Windows, MSYS bash rewrites arguments that start with / into paths when it starts a native exe. #7047 fixed this for the cl.exe syntax replay only, by adding _MSYS_NO_CONVERSION to its env. The ClangTidy action for the same compile action still uses plain action.env.
The tidy argv goes through bash: bash "$@" runs clang_tidy_run.sh, which runs clang-tidy.exe. _msvc_tidy_argv puts the cl flags after -- (/nologo, /DX=1, /I..., /std:c++17). They get rewritten the same way, so /DCOMPILER_MSVC becomes something like C:/msys64/DCOMPILER_MSVC.
Scenario: a cc_library built with --//cc/toolchains:compiler=msvc (cl.exe) on windows_x86_64 has a dep header or a /D define and is linted with clang_tidy. The fixed compilation database treats the rewritten args as input files, so the include dirs and defines are lost. The run reports 'dep.h' file not found / clang-diagnostic-error instead of the real findings. clang_tidy_run.sh always exits 0, so these bogus diagnostics are parsed as findings.
Where
quality/clang_syntax.bzl:36: _MSYS_NO_CONVERSION is defined.
quality/clang_syntax.bzl:362-364: syntax_env gets _MSYS_NO_CONVERSION for the msvc driver. Only ClangSyntax uses it (line 373).
quality/clang_syntax.bzl:380-391: the ClangTidy run_shell passes env = action.env (line 388).
quality/clang_syntax.bzl:133-155: _msvc_tidy_argv puts the /-style flags after --.
quality/clang_tidy_run.sh:20: runs clang-tidy.exe from bash with no conversion guard.
Pass syntax_env as env to the ClangTidy run_shell at quality/clang_syntax.bzl:388. It already includes _MSYS_NO_CONVERSION for the msvc driver.
Add a real_result_clang_tidy_cc_msvc_* case next to _msvc_case. It should use cl.exe, include a dep header and set a /D define, and assert a real finding with no file not found.
Size: S. Risk: low (only the env of the msvc ClangTidy action changes; ClangSyntax already uses the same env).
Confirmed at HEAD f404f79. quality/clang_syntax.bzl:362-364 builds syntax_env with _MSYS_NO_CONVERSION for identity.driver == "msvc". ClangSyntax uses it (:373). The ClangTidy run_shell at :381-391 still passes env = action.env (:388). _msvc_tidy_argv (:131-155) puts /nologo, /D..., /I... after --. The unit test at quality/clang_syntax_tests.bzl:118-121 shows that argv.
Chosen: reuse one env helper for both msvc actions. Rejected: export the MSYS vars inside clang_tidy_run.sh. Too late, because the outer bash "$@" has already started. It would also put Windows logic into the shared runner.
Steps
quality/clang_syntax.bzl: add a public clang_action_env(env, driver). It returns a copy of env, plus _MSYS_NO_CONVERSION when the driver is "msvc". The docstring is one line.
quality/clang_syntax.bzl:_clang_syntax_impl: set syntax_env = clang_action_env(action.env, identity.driver). Pass env = syntax_env to the ClangTidy run_shell at :388. Leave envs.append(dict(action.env)) (:394) and the CUDA tidy env (:339) as they are.
quality/testdata/clang_syntax/tidy_dirty.c and its BUILD.bazel:82-88: add local_defines = ["TIDY_DEFINE=1"]. Guard the file with #ifndef TIDY_DEFINE / #error. cl renders this as /DTIDY_DEFINE=1. The file already includes dep.h, which needs /I.
quality/testdata/real_result_cases.bzl:44-49: let _msvc_case take tool, capability, policy (default to clang_syntax). Build the name as real_result_<tool>_cc_msvc_<name> and update the two existing calls. Add:
clang_tidy "clean" on clean: contains clean.c; absent readability-else-after-return, file not found, clang-diagnostic-error.
clang_tidy "dirty" on tidy_dirty: contains readability-else-after-return; absent file not found, clang-diagnostic-error, TIDY_DEFINE.
Steps 1-2 come first. Step 3 can run alongside them. Step 4 depends on step 3.
Tests
quality/clang_syntax_tests.bzl (//quality:clang_syntax_unit): clang_action_env({"A":"1"}, "msvc") -> A plus the 3 MSYS keys. clang_action_env({"A":"1"}, "gcc") -> {"A":"1"}.
The real-result cases from step 4. They are tagged windows_x86_64 only. Make sure the existing _cc_case/_gcc_case tidy_dirty cases still pass with the new define.
Verify
tools/dx test //quality:clang_syntax_unit
tools/dx test //quality/testdata:real_result_clang_tidy_cc_dirty //quality/testdata:real_result_clang_tidy_cc_gcc_clean
On a Windows x86_64 host with cl.exe: tools/dx test //quality/testdata:real_result_clang_tidy_cc_msvc_dirty //quality/testdata:real_result_clang_tidy_cc_msvc_clean //quality/testdata:real_result_clang_syntax_cc_msvc_dirty
tools/dx check --apply --affected, tools/dx test --affected, tools/dx check --affected
Notes
Needs a Windows x86_64 host. Before the fix, the msvc dirty case should fail with file not found. Run it once without the fix to confirm.
No docs change is needed. This is a bug fix and documented behaviour does not change. No upstream issue, since MSYS conversion is documented behaviour.
Possible follow-up, not part of this PR: the CUDA tidy path (:339) on Windows. It has no / flags today because an MSVC -ccbin is rejected.
Fixed by #8853 (merged as b2532b5). Windows evidence runs 42307832913 (repro) and 42307836687 (fix) both failed before the tests ran, on an unrelated package load error: @@+haskell+dx_ghc_windows_x86_64 cannot load @@rules_cc+//cc:cc_toolchain.bzl. I dispatched a new msvc verification run from main: 42309468960.
Verification run 42309468960 (evidence.yml, ref main, windows_x86_64, --//cc/toolchains:compiler=msvc) failed again before any test ran, with the same package load error: error loading package '@@+haskell+dx_ghc_windows_x86_64//': cannot load '@@rules_cc+//cc:cc_toolchain.bzl': no such file (preceded by at index 0 of provides, got element of type NoneType, want Provider). This is an infra problem with the Haskell Windows toolchain on main and has nothing to do with #8733. The fix stays as merged in #8853 (b2532b5). The msvc clang_tidy/clang_syntax real_result targets still need a green Windows run once the Haskell load error is fixed.
Run 42323331884 got past the Haskell load error (#8976). The msvc clang_tidy cases then failed with unexpected: file: Bazel shell-tokenizes sh_test args, so the absent string file not found was split into separate words. The fix is in the new PR on branch real-result-args-quote-8733. Windows msvc evidence: run 42325679242.
Run 42325967780: real_result_clang_syntax_cc_msvc_dirty and real_result_check_spaces_test PASS. real_result_clang_tidy_cc_msvc_dirty and real_result_clang_tidy_cc_msvc_clean FAIL with unexpected: file not found.
Remaining: the checker now matches the whole string, so clang-tidy under msvc really reports a missing include. Next step: read the msvc tidy test.log for the missing header and check include/sysroot handling in quality/clang_syntax.bzl (_msvc_tidy_argv, #8853).
Evidence for #9012 (merged): run 42329489267 (evidence.yml, windows_x86_64, --//cc/toolchains:compiler=msvc). real_result_clang_tidy_cc_msvc_dirty and real_result_clang_tidy_cc_msvc_clean passed.
P1Bugs in existing featuresmodel:sonnetAgent lane: scoped change with stated design, Sonnetneeds-hostNeeds macOS, Windows, GPU, or signing secrets; not doable on Linux
Activity
TrapsterDK commentedon Nov 6, 2026
Plan
Size: S. Risk: low (only the env of the msvc ClangTidy action changes; ClangSyntax already uses the same env).
Confirmed at HEAD f404f79.
quality/clang_syntax.bzl:362-364buildssyntax_envwith_MSYS_NO_CONVERSIONforidentity.driver == "msvc". ClangSyntax uses it (:373). The ClangTidyrun_shellat :381-391 still passesenv = action.env(:388)._msvc_tidy_argv(:131-155) puts/nologo,/D...,/I...after--. The unit test atquality/clang_syntax_tests.bzl:118-121shows that argv.Chosen: reuse one env helper for both msvc actions. Rejected: export the MSYS vars inside
clang_tidy_run.sh. Too late, because the outerbash "$@"has already started. It would also put Windows logic into the shared runner.Steps
quality/clang_syntax.bzl: add a publicclang_action_env(env, driver). It returns a copy ofenv, plus_MSYS_NO_CONVERSIONwhen the driver is"msvc". The docstring is one line.quality/clang_syntax.bzl:_clang_syntax_impl: setsyntax_env = clang_action_env(action.env, identity.driver). Passenv = syntax_envto the ClangTidyrun_shellat :388. Leaveenvs.append(dict(action.env))(:394) and the CUDA tidy env (:339) as they are.quality/testdata/clang_syntax/tidy_dirty.cand itsBUILD.bazel:82-88: addlocal_defines = ["TIDY_DEFINE=1"]. Guard the file with#ifndef TIDY_DEFINE/#error. cl renders this as/DTIDY_DEFINE=1. The file already includesdep.h, which needs/I.quality/testdata/real_result_cases.bzl:44-49: let_msvc_casetaketool, capability, policy(default to clang_syntax). Build the name asreal_result_<tool>_cc_msvc_<name>and update the two existing calls. Add:clang_tidy"clean" onclean: containsclean.c; absentreadability-else-after-return,file not found,clang-diagnostic-error.clang_tidy"dirty" ontidy_dirty: containsreadability-else-after-return; absentfile not found,clang-diagnostic-error,TIDY_DEFINE.Steps 1-2 come first. Step 3 can run alongside them. Step 4 depends on step 3.
Tests
quality/clang_syntax_tests.bzl(//quality:clang_syntax_unit):clang_action_env({"A":"1"}, "msvc")-> A plus the 3 MSYS keys.clang_action_env({"A":"1"}, "gcc")->{"A":"1"}._cc_case/_gcc_casetidy_dirty cases still pass with the new define.Verify
tools/dx test //quality:clang_syntax_unittools/dx test //quality/testdata:real_result_clang_tidy_cc_dirty //quality/testdata:real_result_clang_tidy_cc_gcc_cleantools/dx test //quality/testdata:real_result_clang_tidy_cc_msvc_dirty //quality/testdata:real_result_clang_tidy_cc_msvc_clean //quality/testdata:real_result_clang_syntax_cc_msvc_dirtytools/dx check --apply --affected,tools/dx test --affected,tools/dx check --affectedNotes
file not found. Run it once without the fix to confirm./flags today because an MSVC-ccbinis rejected.TrapsterDK commentedon Nov 6, 2026
Fixed by #8853 (merged as b2532b5). Windows evidence runs 42307832913 (repro) and 42307836687 (fix) both failed before the tests ran, on an unrelated package load error:
@@+haskell+dx_ghc_windows_x86_64cannot load@@rules_cc+//cc:cc_toolchain.bzl. I dispatched a new msvc verification run from main: 42309468960.TrapsterDK commentedon Nov 6, 2026
Verification run 42309468960 (evidence.yml, ref main, windows_x86_64, --//cc/toolchains:compiler=msvc) failed again before any test ran, with the same package load error:
error loading package '@@+haskell+dx_ghc_windows_x86_64//': cannot load '@@rules_cc+//cc:cc_toolchain.bzl': no such file(preceded byat index 0 of provides, got element of type NoneType, want Provider). This is an infra problem with the Haskell Windows toolchain on main and has nothing to do with #8733. The fix stays as merged in #8853 (b2532b5). The msvc clang_tidy/clang_syntax real_result targets still need a green Windows run once the Haskell load error is fixed.Assisted by Claude.
TrapsterDK commentedon Nov 7, 2026
Windows msvc evidence run for the Haskell mingw load fix (PR #8976): 42323331884. Upstream rules_haskell issue tweag/rules_haskell#2483 and PR tweag/rules_haskell#2484.
Assisted by Claude.
TrapsterDK commentedon Nov 7, 2026
Run 42323331884 got past the Haskell load error (#8976). The msvc clang_tidy cases then failed with
unexpected: file: Bazel shell-tokenizes sh_test args, so the absent stringfile not foundwas split into separate words. The fix is in the new PR on branch real-result-args-quote-8733. Windows msvc evidence: run 42325679242.Assisted by Claude.
lock: refresh windows_support and qt_sdk extension digests (part of #…
quality: quote real_result_test args so strings with spaces stay whol…
TrapsterDK commentedon Nov 7, 2026
PR #8996 (merged) fixed real_result_test arg quoting and refreshed the stale windows_support/qt_sdk lockfile digests.
Evidence, windows_x86_64 with
--//cc/toolchains:compiler=msvc:unexpected: file not found.Remaining: the checker now matches the whole string, so clang-tidy under msvc really reports a missing include. Next step: read the msvc tidy test.log for the missing header and check include/sysroot handling in quality/clang_syntax.bzl (_msvc_tidy_argv, #8853).
Assisted by Claude.
quality: pass --driver-mode=cl after -- for msvc clang-tidy (part of #…
TrapsterDK commentedon Nov 7, 2026
Evidence for #9012 (merged): run 42329489267 (evidence.yml, windows_x86_64, --//cc/toolchains:compiler=msvc). real_result_clang_tidy_cc_msvc_dirty and real_result_clang_tidy_cc_msvc_clean passed.