Include transitive out_dirs in linking action (#3579)

If a build script compiles a file which is needed at linking time, and
adds a linker flag to add it to the search path, we need the out_dir to
be present in the link action in order for the search path flag to
actually take effect.

This was the original behaviour way back in
3a569b8590aed8a2166aec269aaf83c195bdd373 but got removed in
9426a3820093e75ea07d14f875e42f789632507f which was intending to only
restrict where flags were propagated but also stopped propagating
out_dir files.

This is required because cargo uses the path to the out_dir as a
well-known-path that doesn't move between builds, so link flags from a
build script which get transitively propagated up to a link action
happen to point at the right location on disk. We need to propagate this
out_dir because the known location on disk is probably in a sandbox, so
we need to explicitly materialise the files into the sandbox.
4 files changed
tree: ea4b491e6fa01fb2e354a535ba1e456639285730
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. cargo/
  5. crate_universe/
  6. docs/
  7. examples/
  8. extensions/
  9. ffi/
  10. nix/
  11. rust/
  12. test/
  13. tools/
  14. util/
  15. .bazelignore
  16. .bazelrc
  17. .clang-format
  18. .clippy.toml
  19. .envrc
  20. .gitattributes
  21. .gitignore
  22. .pre-commit-config.yaml
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. .typos.toml
  26. ARCHITECTURE.md
  27. AUTHORS
  28. BUILD.bazel
  29. CODEOWNERS
  30. COMPATIBILITY.md
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. LICENSE.txt
  34. MODULE.bazel
  35. README.md
  36. version.bzl
  37. WORKSPACE.bazel
  38. WORKSPACE.bzlmod
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.