Skip to content

fix: Mitigate the -L dependency= consolidation races on Windows under cc_common.link - #82

Merged
dzbarsky merged 1 commit into
hermeticbuild:mainfrom
ArchangelX360:archangelx360/races
Oct 5, 2026
Merged

dzbarsky merged 1 commit into
hermeticbuild:mainfrom
ArchangelX360:archangelx360/races

Conversation

@ArchangelX360

Copy link
Copy Markdown
Member

Keep .a files out of the unified dependency directory of the Windows process wrapper.

On Windows, process_wrapper merges every -Ldependency= directory into one, to keep the command line short. It scans each directory with read_dir, so it also sees files that are no input of the action. rules_rust puts a lib<name>.a symlink next to each rlib, for cc_common.link. With experimental_use_cc_common_link, Bazel builds those symlinks while sibling Rustc actions scan the directory, and the copy fails with "Access is denied".

-L dependency= only searches for crates, and no crate is a .a file, so skip the extension.

Relates to #48

… `cc_common.link`

Keep `.a` files out of the unified dependency directory of the Windows process wrapper.

On Windows, `process_wrapper` merges every `-Ldependency=` directory into one, to keep the command line short. It scans each directory with `read_dir`, so it also sees files that are no input of the action. `rules_rust` puts a `lib<name>.a` symlink next to each rlib, for `cc_common.link`. With `experimental_use_cc_common_link`, Bazel builds those symlinks while sibling `Rustc` actions scan the directory, and the copy fails with "Access is denied".

`-L dependency=` only searches for crates, and no crate is a `.a` file, so skip the extension.

Relates to hermeticbuild#48
@dzbarsky
dzbarsky merged commit e51ad65 into hermeticbuild:main Oct 5, 2026
0 of 3 checks passed
intellij-monorepo-bot pushed a commit to JetBrains/intellij-community that referenced this pull request Oct 21, 2026
Both Bazel roots move from rules_rs 0.0.112 to 0.1.3, the newest release.
`BazelProjectStructureTest` requires the same version, override and patch set in
each root.

# The pin is an archive, not a registry entry

0.1.3 is not in the Bazel Central Registry yet. The entry is in review:
bazelbuild/bazel-central-registry#11208. So each root
takes an `archive_override` on the GitHub release, in place of the
`single_version_override`. The override holds the same patch list. rules_kotlin
already uses an `archive_override` in both roots, so the pattern is known here.
`bazel_downloader.cfg` allows github.com and rewrites it to the cache
redirector.

Go back to `single_version_override` once the registry entry lands. A TODO at
each override says so.

# One patch goes

rules_rs 0.1.3 pins rules_rust a20387a3b3e7baec859b53f3cb15b026fbc8a423, up from
fd521efe16c03e4cd169453eb44fb98d73ebb7aa. That commit holds
hermeticbuild/rules_rust#82, so
rules_rust-process-wrapper-skip-static-lib-symlinks.patch is dead. `a` is out of
`CRATE_SEARCH_ARTIFACT_EXTENSIONS` upstream, and the test moves `libfoo.a` to
the negative list. The patch goes, and the `rules_rust.patch` tag drops it.

# Five patches stay

Each one still applies to the new sources without fuzz, and no upstream version
of the change exists:

- rules_rs-*-github-crate-tarball.patch: 0.1.3 has no `allow_git` attribute.
  hermeticbuild/rules_rs#247 is open.
- rules_rs-*-bootstrap-toolchain-type.patch and
  rules_rust-bootstrap-toolchain-type.patch: the pinned rules_rust has no
  `@rules_rust//rust:bootstrap_toolchain_type`.
- rules_rust-msvc-crt-transition.patch and
  rules_rust-msvc-rustc-link-through-lld-link.patch: unchanged upstream.

The two rules_rs patch files take the new version in their name. The rules_rust
patch files keep their names, because the name holds no version.

# Verification

- `bazel mod deps --lockfile_mode=update` in both roots.
- `bazel build @rules_rust//util/process_wrapper:process_wrapper`, which uses
  the bootstrap toolchain of both bootstrap patches.
- `bazel build //tools/bt/... //tools/vm/... //build/rust-tools/...` in
  community, and `//build/dev-dist-tools/...` in the root.
- Analysis of `//fleet/native/...`, `//toolbox/app/bazel/launcher/...`,
  `//language-server/native/...` and `//build/native/...`.
- `bazel run //:format.check`.
- `BazelProjectStructureTest`, 9 tests.

A Windows and a macOS build are not verified here. The container runs Linux.

M-Session-Id: A-1849b79d-f20c-4519-9ea5-f7cc052de2f6

GitOrigin-RevId: 04cb2a18844650742f85644a7610b04144291693
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