|
| 1 | +#!/bin/bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +# XFAIL: cmake 4.x generates arguments that trigger sccache's @ response file |
| 5 | +# rejection in gcc.rs:349. This test tracks the issue and captures the actual |
| 6 | +# compiler commands for debugging. |
| 7 | + |
| 8 | +SCCACHE="${SCCACHE_PATH:-/sccache/target/debug/sccache}" |
| 9 | + |
| 10 | +echo "==========================================" |
| 11 | +echo "Testing: CMake 4.x C++20 Modules (XFAIL)" |
| 12 | +echo "==========================================" |
| 13 | + |
| 14 | +echo "cmake version: $(cmake --version | head -1)" |
| 15 | +echo "clang version: $(clang++ --version | head -1)" |
| 16 | + |
| 17 | +# Copy cmake-modules project to writable location |
| 18 | +cp -r /sccache/tests/integration/cmake-modules /build/cmake-modules |
| 19 | + |
| 20 | +# Start sccache server |
| 21 | +"$SCCACHE" --start-server || true |
| 22 | + |
| 23 | +echo "" |
| 24 | +echo "Build 1: Capture compiler commands" |
| 25 | +cd /build/cmake-modules |
| 26 | +cmake -B build -G Ninja \ |
| 27 | + -DCMAKE_C_COMPILER=clang \ |
| 28 | + -DCMAKE_CXX_COMPILER=clang++ \ |
| 29 | + -DCMAKE_C_COMPILER_LAUNCHER="$SCCACHE" \ |
| 30 | + -DCMAKE_CXX_COMPILER_LAUNCHER="$SCCACHE" |
| 31 | + |
| 32 | +echo "" |
| 33 | +echo "=== Ninja build rules (grep for @ in commands) ===" |
| 34 | +grep '@' build/build.ninja || echo "(no @ found in build.ninja)" |
| 35 | + |
| 36 | +echo "" |
| 37 | +echo "=== Full compiler commands (ninja -v) ===" |
| 38 | +cmake --build build -- -v 2>&1 | cat |
| 39 | + |
| 40 | +echo "" |
| 41 | +echo "=== sccache stats ===" |
| 42 | +"$SCCACHE" --show-stats |
| 43 | + |
| 44 | +STATS_JSON=$("$SCCACHE" --show-stats --stats-format=json) |
| 45 | +NOT_CACHED=$(echo "$STATS_JSON" | python3 -c "import sys, json; print(json.load(sys.stdin).get('stats', {}).get('not_cached', {}).get('@', 0))") |
| 46 | +CACHE_HITS=$(echo "$STATS_JSON" | python3 -c "import sys, json; stats = json.load(sys.stdin).get('stats', {}); print(stats.get('cache_hits', {}).get('counts', {}).get('C/C++', 0))") |
| 47 | + |
| 48 | +echo "" |
| 49 | +echo "Cache hits: $CACHE_HITS" |
| 50 | +echo "Non-cacheable @: $NOT_CACHED" |
| 51 | + |
| 52 | +if [ "$CACHE_HITS" -gt 0 ]; then |
| 53 | + echo "XPASS: CMake 4.x C++20 modules now cacheable! Remove XFAIL status." |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | + |
| 57 | +if [ "$NOT_CACHED" -gt 0 ]; then |
| 58 | + echo "XFAIL: cmake 4.x @ issue reproduced (expected failure)" |
| 59 | + exit 0 |
| 60 | +fi |
| 61 | + |
| 62 | +echo "FAIL: Unexpected failure" |
| 63 | +echo "$STATS_JSON" | python3 -m json.tool |
| 64 | +exit 1 |
0 commit comments