Skip to content

fix: Windows (MSVC) native and CUDA builds#1

Open
smanaton wants to merge 2 commits into
Apothic-AI:masterfrom
smanaton:windows-fixes
Open

fix: Windows (MSVC) native and CUDA builds#1
smanaton wants to merge 2 commits into
Apothic-AI:masterfrom
smanaton:windows-fixes

Conversation

@smanaton

@smanaton smanaton commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Three build.rs fixes — each a hard build/link failure on Windows:

  1. Verbatim paths: canonicalize() returns \\?\... paths that MSVC cl.exe cannot use in -I dirs. Strip carefully:
    • \\?\C:\fooC:\foo
    • \\?\UNC\server\share\\server\share
  2. advapi32: link on Windows for ggml-cpu registry-based CPU detection.
  3. CUDA link flags: previously Linux-only; emit Windows import libs (cudart, cublas, cublasLt, cuda) plus lib\x64 search path when CUDA is enabled.

Test plan

  • Validated on Windows 11 (MSVC, CUDA 12.2, RTX 4090) against mainline llama.cpp: CPU and CUDA builds link and run.
  • CPU vs GPU eval consistency on Bonsai GGUF lab runs.
  • Optional: verify UNC checkout path strip on a network share.

Notes

Fork staging: smanaton#1
Recommend merging before the prefer-mainline-llama PR.

Three build-script fixes, each a hard build failure on Windows:

- canonicalize_llama_cpp_dir returned \?\-prefixed verbatim paths, which
  cl.exe cannot resolve in -I include dirs (fatal error C1083 on
  ggml-backend.h). Strip the verbatim prefix after canonicalizing.
- The target_os link-lib match had no windows arm; ggml-cpu's CPU detection
  calls RegOpenKeyExA/RegQueryValueExA/RegCloseKey, leaving three unresolved
  __imp_Reg* externals at link time. Link advapi32.
- emit_cuda_link_flags was Linux-only and its lib set (cudart_static/culibos/
  dl/rt/pthread) is Unix-specific, so --features cuda compiled every kernel
  then failed to link. Add a Windows variant emitting the cudart/cublas/
  cublasLt/cuda import libs plus the lib\x64 search path, which
  cuda_library_dir misses when the bare lib parent exists.

Validated on Windows 11 (MSVC 14.51, CUDA 12.2, RTX 4090) against mainline
llama.cpp b10054: CPU and CUDA builds link and run; CPU vs GPU eval results
on Bonsai-27B-Q1_0 are identical.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job was not started because the account is locked due to a billing issue.

canonicalize() can return \\?\UNC\server\share\...; stripping only \\?\ left
a relative UNC\... path. Map that form to \\server\share\... and plain
\\?\C:\... to C:\... so MSVC/CMake include paths stay absolute.
@smanaton smanaton changed the title Fix Windows (MSVC) native and CUDA builds fix: Windows (MSVC) native and CUDA builds Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants