Skip to content

[9.1.0] fix copy_dynamic_libraries_to_binary for subdirectories#28950

Closed
novas0x2a wants to merge 1 commit intobazelbuild:release-9.1.0from
novas0x2a:fix-windows-dlls
Closed

[9.1.0] fix copy_dynamic_libraries_to_binary for subdirectories#28950
novas0x2a wants to merge 1 commit intobazelbuild:release-9.1.0from
novas0x2a:fix-windows-dlls

Conversation

@novas0x2a
Copy link
Copy Markdown
Contributor

@novas0x2a novas0x2a commented Mar 10, 2026

Description / Motivation

This is a new instance of a similar problem described in #12448. In order for windows binaries to run, the (non-system) dlls need to be copied to the same directory. However, the code that determined that was only looking at the package label and the workspace, but not the actual subdirectory. Previously, this was fixed by adding the lib.is_source check, but this only solves it for source files (i.e. for cc_import) but not cc_library.

This is a crossport from rules_cc; See bazelbuild/rules_cc#623.

The bug is not present in bazel HEAD, because the cc code has been fully removed. However, the bug is present in all current release lines (9.x, 8.x, 7.x, 6.x). You can see this in the rules_cc pipeline from before I disabled this test in rules_cc for the versions that use the bazel native code.

Build API Changes

This could potentially be considered a breaking change; it makes copy_dynamic_libraries_to_binary behave like it said it would, but this bug has been present for so long that it is possible people have built workarounds for it into their code.

Checklist

  • I have added tests for the new use cases (if any).
  • [n/a] I have updated the documentation (if applicable).

The tests are in rules_cc; see bazelbuild/rules_cc#623.

Release Notes

RELNOTES: None

This is a new instance of a similar problem described in
bazelbuild#12448. In order for windows
binaries to run, the (non-system) dlls need to be copied to the same
directory. However, the code that determined that was only looking at
the package label and the workspace, but not the actual subdirectory.
Previously, this was fixed by adding the lib.is_source check, but this
only solves it for source files.

This is a crossport from rules_cc; See bazelbuild/rules_cc#623
@novas0x2a novas0x2a requested a review from a team as a code owner March 10, 2026 23:47
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Mar 10, 2026
@armandomontanez
Copy link
Copy Markdown
Contributor

@pzembrod FYI this backport of bazelbuild/rules_cc#623

@iancha1992 iancha1992 added the team-Rules-CPP Issues for C++ rules label Mar 11, 2026
@iancha1992 iancha1992 changed the title fix copy_dynamic_libraries_to_binary for subdirectories [9.1.0] fix copy_dynamic_libraries_to_binary for subdirectories Mar 11, 2026
@iancha1992 iancha1992 requested a review from pzembrod March 11, 2026 19:09
@iancha1992
Copy link
Copy Markdown
Member

iancha1992 commented Mar 11, 2026

cc: @hvadehra because src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl was deleted in the master branch.

@hvadehra
Copy link
Copy Markdown
Member

However, the bug is present in all current release lines (9.x, 8.x, 7.x, 6.x). You can see this in the rules_cc pipeline from before I disabled this test in rules_cc for the versions that use the bazel native code.

I don't see a failing run for Bazel 9 there.

This PR will have no effect - the cc rules embedded in Bazel 9 are unused, only those from @rules_cc get used.

If you want to backport this, it needs to be only for Bazel <= 8.

@hvadehra hvadehra closed this Mar 12, 2026
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Mar 12, 2026
@novas0x2a
Copy link
Copy Markdown
Contributor Author

The idea was to target the newest branch that still had the buggy code present (which is different than the test failing) and then trigger the auto-backport for the rest of the branches. If you're saying this code should already have been deleted from 9.1.0, well, yep, I agree with you, but it's still there nonetheless :)

@novas0x2a
Copy link
Copy Markdown
Contributor Author

novas0x2a commented Mar 12, 2026

@hvadehra As far as I know, I can't trigger the bot backports, though, so... could you?

@novas0x2a
Copy link
Copy Markdown
Contributor Author

Well, let's try anyway:
@bazel-io fork 8.7.0

@novas0x2a
Copy link
Copy Markdown
Contributor Author

I didn't get a thumbs-up, so I assume it's not going to listen to me.

@hvadehra
Copy link
Copy Markdown
Member

Just change the target of this PR to the release-8.7.0 branch instead

@hvadehra hvadehra reopened this Mar 12, 2026
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Mar 12, 2026
@novas0x2a novas0x2a changed the base branch from release-9.1.0 to release-8.7.0 March 12, 2026 10:31
@novas0x2a novas0x2a changed the base branch from release-8.7.0 to release-9.1.0 March 12, 2026 10:32
@hvadehra
Copy link
Copy Markdown
Member

Might be simpler to just open a fresh PR?

@novas0x2a
Copy link
Copy Markdown
Contributor Author

I opened the 8.x PR, but there's no release branch created for 7.x, so I'm not sure how to do this (you all might want to actually document this process for those of us outside google; this is sort of unpleasant).

@iancha1992 iancha1992 added this to the 9.1.0 release blockers milestone Mar 12, 2026
@iancha1992 iancha1992 closed this Mar 12, 2026
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants