aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/ccache_flag.go
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-09-12 15:19:57 -0700
committerTobias Bosch <tbosch@google.com>2019-09-13 18:57:43 +0000
commit3b8531f0c0739003a208b7beb002d1058656a962 (patch)
tree1f53081777ba01d9ecd1b31bd2ee76285a69d91c /compiler_wrapper/ccache_flag.go
parentc183559d9c40285129d08a1146cfde0982b6c356 (diff)
downloadtoolchain-utils-3b8531f0c0739003a208b7beb002d1058656a962.tar.gz
Allow to remove env variables.
Previously, we only supported setting env variables to empty, but not to remove it. This lead to the case that we never removed the CCACHE_DISABLE env variable, which kept the ccache disabled, and caused a performance regression compared to the old wrapper as the new wrapper didn't use the ccache in this case. This cl also adds tests for the real exec and run commands to prevent regressions in these cases. BUG=chromium:773875 TEST=new unit tests TEST=performance analysis for TEST=emerge-veyron_jerry --nodeps chromeos-kernel-4_19 Change-Id: I5ca88ba8d7b05c3e12e292465fcd4ff9925b0344 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1802159 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/ccache_flag.go')
-rw-r--r--compiler_wrapper/ccache_flag.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler_wrapper/ccache_flag.go b/compiler_wrapper/ccache_flag.go
index 640a99fc..312d0f02 100644
--- a/compiler_wrapper/ccache_flag.go
+++ b/compiler_wrapper/ccache_flag.go
@@ -38,7 +38,7 @@ func processCCacheFlag(sysroot string, builder *commandBuilder) {
// All of those will get cache hits (ignoring the first one
// which will seed the cache) due to this setting.
builder.updateEnv("CCACHE_BASEDIR=" + sysroot)
- if builder.env.getenv("CCACHE_DISABLE") != "" {
+ if _, present := builder.env.getenv("CCACHE_DISABLE"); present {
// Portage likes to set this for us when it has FEATURES=-ccache.
// The other vars we need to setup manually because of tools like
// scons that scrubs the env before we get executed.
@@ -46,7 +46,7 @@ func processCCacheFlag(sysroot string, builder *commandBuilder) {
}
// If RESTRICT=sandbox is enabled, then sandbox won't be setup,
// and the env vars won't be available for appending.
- if sandboxRewrite := builder.env.getenv("SANDBOX_WRITE"); sandboxRewrite != "" {
+ if sandboxRewrite, present := builder.env.getenv("SANDBOX_WRITE"); present {
builder.updateEnv("SANDBOX_WRITE=" + sandboxRewrite + ":" + ccacheDir)
}