desugar_globals output is not reproducible (zip entry order varies)

Abierto
#610 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

@TrapsterDK ya está trabajando en esto.

Desde el 28/11/2026.

  • #611 de @TrapsterDK — abierto
  • #614 de @paladine — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
android, java, shell

Línea de trabajo

Start with the //tools/android:desugar_globals and desugar_globals_classes genrules in tools/android/BUILD, then run the issue’s GlobalSyntheticsGenerator reproduction command. The work is done when both genrules enable deterministic mode and repeated runs produce identical .globals output that can be remote-cached. Note that linked PR #611 already proposes this change.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

//tools/android:desugar_globals is not reproducible. The genrule runs R8's GlobalSyntheticsGenerator and the entry order of the .globals zip it writes changes from run to run. The zip is the input of desugar_globals_dex_archive, so the same source tree gives different outputs and misses the remote cache.

Reproduce with the R8 version rules_android pins (com.android.tools:r8:9.3.16), without Bazel. The command line is the one in tools/android/BUILD:

curl -sSLO https://maven.google.com/com/android/tools/r8/9.3.16/r8-9.3.16.jar
for i in 1 2 3 4 5 6 7 8; do
  java -Dcom.android.tools.r8.disableLambdaMethodAnnotations \
    -cp r8-9.3.16.jar com.android.tools.r8.GlobalSyntheticsGenerator \
    --min-api 23 --output run$i.globals
done
sha256sum run*.globals | cut -d' ' -f1 | sort | uniq -c

Actual: 8 runs gave 4 different hashes (3/3/1/1). unzip -Z1 shows the same six entries in different orders, for example RecordTag.global first in one run and DesugarVarHandle$0.global first in another.

Expected: the same bytes on every run.

Adding -Dcom.android.tools.r8.deterministicdebugging=1 to the command makes all 8 runs identical (one hash, 8/8).

The --classfile variant used by desugar_globals_classes produced identical output in 12 runs here, but it runs the same generator.

Environment: Linux x86_64, OpenJDK 25, rules_android main (5a9ce60), same behavior expected for 0.8.1.

I will send a PR that sets the flag on both genrules.

Assisted by Claude.

Lenguaje dominante
Java
Estrellas
205
Forks
113
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bazelbuild/rules_android

Todos los issues de bazelbuild/rules_android

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.