Skip to content

fix(cc): don't drop Windows import libs from cc_binary with dynamic_deps - #4487

Merged
aignas merged 1 commit into
bazel-contrib:mainfrom
AustinSchuh:fix-py-cc-toolchain-provides-toolchaininfo
Nov 22, 2026
Merged

aignas merged 1 commit into
bazel-contrib:mainfrom
AustinSchuh:fix-py-cc-toolchain-provides-toolchaininfo

Conversation

@AustinSchuh

@AustinSchuh AustinSchuh commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

On Windows, current_py_cc_headers forwards a CcInfo that includes
the Python import libraries. A cc_binary with dynamic_deps only
links libraries whose owners it can find in its dependency graph, and it
can't find these through the toolchain. The libraries get dropped and
the link fails with LNK1104: cannot open file 'python313.lib'.

Return CcSharedLibraryHintInfo with the owners, the same fix #4166
made for current_py_cc_libs. Apply it to current_py_cc_headers_abi3
too.

On Windows, `current_py_cc_headers` forwards a `CcInfo` that includes the
Python import libraries. A `cc_binary` with `dynamic_deps` only links
libraries whose owners it can find in its dependency graph, and it can't
find these through the toolchain. The libraries get dropped and the link
fails with `LNK1104: cannot open file 'python313.lib'`.

Return `CcSharedLibraryHintInfo` with the owners, the same fix bazel-contrib#4166 made
for `current_py_cc_libs`. Apply it to `current_py_cc_headers_abi3` too.

@aignas aignas left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will fix the description to comply with the standards.

@AustinSchuh

Copy link
Copy Markdown
Contributor Author

Thanks! And sorry for the extra work.

@aignas
aignas added this pull request to the merge queue Nov 22, 2026
@aignas

aignas commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

No problem, sorry it took a while. Since you are using Windows, may I ask you to take a look at #4509 PR if it actually works on systems without enabling symlinks if you have time? If you have any issues with Windows and the rules, feel free to create issues and I would like to iron out them.

@AustinSchuh

Copy link
Copy Markdown
Contributor Author

Happy to. I'll send patches with any issues I find (claude helps a ton with getting close quickly), feel free to modify as you see fit, or I can.

For context, I'm helping out https://wpilib.org/ which is the core library for ~20k highschool robotics teams. It is built with gradle today by default, but gradle is dropping C++ support, so the default next year for C++ will switch to bazel. I found this as part of that work.

I'll look at that other review and report back. Ping me on other reviews if you'd like me to test anything out.

Merged via the queue into bazel-contrib:main with commit c5b1997 Nov 22, 2026
17 checks passed
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