• Home
Name Date Size #Lines LOC

..--

testdata/03-May-2024-19,03518,977

README.mdD03-May-20243.9 KiB10478

android_config_test.goD03-May-20243.2 KiB133121

android_llvm_next_flags.goD01-Jan-19700

bisect_flag.goD03-May-20241.7 KiB7864

bisect_flag_test.goD03-May-20245.6 KiB185164

build.pyD03-May-20243.7 KiB12994

bundle.READMED03-May-2024582 1913

bundle.pyD03-May-20242.7 KiB9470

ccache_flag.goD03-May-20242.1 KiB6132

ccache_flag_test.goD03-May-20245.3 KiB190164

clang_flags.goD03-May-20246.1 KiB196132

clang_flags_test.goD03-May-20249.3 KiB313283

clang_syntax_flag.goD03-May-20241.1 KiB3829

clang_syntax_flag_test.goD03-May-20245.3 KiB181163

clang_tidy_flag.goD03-May-20246.7 KiB242196

clang_tidy_flag_test.goD03-May-202412.3 KiB452413

command.goD03-May-20247.5 KiB298256

command_test.goD03-May-20241.2 KiB4033

compile_with_fallback.goD03-May-20243.7 KiB11088

compile_with_fallback_test.goD03-May-20248.7 KiB304276

compiler_wrapper.goD03-May-202414 KiB449379

compiler_wrapper_test.goD03-May-20247.3 KiB255225

config.goD03-May-20247.1 KiB241173

config_test.goD03-May-20242.7 KiB135111

crash_builds.goD03-May-20245.4 KiB15595

crash_builds_test.goD03-May-20247 KiB261225

cros_hardened_config_test.goD03-May-202414.7 KiB547513

cros_host_config_test.goD03-May-20242.4 KiB9576

cros_llvm_next_flags.goD03-May-2024762 203

cros_nonhardened_config_test.goD03-May-2024647 2818

disable_werror_flag.goD03-May-20249.6 KiB304227

disable_werror_flag_test.goD03-May-202416.6 KiB594535

env.goD03-May-20244.4 KiB174131

env_test.goD03-May-20248.3 KiB336285

errors.goD03-May-20242.2 KiB8769

errors_test.goD03-May-20242 KiB7360

gcc_flags.goD03-May-2024698 3019

gcc_flags_test.goD03-May-20241.5 KiB6251

go.modD03-May-202462 42

go_exec.goD03-May-2024620 2511

goldenutil_test.goD03-May-20245.8 KiB201175

install_compiler_wrapper.shD03-May-20242.5 KiB7351

iwyu_flag.goD03-May-20244 KiB157123

iwyu_flag_test.goD03-May-20243.7 KiB136124

kernel_bug.goD03-May-2024781 2612

kernel_bug_test.goD03-May-20242.4 KiB7564

libc_exec.goD03-May-20243 KiB10335

libgcc_flags.goD03-May-2024640 2617

libgcc_flags_test.goD03-May-20241.4 KiB5846

main.goD03-May-20241.3 KiB4316

print_cmdline_flag.goD03-May-2024446 2014

print_cmdline_flag_test.goD03-May-20242.6 KiB8672

print_config_flag.goD03-May-2024500 2215

print_config_flag_test.goD03-May-2024809 2921

remote_build_flag_test.goD03-May-20248 KiB252218

remote_build_flags.goD03-May-20244.1 KiB161117

reset_compiler_wrapper.shD03-May-20241.2 KiB4321

rusage_flag.goD03-May-20245.2 KiB161121

rusage_flag_test.goD03-May-20245.3 KiB168144

sanitizer_flags.goD03-May-20242.8 KiB8754

sanitizer_flags_test.goD03-May-20244.6 KiB141117

stackprotector_flags.goD03-May-2024751 3023

stackprotector_flags_test.goD03-May-20241.7 KiB5847

sysroot_flag.goD03-May-20241 KiB4536

sysroot_flag_test.goD03-May-20242.4 KiB8471

testutil_test.goD03-May-20249.4 KiB350290

thumb_flags.goD03-May-2024874 2816

thumb_flags_test.goD03-May-20243 KiB11493

unsupported_flags.goD03-May-2024365 159

unsupported_flags_test.goD03-May-2024526 2114

x64_flags.goD03-May-2024499 2213

x64_flags_test.goD03-May-20241,007 4031

README.md

