Allow specifying additional target triples in rust_register_toolchains() and fix androideabi system (#1181)

* Allow specifying additional target triples in rust_register_toolchains() and fix androideabi system

In addition to host target, "wasm32-unknown-unknown" and "wasm32-wasi" targets are being installed, which includes downloading corresponding rust-std libraries. This CL allow specifying custom additional target triples by introducing a new parameter to rust_register_toolchains(), which defaults to ["wasm32-unknown-unknown" and "wasm32-wasi"] for compatibility. As an example, it is now possible to compile for Android if ["armv7-linux-androideabi"] is specified as an extra_target_triples.

Specifically for Android, most of the required infrastructure was already in place. For example, @rules_rust//rust/platform:triple_mappings.bzl already has all the necessary information to compile Android libraries (e.g. _SYSTEM_TO_STDLIB_LINKFLAGS). However, "armv7-linux-androideabi" is not a 'proper' target tripple because 'androideabi' is not a proper system. As such, special handling is required to map 'androideabi' back to 'android'.

* Extract common triple decomposition logic into a helper method that returns a struct with the fields populated.

* Use triple() function from triple.bzl

* Restore removed methods, and add deprecation message.

Co-authored-by: Denis Koroskin <dkoroskin@google.com>
3 files changed
tree: 298768c1b3e0063c8ed254957fe778d3f6650104
  1. .bazelci/
  2. .github/
  3. bindgen/
  4. cargo/
  5. crate_universe/
  6. docs/
  7. examples/
  8. proto/
  9. rust/
  10. test/
  11. tools/
  12. util/
  13. wasm_bindgen/
  14. .bazelignore
  15. .bazelrc
  16. .gitignore
  17. ARCHITECTURE.md
  18. AUTHORS
  19. BUILD.bazel
  20. CODEOWNERS
  21. COMPATIBILITY.md
  22. CONTRIBUTING.md
  23. CONTRIBUTORS
  24. LICENSE.txt
  25. README.md
  26. WORKSPACE.bazel
  27. workspace.bzl
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.