Skip to content

rust: strip the execroot from clang-cl build-script C objects on Windows (part of #14231) - #14574

Draft
TrapsterDK wants to merge 2 commits into
mainfrom
cloud/14231
Draft

TrapsterDK wants to merge 2 commits into
mainfrom
cloud/14231

Conversation

@TrapsterDK

@TrapsterDK TrapsterDK commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #14231.

On Windows, DX_BS_CFLAGS was empty for every MSVC target. So the C objects that cc-rs builds in Rust build scripts (tree-sitter, tree-sitter-ocaml) kept absolute execroot paths, and their CargoBuildScriptRun outputs differed between output bases (evidence run 44824310234).

  • rust/private/build_script_cc_env.bzl: new build_script_cflags(msvc, clang_cl, coverage). It passes /clang:-ffile-prefix-map=${pwd}=. when the target C compiler is clang-cl, and nothing to cl.exe. Coverage still adds /U_CRT_STDIO_ISO_WIDE_SPECIFIERS. Linux and macOS flags are unchanged.
  • rust/tests/defs_tests.bzl: checks the four flag cases.
  • .github/workflows/evidence.yml: relocate=true task=build passes cygpath -w Bazel to determinism_check on Windows, the same change as in release-tools: run the tools determinism check on every host (part of #14231) #14269, so the Windows evidence below can run.
  • tools/testing/determinism_check.rs: new --keep <dir> copies every differing output of both builds to <dir>/first and <dir>/second. evidence.yml passes --keep "$RUNNER_TEMP/evidence/determinism", so the artifact holds the two _bs.out_dir trees. Evidence run 44951983531 still showed the tree-sitter out_dir diffs, and these trees are needed to find which file differs. .github/workflows/README.md documents it.

The toolchain's target CFLAGS already carry /Brepro and /clang:-gno-codeview-command-line (Windows cross aquery of @dx_quality_crates//:tree-sitter-ocaml), so object timestamps and the CodeView command line are ruled out.

Not in this PR: the Windows Rust link (PDB temp dir and output base) and the macOS topiary diff. Both are still open on #14231, so the Windows determinism run will still list the Rustc link actions.

Tested: //rust/tests:wrapper_registry_tests, //tools/testing:determinism_check_test, //tools/ci:evidence_inputs_test, //tools/ci:workflow_files_test passed; @dx_quality_crates//:tree-sitter-ocaml builds on Linux. tools/dx check --apply on the touched files: format clean. The only lint findings are on older lines of determinism_check.rs (indexing_slicing and map_err_ignore in parse_shard, label_kinds and entry_points). Windows evidence with --keep is requested below. The PR stays draft until the out_dir diff is understood.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hzcDgHHKbaNne5nvNy

Copy link
Copy Markdown
Collaborator Author

/evidence platforms=["windows_x86_64"] task=build relocate=true scope=//rust/private/quality/tools:topiary


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Evidence started on cloud/14231: https://github.com/devhusdk/rules_dx/actions/runs/44951983531

@TrapsterDK
TrapsterDK marked this pull request as ready for review November 21, 2026 21:33
@TrapsterDK TrapsterDK added the train Tested; land via merge train label Nov 21, 2026 — with Claude
@TrapsterDK
TrapsterDK marked this pull request as draft November 21, 2026 21:48
@TrapsterDK TrapsterDK removed the train Tested; land via merge train label Nov 21, 2026 — with Claude

Copy link
Copy Markdown
Collaborator Author

Evidence run 44951983531 (windows_x86_64, topiary, relocate=true task=build): 42 actions differ. They include the CargoBuildScriptRun _bs.out_dir of tree-sitter-0.26.12 and tree-sitter-ocaml-0.24.0, so the prefix map alone does not make those outputs match. The rest are Rustc .exe/.pdb/.dll/.rlib links (cause 1 on #14231). Possible causes: the out_dir differs in the archive step (llvm-lib without /Brepro), or in a file the build script writes other than the objects. Finding which file differs needs the two out_dir trees from determinism_check diff. Back to draft and off the train until a run shows the out_dir lines gone.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

CI on this draft is red in analysis (main's stale dx_crates lock digest) and in many affected tests shards. The shards run because the change to rust/private/build_script_cc_env.bzl reaches most targets; shard 0 fails in //core/modules:consumer_deps_test, which is red on main. Draft until the Windows out_dir diff is understood, as said above.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

/evidence platforms=["windows_x86_64"] task=build relocate=true scope=//rust/private/quality/tools:topiary


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

cc-rs objects built by Rust build scripts on Windows kept absolute
execroot paths, because DX_BS_CFLAGS was empty for every MSVC target.
When the C compiler is clang-cl, pass -ffile-prefix-map through /clang:.
cl.exe still gets no flag. evidence.yml passes Bazel's Windows path to
determinism_check so the Windows determinism evidence can run.

Part of #14231.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hzcDgHHKbaNne5nvNy
--keep <dir> copies each output whose digest differs from both output
bases' exec roots, so a run on a host we cannot reach (macOS, Windows)
shows which file differs. evidence.yml keeps them in the artifact under
determinism/.

Part of #14231.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hyWgXAuKZTkQf9BoEE
@TrapsterDK

Copy link
Copy Markdown
Collaborator Author

Rebased onto main 5bf6454. Conflict in build_script_cc_env.bzl with #14439's DX_BS_CXXFLAGS: both now come from build_script_cflags, so clang-cl C++ objects get the prefix map too. wrapper_registry_tests, determinism_check_test, evidence_inputs_test, workflow_files_test pass; @dx_quality_crates//:tree-sitter-ocaml builds on Linux.

The --keep artifact of run 45011256334 explains the out_dir diff. Header and source paths are now relative, so the prefix map works. Two absolute paths remain:

  1. In every .o, the CodeView S_OBJNAME record: D:\a\_temp\determinism\first\base\execroot\_main\bazel-out\...\_bs.out_dir\f4c771d9ba52b3b4-scanner.o. -ffile-prefix-map doesn't remap it. clang's -object-file-name= sets it.
  2. In tree-sitter-ocaml.lib/.a, the archive member names: D:\a\...\_main\bazel-out/x64_windows-.../_bs.out_dir\<hash>-parser.o. llvm-lib stores the path cc-rs passes, and cc-rs passes absolute OUT_DIR paths.

Fixing (2) takes an archiver step that gets relative member names. That is new work, so this PR stays draft.

🤖 Generated with Claude Code

TrapsterDK commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Shards 4, 5 and 25 on 097ec70 fail only tests that also fail on main:

  • Shards 4 and 5: consumer_deps_test, loaders_test, versions_contract and config:workspace_policy.
  • Shard 25: apple_consumer_test, dart_consumer_test, root_module_test and //tools/docs/typescript/extract:dx_docs_typescript_extract_test.

I ran dx_docs_typescript_extract_test locally both at this head and at merge base 7877817. Both runs fail the same case, lib_tests::run_writes_a_valid_shard_and_reports_file_errors, with 20 passed and 1 failed.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Shard 3 on 097ec70 fails only //cli/adopt:dx_adopt_test. That test fails on main too: at merge base 7877817 it fails the case scaffold::tests::go_files_get_the_gopls_tier_view (493 passed, 1 failed), as checked on #14589.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Shard 26 on 097ec70 fails dx_nested_test, language_skeleton_test and module_extension_srcs_test. All three are recurring failures on main; this run didn't recheck them at the merge base.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Shard 14 on 097ec70 fails only //elixir/tests/conformance:coverage_test, a recurring failure on main that also fails on #14589.


Generated by Claude Code

TrapsterDK commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Shard 24 on 097ec70 hit its 1380s budget, with 32 of 150 tests run. One test failed: //tools/docs/languages:languages_test. It fails the same way at merge base 7877817: generated docs/languages/{android,apple,cc,java,scala,zig}.md are out of date on main. I haven't checked whether the timeout comes from this PR's build-script flag change, for example through cache misses on Linux build scripts. The PR stays draft for the Windows archive paths either way.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Shard 15 on 097ec70 also hit its 1380s budget: 29 of 150 tests ran, all passed. Shards 15 and 24 both timing out here, while #14589's shard 15 finished on the same base, points at this PR. The build_script_cc_env.bzl change probably reruns every Rust build script and their dependents without a cache. Before this leaves draft, either confirm that one CI run warms the cache, or keep Linux DX_BS_CFLAGS/DX_BS_CXXFLAGS byte-identical to main so only clang-cl actions change.


Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants