[llvm] [gn build] Add a generic `compiler_wrapper` gn arg (PR #72757)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 18 10:55:28 PST 2023
https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/72757
Since goma is going away soon, we need to experiment with other wrappers.
>From f8cfd93a9d19ca028dfc90e381302e41acc65b11 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Sat, 18 Nov 2023 10:54:20 -0800
Subject: [PATCH] [gn build] Add a generic `compiler_wrapper` gn arg
Since goma is going away soon, we need to experiment with other wrappers.
---
llvm/utils/gn/build/toolchain/BUILD.gn | 13 +++++++------
llvm/utils/gn/build/toolchain/compiler.gni | 8 ++++++++
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index 8f4a5d2e3e41a82..ebcdcbf6f61e190 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -1,13 +1,9 @@
import("//llvm/utils/gn/build/toolchain/compiler.gni")
-declare_args() {
- # If is_goma is true, the location of the goma client install.
- # Set this to the output of `goma_ctl goma_dir`.
- goma_dir = ""
-}
-
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 == "",
+ "`use_goma` and `compiler_wrapper` are mutually exclusive")
unix_copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
@@ -31,6 +27,9 @@ template("unix_toolchain") {
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") {
@@ -304,6 +303,8 @@ template("win_toolchain") {
if (use_goma) {
cl = "$goma_dir/gomacc $cl"
+ } else if (compiler_wrapper != "") {
+ cl = "$compiler_wrapper $cl"
}
tool("cc") {
diff --git a/llvm/utils/gn/build/toolchain/compiler.gni b/llvm/utils/gn/build/toolchain/compiler.gni
index 7cd15e658a087b7..10ebc8b3bab8376 100644
--- a/llvm/utils/gn/build/toolchain/compiler.gni
+++ b/llvm/utils/gn/build/toolchain/compiler.gni
@@ -2,6 +2,14 @@ declare_args() {
# Whether to use goma (https://chromium.googlesource.com/infra/goma/client/)
use_goma = false
+ # 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, this is prepended to compile action command lines (e.g. `"ccache"`).
+ # Cannot be used with use_goma/goma_dir.
+ compiler_wrapper = ""
+
# Set this to a clang build directory. If set, that clang is used as compiler.
# goma only works with compiler binaries it knows about, so useful both for
# using a goma-approved compiler and for compiling clang with a locally-built
More information about the llvm-commits
mailing list