Fix Windows GNU staticlib output naming (#4231)

## Summary

Make Rust static-library naming ABI-aware on Windows.

Rust emits `lib<crate>.a` for the GNU and GNULLVM Windows ABIs, while
MSVC emits `<crate>.lib`. The generated Rust toolchain currently selects
`.lib` from the operating system alone, and `determine_lib_name` removes
the `lib` prefix for every Windows static library. As a result, Bazel
declares an output different from the file emitted by rustc for Windows
GNU-like targets.

This change passes the target ABI through repository and toolchain
generation, selects `.a` for Windows GNU/GNULLVM static libraries, and
preserves their `lib` prefix. MSVC behavior and Windows dynamic-library
naming remain unchanged.

Regression coverage exercises the extension mapping, rendered toolchain
metadata, final GNU/GNULLVM/MSVC static-library names, and the unchanged
GNU `cdylib` name.
6 files changed
tree: e5b055662de10fa27c4a7a07569e2eef691aa1e8
  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
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Starter repo

The fastest way to try this in an empty project is to click the green “Use this template” button on https://github.com/bazel-starters/rust.

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.