diff --git a/config/functions b/config/functions index 9ddf319095..a03dbb490b 100644 --- a/config/functions +++ b/config/functions @@ -492,8 +492,18 @@ setup_toolchain() { host:*|bootstrap:*) export DESTIMAGE="host" export AWK="gawk" - export CC="$TOOLCHAIN/bin/host-gcc" - export CXX="$TOOLCHAIN/bin/host-g++" + if [ "$1" = "host" ] && flag_enabled "local-cc" "no"; then + export CC="${LOCAL_CC}" + export CXX="${LOCAL_CXX}" + if [ -n "${LOCAL_CCACHE}" ]; then + export CCACHE_DIR="${LOCAL_CCACHE_DIR}" + export CC="${LOCAL_CCACHE} ${CC}"; + export CXX="${LOCAL_CCACHE} ${CXX}"; + fi + else + export CC="$TOOLCHAIN/bin/host-gcc" + export CXX="$TOOLCHAIN/bin/host-g++" + fi export CPP="cpp" export LD="ld" export AS="as" diff --git a/config/path b/config/path index 2b0be6cead..28a5bbf88c 100644 --- a/config/path +++ b/config/path @@ -70,6 +70,14 @@ if [ -z "$CCACHE_DIR" ]; then export CCACHE_DIR=$BUILD/.ccache fi +# keep a copy of ccache dir used for toolchain ccache +export BUILD_CCACHE_DIR="${CCACHE_DIR}" + +# local ccache dir in case we build early packages with local ccache +if [ -z "${LOCAL_CCACHE_DIR}" ]; then + export LOCAL_CCACHE_DIR="${BUILD}/.ccache-local" +fi + if [[ -z "$PATH" || ( "$PATH" != "$TOOLCHAIN/bin:$TOOLCHAIN/sbin" && "$PATH" = "${PATH#$TOOLCHAIN/bin:$TOOLCHAIN/sbin:}" ) ]]; then export PATH="$TOOLCHAIN/bin:$TOOLCHAIN/sbin${PATH:+":$PATH"}" fi diff --git a/packages/devel/ccache/package.mk b/packages/devel/ccache/package.mk index 7ed5c185ec..aedeed3b1f 100644 --- a/packages/devel/ccache/package.mk +++ b/packages/devel/ccache/package.mk @@ -10,30 +10,26 @@ PKG_SITE="https://ccache.dev/download.html" PKG_URL="https://github.com/ccache/ccache/releases/download/v${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}.tar.xz" PKG_DEPENDS_HOST="make:host" PKG_LONGDESC="A compiler cache to speed up re-compilation of C/C++ code by caching." +PKG_BUILD_FLAGS="+local-cc" PKG_CONFIGURE_OPTS_HOST="--with-bundled-zlib" -pre_configure_host() { - export CC=${LOCAL_CC} - export CXX=${LOCAL_CXX} -} - post_makeinstall_host() { # setup ccache if [ -z "${CCACHE_DISABLE}" ]; then - ${TOOLCHAIN}/bin/ccache --max-size=${CCACHE_CACHE_SIZE} + CCACHE_DIR="${BUILD_CCACHE_DIR}" ${TOOLCHAIN}/bin/ccache --max-size=${CCACHE_CACHE_SIZE} fi cat > ${TOOLCHAIN}/bin/host-gcc < ${TOOLCHAIN}/bin/host-g++ < libreelec-local-cc << EOF +#!/bin/sh +exec ${CC} "\$@" +EOF + chmod +x libreelec-local-cc + export CC=$(pwd)/libreelec-local-cc + cat > libreelec-local-cxx << EOF +#!/bin/sh +exec ${CXX} "\$@" +EOF + chmod +x libreelec-local-cxx + export CXX=$(pwd)/libreelec-local-cxx +fi + # configure if [ -n "${PKG_DEPENDS_CONFIG}" -a -n "${PKG_INSTALL}" ]; then for pkg in ${PKG_DEPENDS_CONFIG}; do