aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/ccache_flag.go
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-08 16:02:00 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-08 16:02:00 +0000
commitfb6e2972318a5d63365e66c35c000a6d2e096501 (patch)
tree35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /compiler_wrapper/ccache_flag.go
parent2186a2d2b9783318bc8226b3eff1fd114f03a8c4 (diff)
parentb75f321fc8978b92ce3db6886ccb966768f0c7a8 (diff)
downloadtoolchain-utils-android12-mainline-tzdata2-release.tar.gz
Change-Id: If223f5dd2285da8941d62bcf5daf8e53ec9908ad
Diffstat (limited to 'compiler_wrapper/ccache_flag.go')
-rw-r--r--compiler_wrapper/ccache_flag.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/compiler_wrapper/ccache_flag.go b/compiler_wrapper/ccache_flag.go
index 265b8fc2..312d0f02 100644
--- a/compiler_wrapper/ccache_flag.go
+++ b/compiler_wrapper/ccache_flag.go
@@ -4,7 +4,7 @@
package main
-func processCCacheFlag(builder *commandBuilder) {
+func processCCacheFlag(sysroot string, builder *commandBuilder) {
// We should be able to share the objects across compilers as
// the pre-processed output will differ. This allows boards
// that share compiler flags (like x86 boards) to share caches.
@@ -20,8 +20,24 @@ func processCCacheFlag(builder *commandBuilder) {
})
if builder.cfg.useCCache && useCCache {
- // Note: we used to also set CCACHE_BASEDIR but don't do it
- // anymore for reasons outlined in crrev.com/c/2103170.
+ // We need to get ccache to make relative paths from within the
+ // sysroot. This lets us share cached files across boards (if
+ // all other things are equal of course like CFLAGS) as well as
+ // across versions. A quick test is something like:
+ // $ export CFLAGS='-O2 -g -pipe' CXXFLAGS='-O2 -g -pipe'
+ // $ BOARD=x86-alex
+ // $ cros_workon-$BOARD stop cros-disks
+ // $ emerge-$BOARD cros-disks
+ // $ cros_workon-$BOARD start cros-disks
+ // $ emerge-$BOARD cros-disks
+ // $ BOARD=amd64-generic
+ // $ cros_workon-$BOARD stop cros-disks
+ // $ emerge-$BOARD cros-disks
+ // $ cros_workon-$BOARD start cros-disks
+ // $ emerge-$BOARD cros-disks
+ // 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 _, 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