# is already used by autotargets for the ccache package.
# BR_CACHE_DIR is exported by Makefile based on config option
# BR2_CCACHE_DIR.
-# - ccache shouldn't use the compiler binary mtime to detect a change in
-# the compiler, because in the context of Buildroot, that completely
-# defeats the purpose of ccache. Of course, that leaves the user
-# responsible for purging its cache when the compiler changes.
# - Change hard-coded last-ditch default to match path in .config, to avoid
# the need to specify BR_CACHE_DIR when invoking ccache directly.
define HOST_CCACHE_PATCH_CONFIGURATION
sed -i 's,getenv("CCACHE_DIR"),getenv("BR_CACHE_DIR"),' $(@D)/ccache.c
- sed -i 's,conf->compiler_check = x_strdup("mtime"),conf->compiler_check = x_strdup("none"),' $(@D)/conf.c
sed -i 's,"%s/.ccache","$(BR_CACHE_DIR)",' $(@D)/conf.c
endef
# Xtensa special hook
#
+HOST_GCC_XTENSA_OVERLAY_TAR = $(BR2_XTENSA_OVERLAY_DIR)/xtensa_$(call qstrip,$(BR2_XTENSA_CORE_NAME)).tar
+
define HOST_GCC_XTENSA_OVERLAY_EXTRACT
- tar xf $(BR2_XTENSA_OVERLAY_DIR)/xtensa_$(call qstrip,\
- $(BR2_XTENSA_CORE_NAME)).tar -C $(@D) --strip-components=1 gcc
+ tar xf $(HOST_GCC_XTENSA_OVERLAY_TAR) -C $(@D) --strip-components=1 gcc
endef
#
HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".real"'
+ifeq ($(BR2_CCACHE),y)
+HOST_GCC_COMMON_CCACHE_HASH_FILES += $(DL_DIR)/$(GCC_SOURCE)
+# Cfr. PATCH_BASE_DIRS in .stamp_patched, but we catch both versioned and
+# unversioned patches unconditionally
+HOST_GCC_COMMON_CCACHE_HASH_FILES += \
+ $(wildcard \
+ package/gcc/$(GCC_VERSION)/*.patch \
+ $(addsuffix $((PKG)_RAWNAME)/$(GCC_VERSION)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))) \
+ $(addsuffix $((PKG)_RAWNAME)/*.patch,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR))))
+ifeq ($(BR2_xtensa),y)
+HOST_GCC_COMMON_CCACHE_HASH_FILES += $(HOST_GCC_XTENSA_OVERLAY_TAR)
+endif
+ifeq ($(ARCH),powerpc)
+ifneq ($(BR2_SOFT_FLOAT),)
+HOST_GCC_COMMON_CCACHE_HASH_FILES += package/gcc/$(GCC_VERSION)/1000-powerpc-link-with-math-lib.patch.conditional
+endif
+endif
+
+HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE_HASH=\"`\
+ printf '%s' $($(PKG)_CONF_OPTS) $(GCC_VERSION) \
+ | sha256sum - $(HOST_GCC_COMMON_CCACHE_HASH_FILES) \
+ | cut -c -64 | tr -d '\n'`\"
+endif # BR2_CCACHE
+
# The LTO support in gcc creates wrappers for ar, ranlib and nm which load
# the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
# *-gcc-nm and should be used instead of the real programs when -flto is
debug = atoi(env_debug);
if (debug > 0) {
fprintf(stderr, "Toolchain wrapper executing:");
+#ifdef BR_CCACHE_HASH
+ fprintf(stderr, "%sCCACHE_COMPILERCHECK='string:" BR_CCACHE_HASH "'",
+ (debug == 2) ? "\n " : " ");
+#endif
for (i = 0; exec_args[i]; i++)
fprintf(stderr, "%s'%s'",
(debug == 2) ? "\n " : " ", exec_args[i]);
}
}
+#ifdef BR_CCACHE_HASH
+ /* Allow compilercheck to be overridden through the environment */
+ if (setenv("CCACHE_COMPILERCHECK", "string:" BR_CCACHE_HASH, 0)) {
+ perror(__FILE__ ": Failed to set CCACHE_COMPILERCHECK");
+ return 3;
+ }
+#endif
+
if (execv(exec_args[0], exec_args))
perror(path);