Skip to content

feature: introduce link_deps attribute for native library linkage#4024

Open
Suyashagarw wants to merge 1 commit into
bazelbuild:mainfrom
Suyashagarw:link-deps
Open

feature: introduce link_deps attribute for native library linkage#4024
Suyashagarw wants to merge 1 commit into
bazelbuild:mainfrom
Suyashagarw:link-deps

Conversation

@Suyashagarw
Copy link
Copy Markdown

This change adds a dedicated link_deps attribute to Rust rules, allowing native symbols to be linked without exposing them as Rust crates.

Closes #4023

Key changes:

  • Added link_deps to _COMMON_ATTRS for CcInfo/CrateInfo targets.
  • Filtered link_deps out of rust_proc_macro to avoid transition complexity.
  • Implemented transform_link_deps to extract linkage context while hiding crate metadata.
  • Updated _assert_correct_dep_mapping to print a proactive warning for native libraries listed in deps.
  • Added unit tests in test/unit/link_deps to verify correct linkage and provider propagation.

This provides a cleaner separation of concerns between Rust modules and native code linkage while maintaining full backward compatibility for existing targets.

@krasimirgg krasimirgg self-requested a review May 8, 2026 13:37
Comment thread rust/private/rust.bzl
Comment thread rust/private/rust.bzl Outdated
Comment thread test/unit/link_deps/link_deps_test.bzl Outdated
Comment thread test/unit/link_deps/link_deps_test.bzl
Comment thread test/unit/link_deps/BUILD.bazel
  This change adds a dedicated link_deps attribute to Rust rules, allowing native symbols to be linked without exposing them as Rust crates.

  Key changes:
   - Added link_deps to _common_attrs for CcInfo/CrateInfo targets.
   - Filtered link_deps out of rust_proc_macro to avoid transition complexity.
   - Implemented transform_link_deps to extract linkage context while hiding crate metadata.
   - Added a proactive warning for native libraries incorrectly listed in deps.
   - Added unit tests in test/unit/link_deps to verify correct linkage.
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.

Feature Request: link_deps attribute for native library linkage

2 participants