Skip to content

fix(cc): include toolchain libraries in cc_shared_library - #4166

Merged
aignas merged 2 commits into
bazel-contrib:mainfrom
dzbarsky:upstream/python-libs-shared-library-hints
Sep 18, 2026
Merged

aignas merged 2 commits into
bazel-contrib:mainfrom
dzbarsky:upstream/python-libs-shared-library-hints

Conversation

@dzbarsky

Copy link
Copy Markdown
Contributor

current_py_cc_libs forwards linker inputs with the Python toolchain library's owner labels. cc_shared_library does not discover those labels through the toolchain, so it silently omits the static libraries. Return CcSharedLibraryHintInfo with the forwarded owner labels.

Validation: added a rules_testing regression with a static library supplied through py_cc_toolchain. It fails before the fix; all three current_py_cc_libs analysis tests pass afterward on Bazel 9.1.1.

current_py_cc_libs forwards CcInfo from the selected Python toolchain, but the linker inputs retain their original owner labels. cc_shared_library does not visit those labels through the toolchain and silently omits static libraries from its link.

Return CcSharedLibraryHintInfo with the forwarded owner labels. Add a rules_testing regression using a static library supplied through a py_cc_toolchain.

Validation: the regression fails before this change; all three current_py_cc_libs analysis tests pass afterward on Bazel 9.1.1. buildifier and git diff --check pass.
The analysis transition replaces --extra_toolchains, removing the C++ toolchain supplied by remote CI. When C++ auto-detection is disabled, cc_shared_library then fails before the regression assertion can run.

Register the existing C++ test toolchains along with the Python test toolchain. The static-library assertion remains unchanged.

Validation: reproduced the missing C++ toolchain error on Bazel 8.6.0 with a Linux target platform and auto-detection disabled; the same test passes after the change. All three current_py_cc_libs analysis tests also pass on the host platform.

@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!

@aignas
aignas added this pull request to the merge queue Sep 18, 2026
Merged via the queue into bazel-contrib:main with commit 9cc620e Sep 18, 2026
5 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