bazelbuild / bazelbuild/rules_rust

`incompatible_do_not_include_transitive_data_in_compile_inputs`

Open
#3,915 0 comments 0 reactions 0 assignees View on GitHub
maintenance
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

## Summary

Transitive `data` dependencies are currently included in the compile inputs of Rustc actions via `dep_info.transitive_data` in `_process_build_scripts`. This means that changes to a `data` file in a dependency trigger recompilation of all downstream targets, even though `data` files are intended to be runtime-only dependencies (unlike `compile_data`).

For example, if library `bar` has `data = ["foo.txt"]`, editing `foo.txt` does not rebuild `bar` itself, but **does** rebuild any binary that depends on `bar`. This is incorrect -- only `compile_data` should affect compilation, while `data` should only affect runfiles.

See #3609 for the original bug report and reproduction case.

## Change

A new incompatible flag `incompatible_do_not_include_transitive_data_in_compile_inputs` has been introduced (defaulting to `True`) that removes `dep_info.transitive_data` from the compile inputs constructed in `_process_build_scripts`.

This is safe because:
- Proc macro data is already handled separately via `dep_info.transitive_proc_macro_data` in `nolinkstamp_compile_inputs`
- Direct build script compile data (`build_info.compile_data`) is already added independently
- The `transitive_data` field on `DepInfo` continues to serve its purpose in `collect_deps` for propagating data to proc macros

## Migration

If you rely on the old behavior where `data` files from transitive dependencies are available as compile inputs, you can opt out by setting:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.