From 32bdb20cebb8067445f7ff439d7298f2ad79b851 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 31 Jul 2024 16:28:53 -0700 Subject: [PATCH] Use ccache in runtime builds. --- .github/workflows/ci.yml | 80 ++++++++++-------------------- build_tools/cmake/build_runtime.sh | 10 ++-- 2 files changed, 34 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd82af43ebed..8a2de99d94bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -172,79 +172,53 @@ jobs: include: - name: ubuntu-20.04 runs-on: ubuntu-20.04 - container: gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 - name: windows-2022 runs-on: windows-2022 - # No container, (unnecessary, and Windows https://github.com/actions/runner/issues/904). - name: macos-14 runs-on: macos-14 - # No container, just install what we need directly. - # Disabled while we are short on arm64 runners. Could also make this opt-in, but the matrix complicates that. - # - name: arm64 - # runs-on: - # - self-hosted # must come first - # - runner-group=${{ needs.setup.outputs.runner-group }} - # - environment=${{ needs.setup.outputs.runner-env }} - # - arm64 - # - os-family=Linux - # container: gcr.io/iree-oss/base-arm64@sha256:9daa1cdbbf12da8527319ece76a64d06219e04ecb99a4cff6e6364235ddf6c59 env: BUILD_DIR: build-runtime BUILD_PRESET: test - CONTAINER: ${{ matrix.container }} + IREE_READ_REMOTE_CCACHE: 0 + IREE_WRITE_REMOTE_CCACHE: 0 + IREE_READ_LOCAL_CCACHE: 1 + IREE_WRITE_LOCAL_CCACHE: ${{ needs.setup.outputs.write-caches }} steps: - - name: "Checking out repository" - uses: actions/checkout@v4.1.7 + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-python@v5.1.0 + with: + python-version: "3.11" - - name: "(Windows) Configuring MSVC" + - name: (Linux) Install requirements + if: contains(matrix.name, 'ubuntu') + run: | + sudo apt update + sudo apt install -y ninja-build + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + - name: (Windows) Configure MSVC if: contains(matrix.name, 'windows') uses: ilammy/msvc-dev-cmd@v1.13.0 - - - name: "(macOS) Installing requirements" + - name: (macOS) Install requirements if: contains(matrix.name, 'macos') run: brew install ninja ccache coreutils bash - - name: "Checking out runtime submodules" + - name: Checkout runtime submodules run: bash ./build_tools/scripts/git/update_runtime_submodules.sh - # Windows/macOS (no Docker): install requirements -> build -> test. - # - # Note: Python is a mess across operating systems and GitHub runners so... - # * On Windows just install at the system level - # * On macOS install in a venv - - name: "(Windows) Installing Python requirements" - if: contains(matrix.name, 'windows') + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }}-${{ matrix.name }} + save: ${{ needs.setup.outputs.write-caches == 1 }} + + - name: Install Python requirements run: pip install -r ./runtime/bindings/python/iree/runtime/build_requirements.txt - - name: "(Windows) Building runtime" - if: contains(matrix.name, 'windows') - run: bash ./build_tools/cmake/build_runtime.sh "${BUILD_DIR}" - - name: "(macOS) Building runtime" - if: contains(matrix.name, 'macos') - env: - IREE_BUILD_SETUP_PYTHON_VENV: build-runtime/.venv + - name: Build runtime run: bash ./build_tools/cmake/build_runtime.sh "${BUILD_DIR}" - - name: "Testing runtime" - if: contains(matrix.name, 'windows') || contains(matrix.name, 'macos') + - name: Test runtime run: bash ./build_tools/cmake/ctest_all.sh "${BUILD_DIR}" - # With a Docker container: build under Docker -> test under Docker. - - name: "(Docker) Building runtime" - if: ${{ env.CONTAINER != '' }} - run: | - ./build_tools/github_actions/docker_run.sh \ - --env "BUILD_PRESET=test" \ - --env "IREE_BUILD_SETUP_PYTHON_VENV=${BUILD_DIR}/.venv" \ - ${CONTAINER} \ - ./build_tools/cmake/build_runtime.sh \ - "${BUILD_DIR}" - - name: "(Docker) Testing runtime" - if: ${{ env.CONTAINER != '' }} - run: | - ./build_tools/github_actions/docker_run.sh \ - ${CONTAINER} \ - ./build_tools/cmake/ctest_all.sh \ - "${BUILD_DIR}" - small_runtime: needs: setup if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'small_runtime') diff --git a/build_tools/cmake/build_runtime.sh b/build_tools/cmake/build_runtime.sh index 8ed4c0ea5ff4..c18babc0748a 100755 --- a/build_tools/cmake/build_runtime.sh +++ b/build_tools/cmake/build_runtime.sh @@ -21,7 +21,7 @@ CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}" IREE_BUILD_PYTHON_BINDINGS="${IREE_BUILD_PYTHON_BINDINGS:-ON}" source build_tools/cmake/setup_build.sh -# Note: not using ccache since the runtime build should be fast already. +source build_tools/cmake/setup_ccache.sh declare -a args args=( @@ -31,8 +31,8 @@ args=( "-DIREE_BUILD_COMPILER=OFF" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" - "-DIREE_RUNTIME_OPTIMIZATION_PROFILE=lto" - "-DIREE_FORCE_LTO_COMPAT_BINUTILS_ON_LINUX=ON" + # Use `lld` for faster linking. + "-DIREE_ENABLE_LLD=ON" "-DIREE_BUILD_PYTHON_BINDINGS=${IREE_BUILD_PYTHON_BINDINGS}" "-DPython3_EXECUTABLE=${IREE_PYTHON3_EXECUTABLE}" @@ -81,3 +81,7 @@ case "${BUILD_PRESET}" in exit 1 ;; esac + +if (( IREE_USE_CCACHE == 1 )); then + ccache --show-stats +fi