xref: /aosp_15_r20/external/toolchain-utils/llvm_tools/README.md (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1*760c253cSXin Li# LLVM Tools
2*760c253cSXin Li
3*760c253cSXin Li## Overview
4*760c253cSXin Li
5*760c253cSXin LiThese scripts helps automate tasks such as updating the LLVM next hash,
6*760c253cSXin Lideterming whether a new patch applies correctly, and patch management.
7*760c253cSXin Li
8*760c253cSXin LiIn addition, there are scripts that automate the process of retrieving the
9*760c253cSXin Ligit hash of LLVM from either google3, top of trunk, or for a specific SVN
10*760c253cSXin Liversion.
11*760c253cSXin Li
12*760c253cSXin Li**NOTE: All scripts must must be run outside the chroot**
13*760c253cSXin Li
14*760c253cSXin Li**NOTE: sudo must be permissive (i.e. **`cros_sdk`** should NOT prompt for a
15*760c253cSXin Lipassword)**
16*760c253cSXin Li
17*760c253cSXin Li## `update_packages_and_run_tests.py`
18*760c253cSXin Li
19*760c253cSXin Li### Usage
20*760c253cSXin Li
21*760c253cSXin LiThis script is used for updating a package's LLVM hash (sys-devel/llvm,
22*760c253cSXin Lisys-libs/compiler-rt, sys-libs/libcxx, and sys-libs/llvm-libunwind)
23*760c253cSXin Liand then run tests after updating the git hash. There are three ways to test
24*760c253cSXin Lithe change, including starting tryjobs, recipe builders or using cq+1.
25*760c253cSXin Li
26*760c253cSXin LiAn example when this script should be run is when certain boards would like
27*760c253cSXin Lito be tested with the updated `LLVM_NEXT_HASH`.
28*760c253cSXin Li
29*760c253cSXin LiFor example:
30*760c253cSXin Li
31*760c253cSXin Li```
32*760c253cSXin Li$ ./update_packages_and_run_tests.py \
33*760c253cSXin Li  --is_llvm_next \
34*760c253cSXin Li  --llvm_version tot \
35*760c253cSXin Li  tryjobs \
36*760c253cSXin Li  --options nochromesdk latest-toolchain \
37*760c253cSXin Li  --builders kevin-release-tryjob nocturne-release-tryjob
38*760c253cSXin Li```
39*760c253cSXin Li
40*760c253cSXin LiThe above example would update the packages' `LLVM_NEXT_HASH` to the top of
41*760c253cSXin Litrunk's git hash and would submit tryjobs for kevin and nocturne boards, passing
42*760c253cSXin Liin 'nochromesdk' and 'latest-toolchain' for each tryjob.
43*760c253cSXin Li
44*760c253cSXin LiFor help with the command line arguments of the script, run:
45*760c253cSXin Li
46*760c253cSXin Li```
47*760c253cSXin Li$ ./update_packages_and_run_tests.py --help
48*760c253cSXin Li```
49*760c253cSXin Li
50*760c253cSXin LiSimilarly as the previous example, but for updating `LLVM_HASH` to
51*760c253cSXin Ligoogle3 and test with cq+1:
52*760c253cSXin Li
53*760c253cSXin Li```
54*760c253cSXin Li$ ./update_packages_and_run_tests.py \
55*760c253cSXin Li  --llvm_version google3 \
56*760c253cSXin Li  cq
57*760c253cSXin Li```
58*760c253cSXin Li
59*760c253cSXin LiSimilarly as the previous example, but for updating `LLVM_NEXT_HASH` to
60*760c253cSXin Lithe git hash of revision 367622 and test with recipe builders:
61*760c253cSXin Li
62*760c253cSXin Li```
63*760c253cSXin Li$ ./update_packages_and_run_tests.py \
64*760c253cSXin Li  --is_llvm_next \
65*760c253cSXin Li  --llvm_version 367622 \
66*760c253cSXin Li  recipe \
67*760c253cSXin Li  --options -nocanary \
68*760c253cSXin Li  --builders chromeos/toolchain/kevin-llvm chromeos/toolchain/nocturne-llvm
69*760c253cSXin Li```
70*760c253cSXin Li
71*760c253cSXin Li## `update_chromeos_llvm_hash.py`
72*760c253cSXin Li
73*760c253cSXin Li### Usage
74*760c253cSXin Li
75*760c253cSXin LiThis script is used for updating a package's/packages' LLVM hashes and
76*760c253cSXin Licreating a change list of those changes which will uploaded for review. For
77*760c253cSXin Liexample, some changes that would be included in the change list are
78*760c253cSXin Lithe updated ebuilds, changes made to the patches of the updated packages such
79*760c253cSXin Lias being removed or an updated patch metadata file. These changes are determined
80*760c253cSXin Liby the `--failure_mode` option.
81*760c253cSXin Li
82*760c253cSXin LiAn example where this script would be used is when multiple packages need to
83*760c253cSXin Lihave their `LLVM_NEXT_HASH` updated.
84*760c253cSXin Li
85*760c253cSXin LiFor example:
86*760c253cSXin Li
87*760c253cSXin Li```
88*760c253cSXin Li$ ./update_chromeos_llvm_hash.py \
89*760c253cSXin Li  --update_packages sys-devel/llvm sys-libs/compiler-rt \
90*760c253cSXin Li  --is_llvm_next \
91*760c253cSXin Li  --llvm_version google3 \
92*760c253cSXin Li  --failure_mode disable_patches
93*760c253cSXin Li```
94*760c253cSXin Li
95*760c253cSXin LiThe example above would update sys-devel/llvm and sys-libs/compiler-rt's
96*760c253cSXin Li`LLVM_NEXT_HASH` to the latest google3's git hash of LLVM. And the change list
97*760c253cSXin Limay include patches that were disabled for either sys-devel/llvm or
98*760c253cSXin Lisys-libs/compiler-rt.
99*760c253cSXin Li
100*760c253cSXin LiFor help with the command line arguments of the script, run:
101*760c253cSXin Li
102*760c253cSXin Li```
103*760c253cSXin Li$ ./update_chromeos_llvm_hash.py --help
104*760c253cSXin Li```
105*760c253cSXin Li
106*760c253cSXin LiFor example, to update `LLVM_HASH` to top of trunk of LLVM:
107*760c253cSXin Li
108*760c253cSXin Li```
109*760c253cSXin Li$ ./update_chromeos_llvm_hash.py \
110*760c253cSXin Li  --update_packages sys-devel/llvm sys-libs/compiler-rt \
111*760c253cSXin Li  --llvm_version tot \
112*760c253cSXin Li  --failure_mode disable_patches
113*760c253cSXin Li```
114*760c253cSXin Li
115*760c253cSXin LiFor example, to create a roll CL to the git hash of revision 367622:
116*760c253cSXin Li
117*760c253cSXin Li```
118*760c253cSXin Li$ ./update_chromeos_llvm_hash.py \
119*760c253cSXin Li  --update_packages sys-devel/llvm sys-libs/compiler-rt \
120*760c253cSXin Li  sys-libs/libcxx sys-libs/llvm-libunwind \
121*760c253cSXin Li  'dev-util/lldb-server' \
122*760c253cSXin Li  --llvm_version 367622 \
123*760c253cSXin Li  --failure_mode disable_patches
124*760c253cSXin Li```
125*760c253cSXin Li
126*760c253cSXin Li## `patch_manager.py`
127*760c253cSXin Li
128*760c253cSXin Li### Usage
129*760c253cSXin Li
130*760c253cSXin LiThis script is used when when all the command line arguments are known such as
131*760c253cSXin Litesting a specific metadata file or a specific source tree.
132*760c253cSXin Li
133*760c253cSXin LiFor help with the command line arguments of the script, run:
134*760c253cSXin Li
135*760c253cSXin Li```
136*760c253cSXin Li$ ./patch_manager.py --help
137*760c253cSXin Li```
138*760c253cSXin Li
139*760c253cSXin LiFor example, to see all the failed (if any) patches:
140*760c253cSXin Li
141*760c253cSXin Li```
142*760c253cSXin Li$ ./patch_manager.py \
143*760c253cSXin Li  --svn_version 367622 \
144*760c253cSXin Li  --patch_metadata_file /abs/path/to/patch/file \
145*760c253cSXin Li  --src_path /abs/path/to/src/tree \
146*760c253cSXin Li  --failure_mode continue
147*760c253cSXin Li```
148*760c253cSXin Li
149*760c253cSXin LiFor example, to disable all patches that failed to apply:
150*760c253cSXin Li
151*760c253cSXin Li```
152*760c253cSXin Li$ ./patch_manager.py \
153*760c253cSXin Li  --svn_version 367622 \
154*760c253cSXin Li  --patch_metadata_file /abs/path/to/patch/file \
155*760c253cSXin Li  --src_path /abs/path/to/src/tree \
156*760c253cSXin Li  --failure_mode disable_patches
157*760c253cSXin Li```
158*760c253cSXin Li
159*760c253cSXin LiFor example, to bisect a failing patch and stop at the first bisected patch:
160*760c253cSXin Li
161*760c253cSXin Li```
162*760c253cSXin Li$ ./patch_manager.py \
163*760c253cSXin Li  --svn_version 367622 \
164*760c253cSXin Li  --patch_metadata_file /abs/path/to/patch/file \
165*760c253cSXin Li  --src_path /abs/path/to/src/tree \
166*760c253cSXin Li  --failure_mode bisect_patches \
167*760c253cSXin Li  --good_svn_version 365631
168*760c253cSXin Li```
169*760c253cSXin Li
170*760c253cSXin LiFor example, to bisect a failing patch and then continue bisecting the rest of
171*760c253cSXin Lithe failed patches:
172*760c253cSXin Li
173*760c253cSXin Li```
174*760c253cSXin Li$ ./patch_manager.py \
175*760c253cSXin Li  --svn_version 367622 \
176*760c253cSXin Li  --patch_metadata_file /abs/path/to/patch/file \
177*760c253cSXin Li  --src_path /abs/path/to/src/tree \
178*760c253cSXin Li  --failure_mode bisect_patches \
179*760c253cSXin Li  --good_svn_version 365631 \
180*760c253cSXin Li  --continue_bisection True
181*760c253cSXin Li```
182*760c253cSXin Li
183*760c253cSXin Li## LLVM Bisection
184*760c253cSXin Li
185*760c253cSXin Li### `llvm_bisection.py`
186*760c253cSXin Li
187*760c253cSXin Li#### Usage
188*760c253cSXin Li
189*760c253cSXin LiThis script is used to bisect a bad revision of LLVM. After the script finishes,
190*760c253cSXin Lithe user requires to run the script again to continue the bisection. Intially,
191*760c253cSXin Lithe script creates a JSON file that does not exist which then continues
192*760c253cSXin Libisection (after invoking the script again) based off of the JSON file.
193*760c253cSXin Li
194*760c253cSXin LiFor example, assuming the revision 369420 is the bad revision:
195*760c253cSXin Li
196*760c253cSXin Li```
197*760c253cSXin Li$ ./llvm_bisection.py \
198*760c253cSXin Li  --parallel 3 \
199*760c253cSXin Li  --start_rev 369410 \
200*760c253cSXin Li  --end_rev 369420 \
201*760c253cSXin Li  --last_tested /abs/path/to/tryjob/file/ \
202*760c253cSXin Li  --extra_change_lists 513590 \
203*760c253cSXin Li  --builder eve-release-tryjob \
204*760c253cSXin Li  --options latest-toolchain
205*760c253cSXin Li```
206*760c253cSXin Li
207*760c253cSXin LiThe above example bisects the bad revision (369420), starting from the good
208*760c253cSXin Lirevision 369410 and launching 3 tryjobs in between if possible (`--parallel`).
209*760c253cSXin LiHere, the `--last_tested` path is a path to a JSON file that does not exist. The
210*760c253cSXin Litryjobs are tested on the eve board. `--extra_change_lists` and `--options`
211*760c253cSXin Liindicate what parameters to pass into launching a tryjob.
212*760c253cSXin Li
213*760c253cSXin LiFor help with the command line arguments of the script, run:
214*760c253cSXin Li
215*760c253cSXin Li```
216*760c253cSXin Li$ ./llvm_bisection.py --help
217*760c253cSXin Li```
218*760c253cSXin Li
219*760c253cSXin Li### `auto_llvm_bisection.py`
220*760c253cSXin Li
221*760c253cSXin Li#### Usage
222*760c253cSXin Li
223*760c253cSXin LiThis script automates the LLVM bisection process by using `cros buildresult` to
224*760c253cSXin Liupdate the status of each tryjob.
225*760c253cSXin Li
226*760c253cSXin LiAn example when this script would be used to do LLVM bisection overnight
227*760c253cSXin Libecause tryjobs take very long to finish.
228*760c253cSXin Li
229*760c253cSXin LiFor example, assuming the good revision is 369410 and the bad revision is
230*760c253cSXin Li369420, then:
231*760c253cSXin Li
232*760c253cSXin Li```
233*760c253cSXin Li$ ./auto_llvm_bisection.py --start_rev 369410 --end_rev 369420 \
234*760c253cSXin Li  --last_tested /abs/path/to/last_tested_file.json \
235*760c253cSXin Li  --extra_change_lists 513590 1394249 \
236*760c253cSXin Li  --options latest-toolchain nochromesdk \
237*760c253cSXin Li  --chromeos_path /path/to/chromeos/chroot \
238*760c253cSXin Li  --builder eve-release-tryjob
239*760c253cSXin Li```
240*760c253cSXin Li
241*760c253cSXin LiThe example above bisects LLVM between revision 369410 and 369420. If the file
242*760c253cSXin Liexists, the script resumes bisection. Otherwise, the script creates the file
243*760c253cSXin Liprovided by `--last_tested`. `--extra_change_lists` and `--options` are used for
244*760c253cSXin Lieach tryjob when being submitted. Lastly, the tryjobs are launched for the board
245*760c253cSXin Liprovided by `--builder` (in this example, for the eve board).
246*760c253cSXin Li
247*760c253cSXin LiFor help with the command line arguments of the script, run:
248*760c253cSXin Li
249*760c253cSXin Li```
250*760c253cSXin Li$ ./auto_llvm_bisection.py --help
251*760c253cSXin Li```
252*760c253cSXin Li
253*760c253cSXin Li### `update_tryjob_status.py`
254*760c253cSXin Li
255*760c253cSXin Li#### Usage
256*760c253cSXin Li
257*760c253cSXin LiThis script updates a tryjob's 'status' value when bisecting LLVM. This script
258*760c253cSXin Lican use the file that was created by `llvm_bisection.py`.
259*760c253cSXin Li
260*760c253cSXin LiAn example when this script would be used is when the result of tryjob that was
261*760c253cSXin Lilaunched was 'fail' (due to flaky infra) but it should really have been
262*760c253cSXin Li'success'.
263*760c253cSXin Li
264*760c253cSXin LiFor example, to update a tryjob's 'status' to 'good':
265*760c253cSXin Li
266*760c253cSXin Li```
267*760c253cSXin Li$ ./update_tryjob_status.py \
268*760c253cSXin Li  --set_status good \
269*760c253cSXin Li  --revision 369412 \
270*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
271*760c253cSXin Li```
272*760c253cSXin Li
273*760c253cSXin LiThe above example uses the file in `--status_file` to update a tryjob in that
274*760c253cSXin Lifile that tested the revision 369412 and sets its 'status' value to 'good'.
275*760c253cSXin Li
276*760c253cSXin LiFor help with the command line arguments of the script, run:
277*760c253cSXin Li
278*760c253cSXin Li```
279*760c253cSXin Li$ ./update_tryjob_status.py --help
280*760c253cSXin Li```
281*760c253cSXin Li
282*760c253cSXin LiFor example, to update a tryjob's 'status' to 'bad':
283*760c253cSXin Li
284*760c253cSXin Li```
285*760c253cSXin Li$ ./update_tryjob_status.py \
286*760c253cSXin Li  --set_status bad \
287*760c253cSXin Li  --revision 369412 \
288*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
289*760c253cSXin Li```
290*760c253cSXin Li
291*760c253cSXin LiFor example, to update a tryjob's 'status' to 'pending':
292*760c253cSXin Li
293*760c253cSXin Li```
294*760c253cSXin Li$ ./update_tryjob_status.py \
295*760c253cSXin Li  --set_status pending \
296*760c253cSXin Li  --revision 369412 \
297*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
298*760c253cSXin Li```
299*760c253cSXin Li
300*760c253cSXin LiFor example, to update a tryjob's 'status' to 'skip':
301*760c253cSXin Li
302*760c253cSXin Li```
303*760c253cSXin Li$ ./update_tryjob_status.py \
304*760c253cSXin Li  --set_status skip \
305*760c253cSXin Li  --revision 369412 \
306*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
307*760c253cSXin Li```
308*760c253cSXin Li
309*760c253cSXin LiFor example, to update a tryjob's 'status' based off a custom script exit code:
310*760c253cSXin Li
311*760c253cSXin Li```
312*760c253cSXin Li$ ./update_tryjob_status.py \
313*760c253cSXin Li  --set_status custom_script \
314*760c253cSXin Li  --revision 369412 \
315*760c253cSXin Li  --status_file /abs/path/to/tryjob/file \
316*760c253cSXin Li  --custom_script /abs/path/to/script.py
317*760c253cSXin Li```
318*760c253cSXin Li
319*760c253cSXin Li### `modify_a_tryjob.py`
320*760c253cSXin Li
321*760c253cSXin Li#### Usage
322*760c253cSXin Li
323*760c253cSXin LiThis script modifies a tryjob directly given an already created tryjob file when
324*760c253cSXin Libisecting LLVM. The file created by `llvm_bisection.py` can be used in this
325*760c253cSXin Liscript.
326*760c253cSXin Li
327*760c253cSXin LiAn example when this script would be used is when a tryjob needs to be manually
328*760c253cSXin Liadded.
329*760c253cSXin Li
330*760c253cSXin LiFor example:
331*760c253cSXin Li
332*760c253cSXin Li```
333*760c253cSXin Li$ ./modify_a_tryjob.py \
334*760c253cSXin Li  --modify_a_tryjob add \
335*760c253cSXin Li  --revision 369416 \
336*760c253cSXin Li  --extra_change_lists 513590 \
337*760c253cSXin Li  --options latest-toolchain \
338*760c253cSXin Li  --builder eve-release-tryjob \
339*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
340*760c253cSXin Li```
341*760c253cSXin Li
342*760c253cSXin LiThe above example creates a tryjob that tests revision 369416 on the eve board,
343*760c253cSXin Lipassing in the extra arguments (`--extra_change_lists` and `--options`). The
344*760c253cSXin Litryjob is then inserted into the file passed in via `--status_file`.
345*760c253cSXin Li
346*760c253cSXin LiFor help with the command line arguments of the script, run:
347*760c253cSXin Li
348*760c253cSXin Li```
349*760c253cSXin Li$ ./modify_a_tryjob.py --help
350*760c253cSXin Li```
351*760c253cSXin Li
352*760c253cSXin LiFor example, to remove a tryjob that tested revision 369412:
353*760c253cSXin Li
354*760c253cSXin Li```
355*760c253cSXin Li$ ./modify_a_tryjob.py \
356*760c253cSXin Li  --modify_a_tryjob remove \
357*760c253cSXin Li  --revision 369412 \
358*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
359*760c253cSXin Li```
360*760c253cSXin Li
361*760c253cSXin LiFor example, to relaunch a tryjob that tested revision 369418:
362*760c253cSXin Li
363*760c253cSXin Li```
364*760c253cSXin Li$ ./modify_a_tryjob.py \
365*760c253cSXin Li  --modify_a_tryjob relaunch \
366*760c253cSXin Li  --revision 369418 \
367*760c253cSXin Li  --status_file /abs/path/to/tryjob/file
368*760c253cSXin Li```
369*760c253cSXin Li
370*760c253cSXin Li## Other Helpful Scripts
371*760c253cSXin Li
372*760c253cSXin Li### `get_llvm_hash.py`
373*760c253cSXin Li
374*760c253cSXin Li#### Usage
375*760c253cSXin Li
376*760c253cSXin LiThe script has a class that deals with retrieving either the top of trunk git
377*760c253cSXin Lihash of LLVM, the git hash of google3, or a specific git hash of a SVN version.
378*760c253cSXin LiIt also has other functions when dealing with a git hash of LLVM.
379*760c253cSXin Li
380*760c253cSXin LiIn addition, it has a function to retrieve the latest google3 LLVM version.
381*760c253cSXin Li
382*760c253cSXin LiFor example, to retrieve the top of trunk git hash of LLVM:
383*760c253cSXin Li
384*760c253cSXin Li```
385*760c253cSXin Lifrom get_llvm_hash import LLVMHash
386*760c253cSXin Li
387*760c253cSXin LiLLVMHash().GetTopOfTrunkGitHash()
388*760c253cSXin Li```
389*760c253cSXin Li
390*760c253cSXin LiFor example, to retrieve the git hash of google3:
391*760c253cSXin Li
392*760c253cSXin Li```
393*760c253cSXin Lifrom get_llvm_hash import LLVMHash
394*760c253cSXin Li
395*760c253cSXin LiLLVMHash().GetGoogle3LLVMHash()
396*760c253cSXin Li```
397*760c253cSXin Li
398*760c253cSXin LiFor example, to retrieve the git hash of a specific SVN version:
399*760c253cSXin Li
400*760c253cSXin Li```
401*760c253cSXin Lifrom get_llvm_hash import LLVMHash
402*760c253cSXin Li
403*760c253cSXin LiLLVMHash().GetLLVMHash(<svn_version>)
404*760c253cSXin Li```
405*760c253cSXin Li
406*760c253cSXin LiFor example, to retrieve the latest google3 LLVM version:
407*760c253cSXin Li
408*760c253cSXin Li```
409*760c253cSXin Lifrom get_llvm_hash import GetGoogle3LLVMVersion
410*760c253cSXin Li
411*760c253cSXin LiGetGoogle3LLVMVersion(stable=True)
412*760c253cSXin Li```
413*760c253cSXin Li
414*760c253cSXin Li### `git_llvm_rev.py`
415*760c253cSXin Li
416*760c253cSXin LiThis script is meant to synthesize LLVM revision numbers, and translate between
417*760c253cSXin Lithese synthesized numbers and git SHAs. Usage should be straightforward:
418*760c253cSXin Li
419*760c253cSXin Li```
420*760c253cSXin Li~> ./git_llvm_rev.py --llvm_dir llvm-project-copy/ --rev r380000
421*760c253cSXin Li6f635f90929da9545dd696071a829a1a42f84b30
422*760c253cSXin Li~> ./git_llvm_rev.py --llvm_dir llvm-project-copy/ --sha 6f635f90929da9545dd696071a829a1a42f84b30
423*760c253cSXin Lir380000
424*760c253cSXin Li~> ./git_llvm_rev.py --llvm_dir llvm-project-copy/ --sha origin/some-branch
425*760c253cSXin Lir387778
426*760c253cSXin Li```
427*760c253cSXin Li
428*760c253cSXin Li**Tip**: if you put a symlink called `git-llvm-rev` to this script somewhere on
429*760c253cSXin Liyour `$PATH`, you can also use it as `git llvm-rev`.
430*760c253cSXin Li
431*760c253cSXin Li### `get_upstream_patch.py`
432*760c253cSXin Li
433*760c253cSXin Li#### Usage
434*760c253cSXin Li
435*760c253cSXin LiThis script updates the proper ChromeOS packages with LLVM patches of your choosing, and
436*760c253cSXin Licopies the patches into patch folders of the packages. This tool supports both git hash
437*760c253cSXin Liof commits as well as differential reviews.
438*760c253cSXin Li
439*760c253cSXin LiUsage:
440*760c253cSXin Li
441*760c253cSXin Li```
442*760c253cSXin Li./get_upstream_patch.py --chromeos_path /abs/path/to/chroot --start_sha llvm
443*760c253cSXin Li--sha 174c3eb69f19ff2d6a3eeae31d04afe77e62c021 --sha 174c3eb69f19ff2d6a3eeae31d04afe77e62c021
444*760c253cSXin Li--differential D123456
445*760c253cSXin Li```
446*760c253cSXin Li
447*760c253cSXin LiIt tries to autodetect a lot of things (e.g., packages changed by each sha,
448*760c253cSXin Litheir ebuild paths, the "start"/"end" revisions to set, etc.) By default the
449*760c253cSXin Liscript creates a local patch. Use --create_cl option to create a CL instead. For
450*760c253cSXin Limore information, please see the `--help`
451*760c253cSXin Li
452*760c253cSXin Li### `revert_checker.py`
453*760c253cSXin Li
454*760c253cSXin Li**This script is copied from upstream LLVM. Please prefer to make upstream edits,
455*760c253cSXin Lirather than modifying this script. It's kept in a CrOS repo so we don't need an
456*760c253cSXin LiLLVM tree to `import` this from scripts here.**
457*760c253cSXin Li
458*760c253cSXin LiThis script reports reverts which happen 'across' a certain LLVM commit.
459*760c253cSXin Li
460*760c253cSXin LiTo clarify the meaning of 'across' with an example, if we had the following
461*760c253cSXin Licommit history (where `a -> b` notes that `b` is a direct child of `a`):
462*760c253cSXin Li
463*760c253cSXin Li123abc -> 223abc -> 323abc -> 423abc -> 523abc
464*760c253cSXin Li
465*760c253cSXin LiAnd where 423abc is a revert of 223abc, this revert is considered to be 'across'
466*760c253cSXin Li323abc. More generally, a revert A of a parent commit B is considered to be
467*760c253cSXin Li'across' a commit C if C is a parent of A and B is a parent of C.
468*760c253cSXin Li
469*760c253cSXin LiUsage example:
470*760c253cSXin Li
471*760c253cSXin Li```
472*760c253cSXin Li./revert_checker.py -C llvm-project-copy 123abc 223abc 323abc
473*760c253cSXin Li```
474*760c253cSXin Li
475*760c253cSXin LiIn the above example, the tool will scan all commits between 123abc and 223abc,
476*760c253cSXin Liand all commits between 123abc and 323abc for reverts of commits which are
477*760c253cSXin Liparents of 123abc.
478*760c253cSXin Li
479*760c253cSXin Li### `nightly_revert_checker.py`
480*760c253cSXin Li
481*760c253cSXin LiThis is an automated wrapper around `revert_checker.py`. It checks to see if any
482*760c253cSXin Linew reverts happened across toolchains that we're trying to ship since it was
483*760c253cSXin Lilast run. If so, it either automatically cherry-picks the reverts, or sends
484*760c253cSXin Liemails to appropriate groups.
485*760c253cSXin Li
486*760c253cSXin LiUsage example for cherry-picking:
487*760c253cSXin Li```
488*760c253cSXin LiPYTHONPATH=../ ./nightly_revert_checker.py \
489*760c253cSXin Li  cherry-pick
490*760c253cSXin Li  --state_file state.json \
491*760c253cSXin Li  --llvm_dir llvm-project-copy \
492*760c253cSXin Li  --chromeos_dir ../../../../
493*760c253cSXin Li  [email protected]
494*760c253cSXin Li```
495*760c253cSXin Li
496*760c253cSXin LiUsage example for email:
497*760c253cSXin Li```
498*760c253cSXin LiPYTHONPATH=../ ./nightly_revert_checker.py \
499*760c253cSXin Li  email
500*760c253cSXin Li  --state_file state.json \
501*760c253cSXin Li  --llvm_dir llvm-project-copy \
502*760c253cSXin Li  --chromeos_dir ../../../../
503*760c253cSXin Li```
504*760c253cSXin Li
505*760c253cSXin Li### `bisect_clang_crashes.py`
506*760c253cSXin Li
507*760c253cSXin LiThis script downloads clang crash diagnoses from
508*760c253cSXin Ligs://chromeos-toolchain-artifacts/clang-crash-diagnoses and sends them to 4c for
509*760c253cSXin Libisection.
510*760c253cSXin Li
511*760c253cSXin LiUsage example:
512*760c253cSXin Li
513*760c253cSXin Li```
514*760c253cSXin Li$ ./bisect_clang_crashes.py --4c 4c-cli --state_file ./output/state.json
515*760c253cSXin Li```
516*760c253cSXin Li
517*760c253cSXin LiThe above command downloads the artifacts of clang crash diagnoses and send them
518*760c253cSXin Lito 4c server for bisection. The summary of submitted jobs will be saved in
519*760c253cSXin Lioutput/state.json under the current path. The output directory will be created
520*760c253cSXin Liautomatically if it does not exist yet. To get more information of the submitted
521*760c253cSXin Lijobs, please refer to go/4c-cli.
522*760c253cSXin Li
523*760c253cSXin Li### `upload_lexan_crashes_to_forcey.py`
524*760c253cSXin Li
525*760c253cSXin LiThis script downloads clang crash diagnoses from Lexan's bucket and sends them
526*760c253cSXin Lito 4c for bisection.
527*760c253cSXin Li
528*760c253cSXin LiUsage example:
529*760c253cSXin Li
530*760c253cSXin Li```
531*760c253cSXin Li$ ./upload_lexan_crashes_to_forcey.py --4c 4c-cli \
532*760c253cSXin Li    --state_file ./output/state.json
533*760c253cSXin Li```
534*760c253cSXin Li
535*760c253cSXin LiThe above command downloads the artifacts of clang crash diagnoses and send them
536*760c253cSXin Lito 4c server for bisection. The summary of submitted jobs will be saved in
537*760c253cSXin Lioutput/state.json under the current path. The output directory will be created
538*760c253cSXin Liautomatically if it does not exist yet. To get more information of the submitted
539*760c253cSXin Lijobs, please refer to go/4c-cli.
540*760c253cSXin Li
541*760c253cSXin LiNote that it's recommended to 'seed' the state file with a most recent upload
542*760c253cSXin Lidate. This can be done by running this tool *once* with a `--last_date` flag.
543*760c253cSXin LiThis flag has the script override whatever's in the state file (if anything) and
544*760c253cSXin Listart submitting all crashes uploaded starting at the given day.
545*760c253cSXin Li
546*760c253cSXin Li### `werror_logs.py`
547*760c253cSXin Li
548*760c253cSXin LiThis tool exists to help devs reason about `-Werror` instances that _would_
549*760c253cSXin Libreak builds, were the `FORCE_DISABLE_WERROR` support in the compiler wrapper
550*760c253cSXin Linot enabled.
551*760c253cSXin Li
552*760c253cSXin LiUsage example:
553*760c253cSXin Li
554*760c253cSXin Li```
555*760c253cSXin Li$ ./werror_logs.py aggregate \
556*760c253cSXin Li    --directory=${repo}/out/sdk/tmp/portage/dev-cpp/gtest-1.13.0-r12/cros-artifacts
557*760c253cSXin Li```
558*760c253cSXin Li
559*760c253cSXin Li## `fetch_cq_size_diff.py`
560*760c253cSXin Li
561*760c253cSXin LiThis script should be runnable both inside and outside of the chroot.
562*760c253cSXin Li
563*760c253cSXin LiThis script exists to help users fill in the llvm-next testing matrix. It's
564*760c253cSXin Licapable of comparing the sizes of ChromeOS images, and the size of Chrome's
565*760c253cSXin Lidebuginfo. An example of this is:
566*760c253cSXin Li
567*760c253cSXin Li```
568*760c253cSXin Li$ ./fetch_cq_size_diff.py --image gs \
569*760c253cSXin Li  gs://chromeos-image-archive/asurada-release/R122-15712.0.0/image.zip
570*760c253cSXin Li  gs://chromeos-image-archive/asurada-cq/R122-15712.0.0-92036-8761629109681962289/image.zip
571*760c253cSXin Li```
572*760c253cSXin Li
573*760c253cSXin LiFor convenience, this script can also figure out what to compare from a CL, like
574*760c253cSXin Liso:
575*760c253cSXin Li
576*760c253cSXin Li```
577*760c253cSXin Li$ ./fetch_cq_size_diff.py --image cl \
578*760c253cSXin Li  https://chromium-review.googlesource.com/c/chromiumos/overlays/board-overlays/+/5126116/3
579*760c253cSXin Li```
580*760c253cSXin Li
581*760c253cSXin LiIn the above case, this script will find a completed CQ build associated with
582*760c253cSXin LiPatchSet 3 of the given CL, and compare the `image.zip` generated by said build
583*760c253cSXin Liwith the image.zip generated by a release builder for the same board. CQ
584*760c253cSXin Liattempts don't have to be entirely green for this; as long as there're a few
585*760c253cSXin Ligreen boards to pick from, this script should be able to make a comparison.
586