f4682cf933
Our current ccache disables hashing of the compiler executable itself, because using the default 'mtime' doesn't work in buildroot: we always rebuild the compiler, so the mtime is always different, so the cache always misses. However, in the current situation, if a user changes the compiler configuration (which would result in the compiler generating different object files than before) and does 'make clean all', ccache may in fact reuse object files from the previous run. This rarely gives problems, because (1) the cache expires quite quickly (it's only 1GB by default), (2) radically changing compiler options will cause cache misses because different header files are used, (3) many compiler changes (e.g. changing -mtune) have little practical effect because the resulting code is usually still compatible, (4) we currently don't use CCACHE_BASEDIR, and almost all object files will contain an absolute path (e.g. in debug info), so when building in a different directory, most of it will miss, (5) we do mostly build test, and many of the potential problems only appear at runtime. Still, when ccache _does_ use the wrong cached object files, the effects are really weird and hard to debug. Also, we want reproducible builds and obviously the above makes builds non-reproducible. So we have a FAQ entry that warns against using ccache and tells the user to clear the cache in case of problems. Now that ccache is called from the toolchain wrapper, it is in fact possible to at least use the 'mtime' compiler hash for the external toolchain and for the host-gcc. Indeed, in this case, the compiler executable comes from a tarball so the mtime will be a good reference for its state. Therefore, the patch (sed script) that changes the default from 'mtime' to 'none' is removed. For the internal toolchain, we can do better by providing a hash of the relevant toolchain options. We are only interested in things that affect the compiler itself, because ccache also processes the header files and it doesn't look at libraries because it doesn't cache the link step, just compilation. Everything that affects the compiler itself can nicely be summarised in $(HOST_GCC_FINAL_CONF_OPTS). Of course, also the compiler source itself is relevant, so the source tarball and all the patches are included in the hash. For this purpose, a new HOST_GCC_XTENSA_OVERLAY_TAR is introduced. The following procedure tests the ccache behaviour: Use this defconfig: BR2_arm=y BR2_CCACHE=y make readelf -A output/build/uclibc-1.0.6/libc/signal/signal.os -> Tag_CPU_name: "ARM926EJ-S" Now make menuconfig, change variant into BR2_cortex_a9 make clean; make readelf -A output/build/uclibc-1.0.6/libc/signal/signal.os -> Tag_CPU_name: "ARM926EJ-S" should be "Cortex-A9" After this commit, it is "Cortex-A9". Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Cc: Danomi Manchego <danomimanchego123@gmail.com> Cc: Károly Kasza <kaszak@gmail.com> Cc: Samuel Martin <s.martin49@gmail.com> Cc: Romain Naour <romain.naour@openwide.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
71 lines
2.5 KiB
Makefile
71 lines
2.5 KiB
Makefile
################################################################################
|
|
#
|
|
# ccache
|
|
#
|
|
################################################################################
|
|
|
|
CCACHE_VERSION = 3.2.2
|
|
CCACHE_SITE = https://samba.org/ftp/ccache
|
|
CCACHE_SOURCE = ccache-$(CCACHE_VERSION).tar.xz
|
|
CCACHE_LICENSE = GPLv3+, others
|
|
CCACHE_LICENSE_FILES = LICENSE.txt GPL-3.0.txt
|
|
|
|
# Force ccache to use its internal zlib. The problem is that without
|
|
# this, ccache would link against the zlib of the build system, but we
|
|
# might build and install a different version of zlib in $(O)/host
|
|
# afterwards, which ccache will pick up. This might break if there is
|
|
# a version mismatch. A solution would be to add host-zlib has a
|
|
# dependency of ccache, but it would require tuning the zlib .mk file
|
|
# to use HOSTCC_NOCCACHE as the compiler. Instead, we take the easy
|
|
# path: tell ccache to use its internal copy of zlib, so that ccache
|
|
# has zero dependency besides the C library.
|
|
HOST_CCACHE_CONF_OPTS += --with-bundled-zlib
|
|
|
|
# Patch host-ccache as follows:
|
|
# - Use BR_CACHE_DIR instead of CCACHE_DIR, because CCACHE_DIR
|
|
# is already used by autotargets for the ccache package.
|
|
# BR_CACHE_DIR is exported by Makefile based on config option
|
|
# BR2_CCACHE_DIR.
|
|
# - 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,"%s/.ccache","$(BR_CACHE_DIR)",' $(@D)/conf.c
|
|
endef
|
|
|
|
HOST_CCACHE_POST_PATCH_HOOKS += HOST_CCACHE_PATCH_CONFIGURATION
|
|
|
|
define HOST_CCACHE_MAKE_CACHE_DIR
|
|
mkdir -p $(BR_CACHE_DIR)
|
|
endef
|
|
|
|
HOST_CCACHE_POST_INSTALL_HOOKS += HOST_CCACHE_MAKE_CACHE_DIR
|
|
|
|
# Provide capability to do initial ccache setup (e.g. increase default size)
|
|
BR_CCACHE_INITIAL_SETUP = $(call qstrip,$(BR2_CCACHE_INITIAL_SETUP))
|
|
ifneq ($(BR_CCACHE_INITIAL_SETUP),)
|
|
define HOST_CCACHE_DO_INITIAL_SETUP
|
|
@$(call MESSAGE,"Applying initial settings")
|
|
$(CCACHE) $(BR_CCACHE_INITIAL_SETUP)
|
|
$(CCACHE) -s
|
|
endef
|
|
|
|
HOST_CCACHE_POST_INSTALL_HOOKS += HOST_CCACHE_DO_INITIAL_SETUP
|
|
endif
|
|
|
|
$(eval $(host-autotools-package))
|
|
|
|
ifeq ($(BR2_CCACHE),y)
|
|
ccache-stats: host-ccache
|
|
$(Q)$(CCACHE) -s
|
|
|
|
ccache-options: host-ccache
|
|
ifeq ($(CCACHE_OPTIONS),)
|
|
$(Q)echo "Usage: make ccache-options CCACHE_OPTIONS=\"opts\""
|
|
$(Q)echo "where 'opts' corresponds to one or more valid ccache options" \
|
|
"(see ccache help text below)"
|
|
$(Q)echo
|
|
endif
|
|
$(Q)$(CCACHE) $(CCACHE_OPTIONS)
|
|
endif
|