From 69d1feb83f0e1f411f3b62f74e1a488f0dd29b15 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 28 Aug 2023 20:56:31 +0000 Subject: [PATCH] 8315060: Out of tree incremental build fails with ccache Reviewed-by: kbarrett, dholmes --- make/autoconf/build-performance.m4 | 5 ++++- make/common/NativeCompilation.gmk | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/make/autoconf/build-performance.m4 b/make/autoconf/build-performance.m4 index 3f0ab1bf57c..40ca9d41d33 100644 --- a/make/autoconf/build-performance.m4 +++ b/make/autoconf/build-performance.m4 @@ -243,8 +243,11 @@ AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], fi fi + # The CCACHE_BASEDIR needs to end with '/' as ccache will otherwise think + # directories next to it, that have the base dir name as a prefix, are sub + # directories of CCACHE_BASEDIR. CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \ - CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE" + CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$WORKSPACE_ROOT/ $CCACHE" if test "x$SET_CCACHE_DIR" != x; then mkdir -p $CCACHE_DIR > /dev/null 2>&1 diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index e97d8767ce2..9b847fe35f0 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -224,9 +224,12 @@ endif # object files while CCACHE_BASEDIR will make ccache relativize all paths for # its compiler. The compiler then produces relative dependency files. # make does not know a relative and absolute filename is the same so it will -# ignore such dependencies. +# ignore such dependencies. This only applies when the OUTPUTDIR is inside +# the WORKSPACE_ROOT. ifneq ($(CCACHE), ) - REWRITE_PATHS_RELATIVE = true + ifneq ($(filter $(WORKSPACE_ROOT)/%, $(OUTPUTDIR)), ) + REWRITE_PATHS_RELATIVE = true + endif endif ifeq ($(REWRITE_PATHS_RELATIVE), true)