feature: introduce link_deps attribute for native library linkage - #4024
Conversation
0812abf to
6ffe12e
Compare
092f8e4 to
2d62bd3
Compare
Head branch was pushed to by a user without write access
2324978 to
812181b
Compare
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.
Head branch was pushed to by a user without write access
|
@krasimirgg @Suyashagarw per #4095
I did notice this change added tons of debug prints to builds in |
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).
Hey, missed that. Internally, we have some customizations that add the |
A follow-up from bazelbuild/rules_rust#4024 where we inadvertently mentioned a feature that doesn't exist.
bazelbuild#4024 now adds noisy prints that users have no way to handle when using crate_universe. This change adds annotations so the prints can be actioned.
### What does this PR do? Move `:cpp_stdlib` out of the shared `_LIB_DEPS` and into `link_deps` on the `dd-procmgrd-lib` and `dd-procmgrd-lib-testhelpers` targets. ### Motivation `rules_rust` 0.71.0 deprecates C++ libraries in a Rust target's `deps` and adds `link_deps` for manual FFI linkage: - bazelbuild/rules_rust#4024. Left in `deps`, `:cpp_stdlib` makes the build emit a deprecation warning per target: ``` WARNING: Target @@//pkg/procmgr/rust:cpp_stdlib in 'deps' of @@//pkg/procmgr/rust:dd-procmgrd-lib-testhelpers is a C++ library. Only Rust targets are allowed in 'deps'. Please use 'link_deps' for manual FFI linkage. Support for C++ libraries in 'deps' is deprecated and will be removed in a future release. WARNING: Target @@//pkg/procmgr/rust:cpp_stdlib in 'deps' of @@//pkg/procmgr/rust:dd-procmgrd-lib is a C++ library. Only Rust targets are allowed in 'deps'. Please use 'link_deps' for manual FFI linkage. Support for C++ libraries in 'deps' is deprecated and will be removed in a future release. ``` ### Describe how you validated your changes `bazel build //pkg/procmgr/rust:dd-procmgrd` links cleanly with no `cpp_stdlib` deprecation warning, confirming the `-lstdc++` linkage still propagates to the binary through `link_deps`. ### Additional Notes Will anyway ease the transition to `rules_rs`, backed by `rules_rust`. Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
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:
This provides a cleaner separation of concerns between Rust modules and native code linkage while maintaining full backward compatibility for existing targets.