[go: nahoru, domu]

blob: 82fd03bfb8e33b4f2dc1d5d507660aaacb304f42 [file] [log] [blame]
Tiger Oakes95b7b7d2018-05-28 15:43:491Name: R8
2URL: https://r8.googlesource.com/r8
Mohamed Heikal81e19d92021-09-17 14:50:323Version: unknown
Tiger Oakes95b7b7d2018-05-28 15:43:494License: BSD 3-Clause
Anne Redullaeae2955c2023-07-10 23:45:565License File: LICENSE
Tiger Oakes95b7b7d2018-05-28 15:43:496Security Critical: no
Anne Redullaeae2955c2023-07-10 23:45:567Shipped: no
Tiger Oakes95b7b7d2018-05-28 15:43:498
9Description:
Andrew Grieve492290082022-11-15 02:05:3210R8 is a whole-program optimizer and dexer. It takes in .class files and outputs
11.dex files.
Andrew Grieve723c1502020-04-23 16:27:4212
Andrew Grieve492290082022-11-15 02:05:3213Directory overview:
14* lib/r8.jar
15 * The copy of R8 that is used for proguarding.
16 * Updated daily by an auto-roller.
17* d8/lib/r8.jar
18 * The copy of R8 that is used for dexing.
19 * Updated manually (and infrequently) in order to avoid having to re-dex all
20 library targets every day.
21* 3pp
22 * Contains code for 3pp-linux-amd64-packager to package and upload new
23 versions of r8.
Andrew Grieve492290082022-11-15 02:05:3224* print_version.sh
25 * Print the R8 commit for the current version.sh.
Tiger Oakes95b7b7d2018-05-28 15:43:4926
Eric Stevenson70ed3562018-06-26 21:21:4627Local Modifications:
Peter Wen3d6eb7ee2021-03-03 21:27:4528* Refer to commit descriptions within "3pp/patches" directory.
Andrew Grieve1b0b910e2020-04-07 01:41:5229* Added "playground" directory for quick "how does this optimize" tests.
Andrew Grieve492290082022-11-15 02:05:3230* Added "dump_inputs.py" and "print_version.sh" scripts.
Peter Wen5ef0e3bb2021-01-15 19:59:0831* Added "java/src/org/chromium/build/CustomD8.java", custom_d8.jar, and BUILD.gn.
32 * Used in "build/android/gyp/dex.py" to enable desugar dependencies.
Andrew Grieve92f162cf2020-03-31 20:32:3533
34Update Instructions:
Sam Maier276d77b52023-12-20 22:07:5235* For the custom r8/d8 jar:
36 * This is required only when Custom{R,D}8.java changes.
Peter Wen45443be2021-04-08 22:41:2637 * Uncomment the flag --skip-custom-d8 in internal_rules.gni to avoid depending
38 on the previously built custom_d8.jar.
Sam Maier276d77b52023-12-20 22:07:5239autoninja -C out/Debug third_party/r8:custom_r8_java
40cp out/Debug/obj/third_party/r8/custom_r8_java.javac.jar third_party/r8/custom_r8.jar
41OR
Peter Wen5ef0e3bb2021-01-15 19:59:0842autoninja -C out/Debug third_party/r8:custom_d8_java
43cp out/Debug/obj/third_party/r8/custom_d8_java.javac.jar third_party/r8/custom_d8.jar
44
Mohamed Heikal81e19d92021-09-17 14:50:3245* For r8:
Sam Maierb6c91ba2022-05-06 17:11:4246 * R8 is built daily and uploaded to CIPD.
Mohamed Heikal81e19d92021-09-17 14:50:3247 * New instances are uploaded by the packager bot:
48 https://ci.chromium.org/p/chromium/builders/ci/3pp-linux-amd64-packager
49 * The bot autoruns every 6 hours. Ping a trooper or a clank build core dev to
50 trigger it if you need it sooner:
51 https://luci-scheduler.appspot.com/jobs/chromium/3pp-linux-amd64-packager
Peter Wen91527902021-11-22 17:12:4352 * The autoroller runs automatically when a new cipd instance is uploaded.
53 * Since r8 rolls affect downstream, the roller is only accessible to Googlers.
54 * See its status here: https://skia-autoroll.corp.goog/r/r8-chromium
Peter Wen3d6eb7ee2021-03-03 21:27:4555
56* If patching fails:
Andrew Grieve92f162cf2020-03-31 20:32:3557git clone https://r8.googlesource.com/r8
58cd r8
Sam Maier76dc7a02022-06-30 19:44:5359 * Pull the latest code:
60git pull
Peter Wen3d6eb7ee2021-03-03 21:27:4561 * Apply patches:
Andrew Grieve1762aee2020-08-24 16:17:5462git checkout -b my_branch
Peter Wen4981aa92021-04-27 14:20:4763git am $CHROMIUM_SRC/third_party/r8/3pp/patches/*.patch
Peter Wen3d6eb7ee2021-03-03 21:27:4564 * Fix patch conflicts.
65 * Save new patches. Change number if expecting more or fewer patches:
Andrew Grieve754a0fc02022-05-30 18:52:1566rm $CHROMIUM_SRC/third_party/r8/3pp/patches/*
Andrew Grieve08a8ebac2021-06-24 15:18:3367git format-patch origin/main..HEAD -o $CHROMIUM_SRC/third_party/r8/3pp/patches
Peter Wen3d6eb7ee2021-03-03 21:27:4568 * Submit these fixed patches and the bot will automatically retry.
69
Peter Wen4981aa92021-04-27 14:20:4770* Local development (see above for setting up the r8 repo and applying patches):
Peter Wen3d6eb7ee2021-03-03 21:27:4571 * Build
Andrew Grieve92f162cf2020-03-31 20:32:3572tools/gradle.py r8
Peter Wen3d6eb7ee2021-03-03 21:27:4573 * Shrink (improves r8/d8 launch time):
Andrew Grieve92f162cf2020-03-31 20:32:3574java -jar build/libs/r8.jar --debug --classfile --output r8.jar \
75 --lib $CHROMIUM_SRC/third_party/jdk/current --pg-conf src/main/keep.txt \
76 --no-minification --no-desugaring build/libs/r8.jar
Andrew Grieve089792f2020-10-27 17:49:4477mv $CHROMIUM_SRC/third_party/r8/lib/r8.jar{,.bak}
Sam Maierbaa502f02020-05-21 14:27:5778cp r8.jar $CHROMIUM_SRC/third_party/r8/lib/r8.jar
79
Andrew Grieve605f1fbf2022-12-06 20:55:1280* Update backported methods list (used by lint):
Mohamed Heikal7e1234052020-11-17 16:14:4781cd $CHROMIUM_SRC
Andrew Grieve605f1fbf2022-12-06 20:55:1282java -cp third_party/r8/lib/r8.jar com.android.tools.r8.BackportedMethodList --min-api 24 > third_party/r8/backported_methods.txt
Andrew Grieve9a658442020-10-02 19:38:4483
Andrew Grievebe24d572020-12-04 20:58:5584How to file bugs against R8:
85* Copy & paste the failing ninja command (starts with proguard.py), and add --dump-inputs.
Peter Wen22ce1b02023-11-15 19:59:3086 * On siso you may need to find it at the beginning of `out/<Directory>/siso_output`.
Peter Wen5ef1cbd22021-03-17 22:08:1287 * This also works for dex.py, it produces d8inputs.zip
Andrew Grieve5262fe02022-06-24 02:55:4388 * As a shortcut: third_party/r8/dump_inputs.py out/Release/apks/ChromePublic.apk.mapping
Andrew Grievebe24d572020-12-04 20:58:5589* File bug at go/r8bug
90* Things to include (use discretion if some are not relevant):
91 * src revision bug reproduces at
92 * Repro steps (gn gen & autoninja commands)
93 * Prefer enable_chrome_android_internal=false
94 * The r8inputs.zip from --dump-inputs
95 * Any relevant dexdump analysis
Peter Wen5ef1cbd22021-03-17 22:08:1296
Mohamed Heikalfdaecf122022-09-30 17:32:2897Example R8 git-bisect script:
98```
99set -x
100CHROMIUM_SRC=/media/mheikal/code/clankium/src
101tools/gradle.py r8 || exit -1
102chmod +r $CHROMIUM_SRC/third_party/r8/lib/r8.jar
103rm -f $CHROMIUM_SRC/third_party/r8/lib/r8.jar
104cp build/libs/r8.jar $CHROMIUM_SRC/third_party/r8/lib/r8.jar
105
106cd $CHROMIUM_SRC
107exec tools/autotest.py --out-dir out/Release <Test Here>
108```
109
110You can run this script like so:
111```
112cd $R8_REPO
113git bisect start <known_good_rev> <known_bad_rev>
114git bisect run <path_to_script.sh>
115```
116Tip: When you are done, you can delete the r8 jar and gclient sync to get back
117 to ToT R8.
118 `rm -f $CHROMIUM_SRC/third_party/r8/lib/r8.jar && gclient sync`
119
Peter Wen5ef1cbd22021-03-17 22:08:12120How to submit CLs to R8:
121* Request to be added to their allowlist in order to upload CLs.
122* After CLs are submitted, check the bots for build breakage.
123 * https://ci.chromium.org/p/r8/g/main_all/console