From 86ef4e95a515f74afef8ef8f8b79d534feb0c765 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Fri, 29 Oct 2021 21:04:05 -0400 Subject: [PATCH] Add option in Makefile for (s)ccache support. --- litex/soc/software/common.mak | 9 +++++---- litex/soc/software/libc/Makefile | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index fb9735434..ea49dbbd0 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -6,13 +6,14 @@ endif RM ?= rm -f PYTHON ?= python3 +CCACHE ?= ifeq ($(CLANG),1) -CC_normal := clang -target $(TRIPLE) -integrated-as -CX_normal := clang++ -target $(TRIPLE) -integrated-as +CC_normal := $(CCACHE) clang -target $(TRIPLE) -integrated-as +CX_normal := $(CCACHE) clang++ -target $(TRIPLE) -integrated-as else -CC_normal := $(TARGET_PREFIX)gcc -std=gnu99 -CX_normal := $(TARGET_PREFIX)g++ +CC_normal := $(CCACHE) $(TARGET_PREFIX)gcc -std=gnu99 +CX_normal := $(CCACHE) $(TARGET_PREFIX)g++ endif AR_normal := $(TARGET_PREFIX)gcc-ar LD_normal := $(TARGET_PREFIX)ld diff --git a/litex/soc/software/libc/Makefile b/litex/soc/software/libc/Makefile index e952fd4d4..8523d842d 100644 --- a/litex/soc/software/libc/Makefile +++ b/litex/soc/software/libc/Makefile @@ -9,9 +9,15 @@ ifeq ($(CPU), microwatt) CFLAGS += -DLONG_LONG_MIN=LLONG_MIN -DLONG_LONG_MAX=LLONG_MAX -DLONG_LONG_MIN=LLONG_MIN -DULONG_LONG_MAX=ULLONG_MAX endif +ifeq ($(CCACHE), ) + MESON_CROSS_CC = '$(TRIPLE)-gcc' +else + MESON_CROSS_CC = ['$(CCACHE)', '$(TRIPLE)-gcc'] +endif + define CROSSFILE [binaries] -c = '$(TRIPLE)-gcc' +c = $(MESON_CROSS_CC) ar = '$(TRIPLE)-gcc-ar' as = '$(TRIPLE)-as' nm = '$(TRIPLE)-gcc-nm' @@ -60,4 +66,3 @@ libc.a: $(LIBC_DIRECTORY)/missing.c _libc.a $(compile) $(AR) csr _libc.a $@ cp _libc.a libc.a -