bazelbuild / bazelbuild/rules_rust
rust.toolchain(strip_level = ...) is silently ignored
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
The `rust.toolchain` tag's `strip_level` dict is keyed by compilation mode, but `rust_register_toolchains` forwards it unchanged to `rust_repository_set`, which looks it up by target triple (`strip_level.get(toolchain.target_triple)`) and finds nothing, so the setting is dropped without an error. `opt_level` from the same tag had the same problem and was fixed by re-keying (`opt_level_by_triple` in `rust/private/repositories.bzl`); `strip_level` needs the same treatment.
````
$ bazel --version
bazel 9.2.0
$ cat MODULE.bazel
bazel_dep(name = "rules_rust", version = "0.73.0")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
opt_level = {"dbg": "0", "fastbuild": "1", "opt": "3"},
strip_level = {"fastbuild": "debuginfo"},
versions = ["1.92.0"],
)
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
$ cat BUILD.bazel
load("@rules_rust//rust:defs.bzl", "rust_binary")
rust_binary(
name = "hello",
srcs = ["src/main.rs"],
)
$ echo 'fn main() {}' > src/main.rs
$ bazel aquery 'mnemonic("Rustc", //:hello)' | grep -oE -- '--codegen=(opt-level|strip)=[^ ]*'
--codegen=opt-level=1
--codegen=strip=none
````
`opt_level` from the same tag lands in the argv; `strip_level = {"fastbuild": "debuginfo"}` does not (`strip=none` is the fastbuild default).
Contributor guide
Research direction
Start in rust/private/repositories.bzl and trace how rust_register_toolchains forwards strip_level to rust_repository_set. Compare it with the existing opt_level_by_triple handling and verify the fastbuild configuration produces the requested strip setting in the Rustc action arguments rather than strip=none.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100