Configurable `rules_rust`

Open
#4,049 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@mansiverma897993 is already working on this.

Since Jun 16, 2026.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
rust

Research direction

Start by reading rustc.bzl, especially the hardcoded args.add blocks, along with the existing build settings and transitions. Map how compiler and linker flags, compilation sub-phases, custom actions, and artifact names are currently coupled to the rule. Done means the issue's requested toolchain-level declarative customization is supported without rule forks, with coverage for the listed action types and platform naming cases.

Written by the indexing model from the issue text.

Description

core

Configuring compiler and linker flags in rules_rust currently relies heavily on imperative Starlark code (such as hardcoded args.add blocks inside the rule implementation) and bespoke build settings/transitions. Because flag-building is tightly coupled with the rule logic, consumers face high friction when adapting toolchain configurations to custom environments.

To resolve these customization barriers, compile and link flags should be decoupled from the core rule implementation and exposed as declarative configurations at the toolchain level.

  • Enable declarative wrappers and flags without maintaining rule forks: Users should be able to inject custom compiler/linker wrappers, extra flag configurations, or alternative platform sanitizers declaratively at the toolchain level. This enables setting flags for project-specific workflows rather than adding more build settings directly to rules_rust, eliminating the need to carry custom patches or fork core rules (like rustc.bzl) and greatly simplifying upstream version upgrades.
  • Support granular flag controls and custom compilation actions: The system should expose specific compilation sub-phases so that consumers can apply flags selectively based on the action type - such as targeting metadata-only builds (.rmeta), clippy checkout runs, etc. It should also enable support for spawning different types of compilation actions, such as emitting LLVM IR (--emit=llvm-ir) or LLVM bitcode (--emit=llvm-bc), based on user demands.
  • Provide configurable and overridable artifact naming: Hardcoded platform-specific name mappings (like .rlib to .a static library symlinks or MSVC .dll vs. .dll.lib import conventions) should be decoupled and made configurable, making it easy to support custom platform layouts and exotic execution environments.
Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.