From d868c9c5c37d2a5fb03875eba54ca80a476d7edb Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 28 Nov 2019 14:13:39 +0100 Subject: [PATCH 1/2] makefiles: Do not set CCACHE_BASEDIR environmental variable When CCACHE_BASEDIR variable is set, ccache rewrites absolute paths into relative paths before computing the hash that identifies the compilation for all the paths under that directory. The problem is that those paths are also used when the compiler is called, so the generated dependency files (*.d) will have a relative path to the object files, and thus, it will not match our rule for compiling (we use absolute paths). As dependency files define the targets this way, any change on its dependencies (e.g. an included header file) will not re-trigger a build. --- Makefile.include | 3 --- makefiles/vars.inc.mk | 3 --- 2 files changed, 6 deletions(-) diff --git a/Makefile.include b/Makefile.include index cea7c51fab..5cfd10ccdc 100644 --- a/Makefile.include +++ b/Makefile.include @@ -23,7 +23,6 @@ include $(RIOT_MAKEFILES_GLOBAL_PRE) # set undefined variables RIOTBASE ?= $(_riotbase) -CCACHE_BASEDIR ?= $(RIOTBASE) RIOTCPU ?= $(RIOTBASE)/cpu RIOTBOARD ?= $(RIOTBASE)/boards RIOTMAKE ?= $(RIOTBASE)/makefiles @@ -55,7 +54,6 @@ __DIRECTORY_VARIABLES := \ BUILD_DIR \ BINDIRBASE \ BINDIR \ - CCACHE_BASEDIR \ GITCACHE \ PKGDIRBASE \ DLCACHE_DIR \ @@ -63,7 +61,6 @@ __DIRECTORY_VARIABLES := \ # Make all paths absolute. override RIOTBASE := $(abspath $(RIOTBASE)) -override CCACHE_BASEDIR := $(abspath $(CCACHE_BASEDIR)) override RIOTCPU := $(abspath $(RIOTCPU)) override RIOTBOARD := $(abspath $(RIOTBOARD)) override RIOTMAKE := $(abspath $(RIOTMAKE)) diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index 06b5b525f0..bc2732b496 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -92,9 +92,6 @@ export HEXFILE # The 'intel hex' stripped result of the compilatio # RESET # The command to call on "make reset", this command resets/reboots the target. # RESET_FLAGS # The parameters to supply to RESET. -export CCACHE_BASEDIR # ccache basedir, allows multiple riot build - # directories to share a ccache directory - export DLCACHE # directory used to cache http downloads export DOWNLOAD_TO_FILE # Use `$(DOWNLOAD_TO_FILE) $(DESTINATION) $(URL)` to download `$(URL)` to `$(DESTINATION)`. export DOWNLOAD_TO_STDOUT # Use `$(DOWNLOAD_TO_STDOUT) $(URL)` to download `$(URL)` output `$(URL)` to stdout, e.g. to be piped into `tar xz`. From dc845841f0f201d42c87b10da5faa8ba55ba113c Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 28 Nov 2019 15:34:20 +0100 Subject: [PATCH 2/2] Makefile.base: Set targets of *.d files to absolute object path By passing the -MT flag with the absolute path to the object we make sure that the compiler generates dependency files with rules that match our building rules. --- Makefile.base | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.base b/Makefile.base index f937603245..5f7fd9f02d 100644 --- a/Makefile.base +++ b/Makefile.base @@ -100,25 +100,25 @@ $(OBJC): $(BINDIR)/$(MODULE)/%.o: %.c $(RIOTBUILD_CONFIG_HEADER_C) $(Q)$(CCACHE) $(CC) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ - $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + $(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<) $(GENOBJC): %.o: %.c $(RIOTBUILD_CONFIG_HEADER_C) $(Q) $(CCACHE) $(CC) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$<)\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ - $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $< + $(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $< $(OBJCXX): $(BINDIR)/$(MODULE)/%.o: %.cpp $(RIOTBUILD_CONFIG_HEADER_C) $(Q)$(CCACHE) $(CXX) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ - $(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + $(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<) $(ASMOBJ): $(BINDIR)/$(MODULE)/%.o: %.s $(Q)$(AS) $(ASFLAGS) -o $@ $(abspath $<) $(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: %.S $(RIOTBUILD_CONFIG_HEADER_C) - $(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<) + $(Q)$(CCAS) $(CCASFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c -o $@ $(abspath $<) # pull in dependency info for *existing* .o files # deleted header files will be silently ignored