diff --git a/.github/scripts/build-sizer.sh b/.github/scripts/build-sizer.sh index aac5905..e03be1c 100755 --- a/.github/scripts/build-sizer.sh +++ b/.github/scripts/build-sizer.sh @@ -25,8 +25,20 @@ if [[ -f "${openroad_deps_prefixes}" ]]; then done fi +cmake_compiler_launcher_args=() +if command -v sccache >/dev/null 2>&1; then + echo "sccache detected at $(command -v sccache); enabling CMake compiler launcher" + cmake_compiler_launcher_args=( + -DCMAKE_C_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + ) +else + echo "sccache not found on PATH; building without a compiler cache" +fi + cmake -S . -B build \ "${cmake_dependency_args[@]}" \ + "${cmake_compiler_launcher_args[@]}" \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_TESTS=OFF \ -DUSE_SYSTEM_BOOST=ON \ @@ -40,4 +52,12 @@ cmake -S . -B build \ -DZLIB_HOME=/usr/lib/x86_64-linux-gnu \ -DCMAKE_RULE_MESSAGES=OFF +if [[ ${#cmake_compiler_launcher_args[@]} -gt 0 ]]; then + if grep -q "sccache" build/src/CMakeFiles/Sizer.dir/build.make; then + echo "Verified: generated compile rules invoke sccache" + else + echo "WARNING: sccache is missing from the generated compile rules" >&2 + fi +fi + cmake --build build --target Sizer -j "${NPROC:-$(nproc)}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c5cd6e..035b43a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,10 @@ jobs: build-linux-x64: name: Build Linux x64 runs-on: ubuntu-22.04 + env: + # sccache-action does not enable the GHA cache backend by itself; + # without this, sccache falls back to an ephemeral local-disk cache. + SCCACHE_GHA_ENABLED: "true" outputs: archive-name: ${{ steps.package.outputs.archive-name }} steps: @@ -37,6 +41,10 @@ jobs: env: SIZER_VERSION: ${{ inputs.version }} + - name: Show sccache stats + if: always() + run: "${SCCACHE_PATH:-sccache} --show-stats" + - name: Package Sizer with runtime wrapper id: package env: