desugar_globals output is not reproducible (zip entry order varies)

Aperta
#610 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 6 giorni

@TrapsterDK ci sta già lavorando.

Dal 28/11/2026.

  • #611 di @TrapsterDK — aperta
  • #614 di @paladine — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
android, java, shell

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

//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.

Lingua principale
Java
Stelle
205
Fork
113
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazelbuild/rules_android

Tutte le issue di bazelbuild/rules_android

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.