diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn --- a/llvm/utils/gn/build/toolchain/BUILD.gn +++ b/llvm/utils/gn/build/toolchain/BUILD.gn @@ -4,11 +4,16 @@ # If is_goma is true, the location of the goma client install. # Set this to the output of `goma_ctl goma_dir`. goma_dir = "" + + # If set, prepends this to compile action command lines (e.g. `"ccache"`). + compiler_wrapper = "" } assert(!use_goma || goma_dir != "", "set `goma_dir` to the output of `goma_ctl goma_dir` in your args.gn") +assert(!(use_goma && compiler_wrapper != ""), "cannot use both goma and a compiler launcher") + unix_copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" template("unix_toolchain") { @@ -31,6 +36,9 @@ if (use_goma) { cc = "$goma_dir/gomacc $cc" cxx = "$goma_dir/gomacc $cxx" + } else if (compiler_wrapper != "") { + cc = "$compiler_wrapper $cc" + cxx = "$compiler_wrapper $cxx" } tool("cc") {