Repository navigation
Conversation
`drain_runfiles_dir_windows` skipped the entries that did not match a retained suffix and deleted the ones that did, the opposite of its doc comment. On Windows hosts without symlink privilege this removed the `.lib`/`.so` files from the `cargo_runfiles` tree, so links against them failed with LNK1181. Delete the non-retained entries instead, and remove the directories they leave empty, the same way the Unix drain does. The empty-parent cleanup is moved into a shared helper. Fixes bazelbuild#4266 Assisted-by: Claude
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4266.
RunfilesMaker::drain_runfiles_dir_windowshad its guard backwards. Its doc comment says only the non-retained entries are deleted, but the code skipped every entry that did not match a retain suffix and deleted the ones that did. On a Windows host where the Bazel server can't create symlinks,create_runfiles_dircopies every runfile into the tree, and then the drain removed exactly the.lib/.sofiles that were supposed to stay. Links that used those paths then failed withLNK1181.What changed:
drain_runfiles_dir_unix. That loop moved into a smallremove_empty_parent_dirshelper so both paths share it, plus anis_retainedhelper for the suffix check.drain_runfiles_dir_windows_keeps_retained_filesbuilds aRunfilesMakerwith a.liband a.rsentry already copied into the output dir, drains it, and checks that only the.libis left and the emptysrc/dir is gone. The function isn't cfg-gated, so the test runs on Linux and macOS CI too.Testing: I didn't have Bazel on this machine, so I compiled the crate directly with
rustc --edition 2018 --test(it has no deps) and ran it withTEST_TMPDIRset.bin.rstests pass. Clippy is clean..libassert. The existingreplace_symlinks_in_out_dirtest fails there with os error 1314 both before and after this change, because that test creates symlinks.I used Claude (AI) to help write this change, per the AI tool policy in CONTRIBUTING. I read and checked all of it myself, and the commit has an
Assisted-by: Claudetrailer.