From dae81328c06f34d4ad031b6ce1c0e53aa1830e35 Mon Sep 17 00:00:00 2001 From: Titouan Bion Date: Mon, 5 Oct 2026 15:48:14 +0200 Subject: [PATCH] fix: Mitigate the -L dependency= consolidation races on Windows under `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.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 https://github.com/hermeticbuild/rules_rust/pull/48 --- util/process_wrapper/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/process_wrapper/main.rs b/util/process_wrapper/main.rs index d4a4d49900..f6a9b786e4 100644 --- a/util/process_wrapper/main.rs +++ b/util/process_wrapper/main.rs @@ -102,7 +102,7 @@ impl TemporaryDirectoryGuard { /// Matching on what rustc can actually use within a given `-Ldependency=` directory #[cfg(any(windows, test))] const CRATE_SEARCH_ARTIFACT_EXTENSIONS: &[&str] = - &["rlib", "rmeta", "dll", "lib", "a", "so", "dylib"]; + &["rlib", "rmeta", "dll", "lib", "so", "dylib"]; #[cfg(any(windows, test))] fn is_crate_search_artifact(file_name: &str) -> bool { @@ -540,6 +540,8 @@ mod test { "foo.d", "foo.rustc-output", "noextension", + // The `.a` symlink to an rlib that `rules_rust` makes for `cc_common.link`. + "libfoo.a", ] { assert!( !is_crate_search_artifact(file_name), @@ -559,7 +561,6 @@ mod test { "foo.dll", // Import library rustc emits alongside a Windows cdylib. "foo.dll.lib", - "libfoo.a", "FOO.RLIB", ] { assert!(