Skip to content

feature: introduce link_deps attribute for native library linkage#4024

Merged
krasimirgg merged 1 commit into
bazelbuild:mainfrom
Suyashagarw:link-deps
Jun 1, 2026
Merged

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

Conversation

@Suyashagarw

Copy link
Copy Markdown
Contributor

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
@Suyashagarw Suyashagarw force-pushed the link-deps branch 2 times, most recently from 0812abf to 6ffe12e Compare May 13, 2026 20:17
@Suyashagarw Suyashagarw requested a review from krasimirgg May 13, 2026 20:33
Comment thread test/unit/link_deps/BUILD.bazel Outdated
@Suyashagarw Suyashagarw force-pushed the link-deps branch 3 times, most recently from 092f8e4 to 2d62bd3 Compare May 18, 2026 19:27
@krasimirgg krasimirgg self-requested a review May 19, 2026 09:07

@krasimirgg krasimirgg 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.

Thank you!

@krasimirgg krasimirgg enabled auto-merge May 19, 2026 09:08
auto-merge was automatically disabled May 19, 2026 15:39

Head branch was pushed to by a user without write access

@Suyashagarw Suyashagarw force-pushed the link-deps branch 2 times, most recently from 2324978 to 812181b Compare May 25, 2026 10:17
@krasimirgg krasimirgg enabled auto-merge May 28, 2026 08:50
  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.
auto-merge was automatically disabled June 1, 2026 11:29

Head branch was pushed to by a user without write access

@krasimirgg krasimirgg enabled auto-merge June 1, 2026 12:33
@krasimirgg krasimirgg added this pull request to the merge queue Jun 1, 2026
Merged via the queue into bazelbuild:main with commit 0dc66fa Jun 1, 2026
3 checks passed
@UebelAndre

Copy link
Copy Markdown
Collaborator

@krasimirgg @Suyashagarw per #4095

#4024 introduced a warning for targets adding CC deps in deps. The warning calls out putting this in link_deps or cc_deps. The latter makes more sense here... but doesn't actually exist.

I did notice this change added tons of debug prints to builds in rules_rust and now it seems the guidance is inaccurate? There is indeed no cc_deps

UebelAndre pushed a commit to UebelAndre/rules_rust that referenced this pull request Jun 23, 2026
bazelbuild#4024 introduced a warning
for targets adding CC deps in `deps`. The warning calls out putting this
in `link_deps` or `cc_deps`. The latter makes more sense here... but
doesn't actually exist. However, I don't think this matters anyways, as
I don't think it's needed (this works with an internal codebase).
@krasimirgg

krasimirgg commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

I did notice this change added tons of debug prints to builds in rules_rust and now it seems the guidance is inaccurate? There is indeed no cc_deps

Hey, missed that. Internally, we have some customizations that add the cc_deps attribute and automagically enable Crubit on those. Let me prep a PR to update the warning: #4099

sync-agent-neo Bot pushed a commit to aosp-mirror-neo/platform_external_bazelbuild-rules_rust that referenced this pull request Jun 24, 2026
A follow-up from bazelbuild/rules_rust#4024
where we inadvertently mentioned a feature that doesn't exist.
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

3 participants