From 22dd6de6088e8a5e69c986a22bc7e6ccfb96028a Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 7 Nov 2023 06:54:33 -0800 Subject: [PATCH] Enable ccache for local/non-docker builds Signed-off-by: Brian Cain --- Dockerfile | 1 + build-toolchain.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 020972a..0f3d75c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,6 +77,7 @@ ADD get-src-tarballs.sh /root/hexagon-toolchain/get-src-tarballs.sh ADD *.cmake /root/hexagon-toolchain/ RUN cd /root/hexagon-toolchain && ./get-src-tarballs.sh ${PWD} ${TOOLCHAIN_INSTALL}/manifest +ENV IN_CONTAINER 1 ARG ARTIFACT_TAG=${VER} ADD build-toolchain.sh /root/hexagon-toolchain/build-toolchain.sh RUN cd /root/hexagon-toolchain && ./build-toolchain.sh ${ARTIFACT_TAG} diff --git a/build-toolchain.sh b/build-toolchain.sh index d40a4cd..163d61b 100755 --- a/build-toolchain.sh +++ b/build-toolchain.sh @@ -16,6 +16,9 @@ build_llvm_clang_cross() { if [[ "${triple}" =~ "windows" ]]; then EXTRA="-C windows-gnu-target.cmake" fi + if [[ "${IN_CONTAINER-0}" -ne 1 ]]; then + CMAKE_CCACHE="-DLLVM_CCACHE_BUILD:BOOL=ON" + fi CC="zig cc --target=${triple}" \ ASM="zig cc --target=${triple}" \ @@ -23,7 +26,7 @@ build_llvm_clang_cross() { cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX:PATH=${TOOLCHAIN_INSTALL}/${triple}/ \ - -DLLVM_CCACHE_BUILD:BOOL=OFF \ + ${CMAKE_CCACHE-} \ -DLLVM_ENABLE_TERMINFO:BOOL=OFF \ -DLLVM_ENABLE_ASSERTIONS:BOOL=ON \ -DLLVM_HOST_TRIPLE=${triple} \ @@ -46,11 +49,15 @@ build_llvm_clang_cross() { build_llvm_clang() { cd ${BASE} + if [[ "${IN_CONTAINER-0}" -ne 1 ]]; then + CMAKE_CCACHE="-DLLVM_CCACHE_BUILD:BOOL=ON" + fi + CC=clang CXX=clang++ cmake -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX:PATH=${TOOLCHAIN_INSTALL}/x86_64-linux-gnu/ \ - -DLLVM_CCACHE_BUILD:BOOL=OFF \ + ${CMAKE_CCACHE-} \ -DLLVM_ENABLE_LLD:BOOL=ON \ -DLLVM_ENABLE_LIBCXX:BOOL=ON \ -DLLVM_ENABLE_TERMINFO:BOOL=OFF \