aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/Makefile.in5
-rw-r--r--toolchain/toolchain-wrapper.c15
-rw-r--r--toolchain/toolchain-wrapper.mk4
3 files changed, 18 insertions, 6 deletions
diff --git a/package/Makefile.in b/package/Makefile.in
index 545694f389..4b1ce7faed 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -189,11 +189,6 @@ TARGET_OBJDUMP = $(TARGET_CROSS)objdump
TARGET_CC_NOCCACHE := $(TARGET_CC)
TARGET_CXX_NOCCACHE := $(TARGET_CXX)
-ifeq ($(BR2_CCACHE),y)
-TARGET_CC := $(CCACHE) $(TARGET_CC)
-TARGET_CXX := $(CCACHE) $(TARGET_CXX)
-endif
-
ifeq ($(BR2_STRIP_strip),y)
STRIP_STRIP_DEBUG := --strip-debug
STRIP_STRIP_UNNEEDED := --strip-unneeded
diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
index d4d25c7057..aee5df7ac9 100644
--- a/toolchain/toolchain-wrapper.c
+++ b/toolchain/toolchain-wrapper.c
@@ -23,6 +23,9 @@
#include <stdlib.h>
#include <errno.h>
+#ifdef BR_CCACHE
+static char ccache_path[PATH_MAX];
+#endif
static char path[PATH_MAX];
static char sysroot[PATH_MAX];
@@ -40,6 +43,9 @@ static char sysroot[PATH_MAX];
#define EXCLUSIVE_ARGS 3
static char *predef_args[] = {
+#ifdef BR_CCACHE
+ ccache_path,
+#endif
path,
"--sysroot", sysroot,
#ifdef BR_ABI
@@ -147,6 +153,13 @@ int main(int argc, char **argv)
perror(__FILE__ ": overflow");
return 3;
}
+#ifdef BR_CCACHE
+ ret = snprintf(ccache_path, sizeof(ccache_path), "%s/usr/bin/ccache", absbasedir);
+ if (ret >= sizeof(ccache_path)) {
+ perror(__FILE__ ": overflow");
+ return 3;
+ }
+#endif
ret = snprintf(sysroot, sizeof(sysroot), "%s/" BR_SYSROOT, absbasedir);
if (ret >= sizeof(sysroot)) {
perror(__FILE__ ": overflow");
@@ -251,7 +264,7 @@ int main(int argc, char **argv)
}
}
- if (execv(path, args))
+ if (execv(args[0], args))
perror(path);
free(args);
diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk
index 899947de77..749afd7a59 100644
--- a/toolchain/toolchain-wrapper.mk
+++ b/toolchain/toolchain-wrapper.mk
@@ -16,6 +16,10 @@ TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
# separate argument when used in execv() by the toolchain wrapper.
TOOLCHAIN_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)",)'
+ifeq ($(BR2_CCACHE),y)
+TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE
+endif
+
# For simplicity, build directly into the install location
define TOOLCHAIN_BUILD_WRAPPER
$(Q)mkdir -p $(HOST_DIR)/usr/bin