Add support for extra rustc environment variables (#3510)

This adds support for injecting environment variables into rustc
invocations via build settings:

- `//rust/settings:extra_rustc_env` for the target configuration
- `//rust/settings:extra_exec_rustc_env` for the exec configuration

These settings can be set from the command line with flags like:

```
  --@rules_rust//rust/settings:extra_rustc_env=RUSTC_BOOTSTRAP=1
```

This mirrors how extra rustc flags are handled and enables build-wide
env-based feature control without editing individual rules. Useful for
enabling unstable features across many crates, or toggling behavior in
proc macros and build scripts.
5 files changed
tree: 2a1920bb7854091fd2fc62cb89162fb26e4e4336
  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.