Skip to content

Conversation

@hlopko
Copy link
Member

@hlopko hlopko commented Jul 25, 2025

Before this PR, Rust rules merge data_runfiles of dependencies into its default_runfiles (because we used [collect_data=True](https://bazel.build/versions/7.1.0/rules/lib/builtins/ctx#runfiles)). cc_libraries put shared libraries to data_runfiles even when cc_library has a static library equivalent and Bazel is linking statically. This becomes problematic when packaging binaries - we end up putting unnecessary shared libraries into the package.

Therefore, this PR removes the use of collect_data, and refactors our runfiles logic to follow the latest guidance. While at it, I made sure to only put transitive shared libraries to runfiles when building a binary-like target (bin, staticlib, cdylib). This way we avoid depset flattenning in libraries.

Added a little regression test.

@hlopko hlopko requested a review from krasimirgg July 25, 2025 20:55
@hlopko hlopko marked this pull request as ready for review July 25, 2025 20:55
Copy link
Collaborator

@krasimirgg krasimirgg left a comment

Choose a reason for hiding this comment

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

also plz look into the formatting error and if possible add some unit tests.

@hlopko hlopko changed the title Synchronize handling of C++ runfiles with C++ rules Do not use runfiles.collect_data Jul 30, 2025
hlopko added 12 commits July 30, 2025 22:57
This PR makes sure that Rust forwards runfiles from C++ rules exactly like C++ rules do (currently, Rust sends shared libraries to data_runfiles even when linking statically, C++ doesn't).
@hlopko hlopko requested a review from krasimirgg July 30, 2025 20:59
Copy link
Collaborator

@krasimirgg krasimirgg left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you!

@krasimirgg krasimirgg added this pull request to the merge queue Jul 31, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 31, 2025
@krasimirgg krasimirgg added this pull request to the merge queue Jul 31, 2025
Merged via the queue into main with commit 477ab18 Jul 31, 2025
7 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.

4 participants