xref: /aosp_15_r20/external/toolchain-utils/compiler_wrapper/README.md (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1*760c253cSXin LiCopyright 2023 The ChromiumOS Authors
2*760c253cSXin LiUse of this source code is governed by a BSD-style license that can be
3*760c253cSXin Lifound in the LICENSE file.
4*760c253cSXin Li
5*760c253cSXin Li### What
6*760c253cSXin LiToolchain utils compiler wrapper sources.
7*760c253cSXin Li
8*760c253cSXin LiPlease note that there's a regular syncing operation between
9*760c253cSXin Li`chromiumos-overlay/sys-devel/llvm/files/compiler_wrapper` and
10*760c253cSXin Li`toolchain-utils/compiler_wrapper`. This sync is one way (from
11*760c253cSXin Lichromiumos-overlay to `toolchain-utils`). Syncing in this way helps the Android
12*760c253cSXin Litoolchain keep up-to-date with our wrapper easily, as they're a downstream
13*760c253cSXin Liconsumer of it. For this reason, **please be sure to land all actual changes in
14*760c253cSXin Lichromeos-overlay**.
15*760c253cSXin Li
16*760c253cSXin Li### Build + Run Tests
17*760c253cSXin Li1. Install the wrapper locally in chroot (builds as well)
18*760c253cSXin Li```
19*760c253cSXin Li(chroot) ./install_compiler_wrapper.sh
20*760c253cSXin Li```
21*760c253cSXin Li
22*760c253cSXin Li#### Running a manual test
23*760c253cSXin LiTest a manual build command with `-print-cmdline`
24*760c253cSXin Li```
25*760c253cSXin Li(chroot) x86_64-cros-linux-gnu-clang++ -o test_exec -f<some_flag_to_add>='some_value' -print-cmdline test.cc
26*760c253cSXin Li```
27*760c253cSXin Li-  `test.cc` doesn't actually have to exist.
28*760c253cSXin Li-  The command above will output the additional build flags that are added in by the wrapper.
29*760c253cSXin Li
30*760c253cSXin Li#### Testing your changes
31*760c253cSXin Li1. Add tests to your wrapper changes
32*760c253cSXin Li1. Run all the tests via:
33*760c253cSXin Li```
34*760c253cSXin Ligo test -vet=all
35*760c253cSXin Li```
36*760c253cSXin Li
37*760c253cSXin Li### Build Only
38*760c253cSXin LiThis is handy if you just want to test that the build works.
39*760c253cSXin Li
40*760c253cSXin LiBuild the wrapper:
41*760c253cSXin Li```
42*760c253cSXin Li./build.py --config=<config name> --use_ccache=<bool> \
43*760c253cSXin Li  --use_llvm_next=<bool> --output_file=<file>
44*760c253cSXin Li  ```
45