bzlmod: override_target_build_script and override_target_proc_macro are silent no-ops (override_targets key mismatch)
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 90/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- rust
- Área
- build-system
Línea de trabajo
Comienza en extensions.bzl con la reconstrucción de override_targets y compara sus claves con override_target_key en crate_context.rs. Alinea las claves de bzlmod con el vocabulario documentado de kind; después, vuelve a fijar un crate con un build script o proc macro e inspecciona el BUILD generado para confirmar que el override emite un alias al label proporcionado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The bzlmod module extension reconstructs override_targets from the four split override_target_* attributes using the keys "build_script" and "proc_macro":
https://github.com/bazelbuild/rules_rust/blob/main/crate_universe/extensions.bzl (search for override_target_build_script)
replacement = annotation_dict.pop("override_target_proc_macro")
if replacement:
annotation_dict["override_targets"]["proc_macro"] = str(replacement)
replacement = annotation_dict.pop("override_target_build_script")
if replacement:
annotation_dict["override_targets"]["build_script"] = str(replacement)
But rendering looks the rule up by its cargo-metadata Target.kind via override_target_key(), which returns "proc-macro" and "custom-build":
https://github.com/bazelbuild/rules_rust/blob/main/crate_universe/src/context/crate_context.rs (override_target_key)
pub(crate) fn override_target_key(&self) -> &'static str {
match self {
Self::Library(..) => "lib",
Self::ProcMacro(..) => "proc-macro",
Self::Binary(..) => "bin",
Self::BuildScript(..) => "custom-build",
}
}
"lib" and "bin" agree in both spellings, so those overrides work. "build_script" and "proc_macro" never match, so under bzlmod override_target_build_script and override_target_proc_macro are silently ignored: the generated BUILD keeps its own cargo_build_script instead of emitting the alias to the override label. No error or warning is produced.
The non-bzlmod crate.annotation(override_targets = ...) documents the kind-style vocabulary ("Keys can be proc-macro, custom-build, lib, bin" in crate_universe/private/crate.bzl), which is presumably why this went unnoticed: WORKSPACE users pass the dict directly with the correct keys.
Repro: annotate any crate that has a build script with override_target_build_script = "//some:target" under bzlmod, repin, and inspect the generated BUILD: it still contains the generated cargo_build_script rather than an alias to //some:target.
Fix: align the two keys in extensions.bzl with the documented vocabulary:
- annotation_dict["override_targets"]["proc_macro"] = str(replacement)
+ annotation_dict["override_targets"]["proc-macro"] = str(replacement)
...
- annotation_dict["override_targets"]["build_script"] = str(replacement)
+ annotation_dict["override_targets"]["custom-build"] = str(replacement)
We are running with exactly this two-line patch applied to 0.70.0 and override_target_build_script works as documented with it.
- Lenguaje dominante
- Starlark
- Estrellas
- 853
- Forks
- 680
- Merge medio
- 3 d 4 h
- PR fusionados (30 d)
- 19
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bazelbuild/rules_rust
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfilesPosiblemente ocupada @Wito-1 la tomó hace 33 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
bazelbuild/rules_rust#4309 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bazelbuild/rules_rust#4266 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bazelbuild/rules_rust#4223 ·
Los mantenedores suelen responder en 2 días
-
awaiting-response
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
bazelbuild/rules_rust#3599 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
crate-universe needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
bazelbuild/rules_rust#3557 ·
Los mantenedores suelen responder en 2 días
Todos los issues de bazelbuild/rules_rust
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pyodide/pyodide-recipes#682 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/arrow-swift#209 ·
Los mantenedores suelen responder en 1 día
-
[BUG] spotify-launcherAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
libretiny-eu/libretiny#435 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 65/100
influxdata/telegraf#20031 ·
Los mantenedores suelen responder en 1 día