1# Compiler wrapper
2
3See the comments on the top of main.go.
4Build is split into 2 steps via separate commands:
5- bundle: copies the sources and the `build.py` file into
6  a folder.
7- build: builds the actual go binary, assuming it is executed
8  from the folder created by `bundle.py`.
9
10This allows to copy the sources to a ChromeOS / Android
11package, including the build script, and then
12build from there without a dependency on toolchain-utils
13itself.
14
15## Testing Inside the Chroot
16
17To test updates to the wrapper locally:
18
19Run `install_compiler_wrapper.sh` to install the new wrapper in the chroot:
20```
21(chroot) ~/trunk/src/third_party/toolchain-utils/compiler_wrapper/install_compiler_wrapper.sh
22```
23
24Then perform the tests, e.g. build with the new compiler.
25
26
27## Updating the Wrapper for ChromeOS
28
29To update the wrapper for everyone, the new wrapper configuration must be copied
30into chromiumos-overlay, and new revisions of the gcc and llvm ebuilds must be
31created.
32
33Copy over sources and `build.py` to chromiumos-overlay:
34```
35(chroot) /mnt/host/source/src/third_party/chromiumos-overlay/sys-devel/llvm/files/update_compiler_wrapper.sh
36```
37
38Rename chromiumos-overlay/sys-devel/llvm/llvm-${VERSION}.ebuild to the next
39revision number. For example, if the current version is
4011.0_pre394483_p20200618-r2:
41```
42(chroot) cd ~/trunk/src/third_party/chromiumos-overlay
43(chroot) git mv llvm-11.0_pre394483_p20200618-r2.ebuild llvm-11.0_pre394483_p20200618-r3.ebuild
44```
45
46Rename chromiumos-overlay/sys-devel/gcc/gcc-${VERSION}.ebuild to the next
47revision number.  For example, if the current version is 10.2.0-r3:
48```
49(chroot) cd ~/trunk/src/third_party/chromiumos-overlay
50(chroot) git mv sys-devel/gcc/gcc-10.2.0-r3.ebuild sys-devel/gcc/gcc-10.2.0-r4.ebuild
51```
52
53Commit those changes together with the changes made by
54`update_compiler_wrapper.sh`.
55
56The changes can then be reviewed and submitted through the normal process.
57
58
59## Paths
60
61`build.py` is called by these ebuilds:
62
63- third_party/chromiumos-overlay/sys-devel/llvm/llvm-*.ebuild
64- third_party/chromiumos-overlay/sys-devel/gcc/gcc-*.ebuild
65
66Generated wrappers are stored here:
67
68- Sysroot wrapper with ccache:
69  `/usr/x86_64-pc-linux-gnu/<arch>/gcc-bin/10.2.0/sysroot_wrapper.hardened.ccache`
70- Sysroot wrapper without ccache:
71  `/usr/x86_64-pc-linux-gnu/<arch>/gcc-bin/10.2.0/sysroot_wrapper.hardened.noccache`
72- Clang host wrapper:
73  `/usr/bin/clang_host_wrapper`
74- Gcc host wrapper:
75  `/usr/x86_64-pc-linux-gnu/gcc-bin/10.2.0/host_wrapper`
76
77## Using the compiler wrapper to crash arbitrary compilations
78
79When Clang crashes, its output can be extremely useful. Often, it will provide
80the user with a stack trace, and messages like:
81
82```
83clang-15: unable to execute command: Illegal instruction
84clang-15: note: diagnostic msg: /tmp/clang_crash_diagnostics/foo-5420d2.c
85clang-15: note: diagnostic msg: /tmp/clang_crash_diagnostics/foo-5420d2.sh
86```
87
88Where the artifacts at `/tmp/clang_crash_diagnostics/foo-*` are a full,
89self-contained reproducer of the inputs that caused the crash in question.
90Often, such a reproducer is very valuable to have even for cases where a crash
91_doesn't_ happen (e.g., maybe Clang is now emitting an error where it used to
92not do so, and we want to bisect upstream LLVM with that info). Normally,
93collecting and crafting such a reproducer is a multi-step process, and can be
94error-prone; compile commands may rely on env vars, they may be done within
95`chroot`s, they may rely on being executed in a particular directory, they may
96rely on intermediate state, etc.
97
98Because of the usefulness of these crash reports, our wrapper supports crashing
99Clang even on files that ordinarily don't cause Clang to crash. For various
100reasons (b/236736327), this support currently requires rebuilding and
101redeploying the wrapper in order to work. That said, this could be a valuable
102tool for devs interested in creating a self-contained reproducer without having
103to manually reproduce the environment in which a particular build was performed.
104

bundle.README

1Copyright 2019 The ChromiumOS Authors
2Use of this source code is governed by a BSD-style license that can be
3found in the LICENSE file.
4
5Toolchain utils compiler wrapper sources.
6
7Build the wrapper:
8./build --config=<config name> --use_ccache=<bool> \
9  --use_llvm_next=<bool> --output_file=<file>
10
11ATTENTION:
12The files in this folder are generated. Do not modify manually!
13
14To update:
15- modify third_party/toolchain_utils/compiler_wrapper
16- run third_party/toolchain_utils/compiler_wrapper/bundle.py --output_dir=...
17
18Source: https://chromium-review.googlesource.com/q/{change_id}
19