Introduce feature `rules_rust_link_cc`. (#2723)

This feature is similar to `rules_rust_unsupported_feature`. The
difference is that, `rules_rust_unsupported_feature` gets disabled if
*any* rust is involved, while this feature gets disabled if *only* rust
is involved.

My use case for this feature is to static link to c++ / objc stdlibs.
They are needed only when any C object is being linked, and will produce
invalid rust_proc_macro if linked blindly.

This implementation uses the fact that `DepInfo.transitive_noncrates`
would be empty unless there is a `cc_library` or `cc_import` in the
(transitive) deps. As a side effect, `collect_deps()` can no longer use
the output of `_are_linkstamps_supported()` so it now always returns a
populated linkstamp depset, to be discarded later if linkstamps are not
supported.

---------

Co-authored-by: scentini <rosica@google.com>
5 files changed
tree: 638791f2bef1518dc937bbeff8a3841d1e8a9d9f
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. bindgen/
  5. cargo/
  6. crate_universe/
  7. docs/
  8. examples/
  9. ffi/
  10. nix/
  11. proto/
  12. rust/
  13. test/
  14. tools/
  15. util/
  16. wasm_bindgen/
  17. .bazelignore
  18. .bazelrc
  19. .clang-format
  20. .envrc
  21. .gitattributes
  22. .gitignore
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. ARCHITECTURE.md
  26. AUTHORS
  27. BUILD.bazel
  28. CODEOWNERS
  29. COMPATIBILITY.md
  30. CONTRIBUTING.md
  31. CONTRIBUTORS
  32. LICENSE.txt
  33. MODULE.bazel
  34. README.md
  35. version.bzl
  36. WORKSPACE.bazel
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.