Skip to content

Commit 2681bde

Browse files
committed
Windows CUDA: don't sccache-wrap nvcc; fail loudly on empty build
Run 28329638757 (788aaef): the CUDA build job went GREEN but produced an empty artifact, so `package` failed with "Artifact not found: Windows-x86_64-cuda". Two bugs: 1. sccache cannot wrap nvcc on Windows — it dies with "sccache: error: Could not parse shell line" on every .cu compile, so ggml-cuda never builds. My build.bat nvcc-launcher addition (mirrored from build.sh, which works on Linux) is the cause. Remove it: CUDA device code now builds with nvcc directly (uncached); the cl.exe C/C++ TUs still cache via the C/CXX launcher. 2. The failed `cmake --build` exited 0 (sccache-as-launcher failure path), so build.bat reached the end and the job went green with no DLLs. build.bat now captures the build exit code, prints sccache stats regardless, then propagates a non-zero exit. As a backstop, the three GPU upload-artifact steps use if-no-files-found: error so an empty output fails the job loudly instead of surfacing later at package. Docs (CLAUDE.md) corrected re: nvcc not being cached on Windows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Deqf9xS6jz9t1idytVTaPV
1 parent 788aaef commit 2681bde

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

.github/build.bat

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,28 @@ if /I "%USE_CACHE%"=="true" (
3838
)
3939
)
4040

41-
REM CUDA device-code caching: when sccache wrapping succeeded (LAUNCH set) and this
42-
REM is a CUDA build (GGML_CUDA in the cmake args), also front nvcc with sccache so the
43-
REM per-arch .cu device passes cache over Depot alongside the cl.exe TUs (mirrors
44-
REM build.sh). Inert on non-CUDA builds (the flag is simply unused).
45-
if defined LAUNCH (
46-
echo %* | findstr /I "GGML_CUDA" >nul
47-
if not errorlevel 1 (
48-
set "LAUNCH=!LAUNCH! -DCMAKE_CUDA_COMPILER_LAUNCHER=sccache"
49-
echo build.bat: CUDA build detected -- also wrapping nvcc with sccache.
50-
)
51-
)
41+
REM NOTE: nvcc is NOT wrapped with sccache on Windows. Unlike build.sh (Linux) -- where
42+
REM sccache caches the per-arch .cu device passes -- sccache on Windows cannot parse the
43+
REM nvcc command line (it dies with `sccache: error: Could not parse shell line` and
44+
REM fails every .cu compile). So CUDA device code is built by nvcc directly (uncached)
45+
REM here; the cl.exe C/C++ TUs still cache via the C/CXX launcher set above.
5246

5347
mkdir build
5448
cmake -Bbuild %LAUNCH% %*
55-
if errorlevel 1 exit /b %ERRORLEVEL%
49+
if errorlevel 1 exit /b 1
5650
cmake --build build --config Release
57-
if errorlevel 1 exit /b %ERRORLEVEL%
51+
set "BUILD_RC=!ERRORLEVEL!"
5852

59-
REM Only query stats when sccache was actually wired in as the launcher; re-invoking
60-
REM a rejected/crashing sccache here would just repeat its failure output.
53+
REM Print cache stats (best-effort) regardless of build outcome -- only when sccache
54+
REM was wired in as the launcher.
6155
if defined LAUNCH (
6256
echo build.bat: sccache --show-stats
6357
sccache --show-stats
6458
)
59+
60+
REM Propagate a build failure as a non-zero exit (a prior bug let a failed `cmake
61+
REM --build` reach here and exit 0, masquerading as a green build with no artifacts).
62+
if not "!BUILD_RC!"=="0" (
63+
echo build.bat: cmake --build failed with exit code !BUILD_RC!.
64+
exit /b !BUILD_RC!
65+
)

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ jobs:
734734
with:
735735
name: Windows-x86_64-cuda
736736
path: ${{ github.workspace }}/src/main/resources_windows_cuda/net/ladenthin/llama/
737+
if-no-files-found: error
737738

738739
build-windows-x86_64-vulkan:
739740
name: Build Windows 2025 x86_64 Vulkan (Ninja + sccache)
@@ -782,6 +783,7 @@ jobs:
782783
with:
783784
name: Windows-x86_64-vulkan
784785
path: ${{ github.workspace }}/src/main/resources_windows_vulkan/net/ladenthin/llama/
786+
if-no-files-found: error
785787

786788
build-windows-x86_64-opencl:
787789
name: Build Windows 2025 x86_64 OpenCL (Ninja + sccache)
@@ -825,6 +827,7 @@ jobs:
825827
with:
826828
name: Windows-x86_64-opencl
827829
path: ${{ github.workspace }}/src/main/resources_windows_opencl/net/ladenthin/llama/
830+
if-no-files-found: error
828831

829832
# ---------------------------------------------------------------------------
830833
# CI-only jobs — no release artifact, purely for test coverage

CLAUDE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,12 @@ Wiring (mirrors the CUDA-Linux / OpenCL-Android classifier pattern):
202202
`resources_android_opencl`). The default CPU build (both generators) still emits to the canonical
203203
`src/main/resources/.../Windows/{x86_64,x86}/`, so the Ninja-vs-MSVC split is purely a
204204
CI-artifact-name + pom-profile concern (no CMake change for it).
205-
2. **`.github/build.bat`** — the sccache probe guard (mirrors `build.sh`); for CUDA builds it also
206-
adds `-DCMAKE_CUDA_COMPILER_LAUNCHER=sccache` (detects `GGML_CUDA` in the args) so nvcc caches too.
205+
2. **`.github/build.bat`** — the sccache probe guard (mirrors `build.sh`) wraps the **cl.exe** C/C++ TUs
206+
only. Unlike `build.sh` (Linux), it does **not** wrap `nvcc`: sccache on Windows can't parse the nvcc
207+
command line (`sccache: error: Could not parse shell line`) and fails every `.cu` compile, so CUDA
208+
device code builds with nvcc directly (uncached). `build.bat` also propagates a `cmake --build`
209+
failure as a non-zero exit (a prior bug let a failed CUDA build exit 0 → empty artifact → late
210+
`package` failure); the GPU upload steps additionally use `if-no-files-found: error` as a backstop.
207211
3. **`.github/build_opencl_windows.bat`** — stages Khronos OpenCL-Headers + builds OpenCL-ICD-Loader
208212
(`OpenCL.lib`), then delegates to `build.bat` with `-DOpenCL_INCLUDE_DIR`/`-DOpenCL_LIBRARY`
209213
(the Windows analogue of `build_opencl_android.sh`).

0 commit comments

Comments
 (0)