[PATCH] D159304: [gn build] Add support for other compiler wrappers

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 11:32:31 PDT 2023


aeubanks created this revision.
aeubanks added a reviewer: thakis.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

e.g. ccache is much faster than goma if everything is already cached.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159304

Files:
  llvm/utils/gn/build/toolchain/BUILD.gn


Index: llvm/utils/gn/build/toolchain/BUILD.gn
===================================================================
--- llvm/utils/gn/build/toolchain/BUILD.gn
+++ 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") {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159304.555120.patch
Type: text/x-patch
Size: 1082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230831/e42c7e93/attachment.bin>


More information about the llvm-commits mailing list