• Home
Name Date Size #Lines LOC

..--

d8/lib/03-May-2024-

lib/03-May-2024-

playground/03-May-2024-5125

BUILD.gnD03-May-2024597 1612

DIR_METADATAD03-May-202468 54

LICENSED03-May-20241.5 KiB2722

OWNERSD03-May-202460 43

README.chromiumD03-May-20244.2 KiB9987

backported_methods.txtD03-May-202410.2 KiB163162

cipd.yamlD03-May-2024391 125

desugar_jdk_libs.jsonD03-May-202411.9 KiB250249

README.chromium

1Name: R8
2URL: https://r8.googlesource.com/r8
3Version: 3.0.33
4License: BSD 3-Clause
5License File: LICENSE
6Security Critical: no
7Shipped: no
8
9Description:
10lib/r8.jar
11 - Contains R8 (proguard replacement) as well as D8 (dexer).
123pp
13 - Contains code for 3pp-linux-amd64-packager to package and upload new versions of r8.
14desugar_jdk_libs.json
15 - Configuration for Java library desugaring.
16 - Taken from
17   //third_party/android_deps/libs/com_android_tools_desugar_jdk_libs_configuration/
18   inside the jar file, in META-INF/desugar/d8/desugar.json. License is also BSD
19   3-Clause (the r8 version).
20
21R8 is a proguard-like optimizer that also has the ability to dex.
22
23Local Modifications:
24* Refer to commit descriptions within "3pp/patches" directory.
25* Added "playground" directory for quick "how does this optimize" tests.
26* Removed references to ConcurrentHashMap and TimeZone#getTimeZone in desugar_jdk_libs.json.
27* Added "java/src/org/chromium/build/CustomD8.java", custom_d8.jar, and BUILD.gn.
28  * Used in "build/android/gyp/dex.py" to enable desugar dependencies.
29
30Update Instructions:
31* For the custom d8 jar:
32  * This is required only when CustomD8.java changes.
33  * Uncomment the flag --skip-custom-d8 in internal_rules.gni to avoid depending
34    on the previously built custom_d8.jar.
35autoninja -C out/Debug third_party/r8:custom_d8_java
36cp out/Debug/obj/third_party/r8/custom_d8_java.javac.jar third_party/r8/custom_d8.jar
37
38* For a new version of r8:
39  * Find the latest successful run of the build bot:
40    * https://ci.chromium.org/p/chromium/builders/ci/3pp-linux-amd64-packager
41    * The bot autoruns every 6 hours. Ping a trooper to trigger it if you need it sooner.
42      * https://luci-scheduler.appspot.com/jobs/chromium/3pp-linux-amd64-packager
43  * Go to its log page and look under:
44    * Expand "building chromium/third_party/r8" to see the CIPD instance ID.
45  * Copy this instance ID to the r8 entry in //DEPS.
46  * Update this file with the new version string and submit.
47
48* If patching fails:
49git clone https://r8.googlesource.com/r8
50cd r8
51  * Find latest tag:
52git fetch origin --tags
53git tag -l  # Often unnecessary as output from the fetch includes recent tags.
54git checkout $TAG  # e.g. 3.0.25-dev, whichever tag failed patching.
55  * Apply patches:
56git checkout -b my_branch
57git am $CHROMIUM_SRC/third_party/r8/patches/*.patch
58  * Fix patch conflicts.
59  * Save new patches. Change number if expecting more or fewer patches:
60git format-patch -3 -o $CHROMIUM_SRC/third_party/r8/3pp/patches
61  * Submit these fixed patches and the bot will automatically retry.
62
63* Local development (see above for setting up the r8 repo):
64  * Build
65tools/gradle.py r8
66  * Shrink (improves r8/d8 launch time):
67java -jar build/libs/r8.jar --debug --classfile --output r8.jar \
68    --lib $CHROMIUM_SRC/third_party/jdk/current --pg-conf src/main/keep.txt \
69    --no-minification --no-desugaring build/libs/r8.jar
70mv $CHROMIUM_SRC/third_party/r8/lib/r8.jar{,.bak}
71cp r8.jar $CHROMIUM_SRC/third_party/r8/lib/r8.jar
72
73* Update backported methods list:
74cd $CHROMIUM_SRC
75java -cp third_party/r8/lib/r8.jar com.android.tools.r8.BackportedMethodList --min-api 16 > third_party/r8/backported_methods.txt
76
77* Update instructions for desugar_jdk_libs.json:
78unzip -p third_party/android_deps/libs/com_android_tools_desugar_jdk_libs_configuration/*.jar META-INF/desugar/d8/desugar.json > third_party/r8/desugar_jdk_libs.json
79  * Remove all mentions of ConcurrentHashMap and TimeZone#getTimeZone and remove trailing commas.
80  * Update //build/config/android/internal_rules.gni to point at the new .jar files:
81    * desugar_jdk_libs-1.1.1.jar
82    * desugar_jdk_libs_configuration-1.1.1.jar
83
84How to file bugs against R8:
85* Copy & paste the failing ninja command (starts with proguard.py), and add --dump-inputs.
86  * This also works for dex.py, it produces d8inputs.zip
87* File bug at go/r8bug
88* Things to include (use discretion if some are not relevant):
89  * src revision bug reproduces at
90  * Repro steps (gn gen & autoninja commands)
91    * Prefer enable_chrome_android_internal=false
92  * The r8inputs.zip from --dump-inputs
93  * Any relevant dexdump analysis
94
95How to submit CLs to R8:
96* Request to be added to their allowlist in order to upload CLs.
97* After CLs are submitted, check the bots for build breakage.
98  * https://ci.chromium.org/p/r8/g/main_all/console
99