bazel-contrib / bazel-contrib/rules_foreign_cc
Redundant builds of dependencies due to shared objects in runfiles
- Dominant language
- Starlark
- Stars
- 737
- Forks
- 270
- PR merge metrics
- No merged PRs in 30d
Description
I've noticed that all (transitive) dependencies of `rules_foreign_cc` rules tend to get compiled twice, due to [this code](https://github.com/bazelbuild/rules_foreign_cc/blob/86936d7b5b6022eba654fee1b0937915159e94ba/foreign_cc/private/framework.bzl#L517) in `cc_external_rule_impl` adding the dynamic libraries to the runfiles. I find this surprising and generally undesirable, because it increases build times and increases the size of the runfiles tree for deployment. Also it's hard to make use of these shared libraries without violating the One Definition Rule if the actual `rules_foreign_cc` target links them statically (which is by far the most common I've observed).
The comment on the code in question says this:
```
# Include shared libraries of transitive dependencies in runfiles, facilitating the "runnable_binary" macro
```
Would a separate provider that `runnable_binary` finds using an aspect be an acceptable alternative? It could break backwards compatibility for anybody relying on these shared libraries being present in runfiles, but I suspect that isn't very common because these shared libraries are pretty hard to use.
Contributor guide
Research direction
Read foreign_cc/private/framework.bzl at the cc_external_rule_impl code linked in the issue, then trace how the runnable_binary macro uses the shared libraries in runfiles. Done means establishing whether the current runfiles behavior can change safely and documenting or implementing an agreed alternative without breaking existing users.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100