fix: Windows (MSVC) native and CUDA builds#1
Open
smanaton wants to merge 2 commits into
Open
Conversation
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 stopped reviewing on behalf of
smanaton due to an error
July 17, 2026 18:00
3 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three
build.rsfixes — each a hard build/link failure on Windows:canonicalize()returns\\?\...paths that MSVCcl.execannot use in-Idirs. Strip carefully:\\?\C:\foo→C:\foo\\?\UNC\server\share→\\server\sharecudart,cublas,cublasLt,cuda) pluslib\x64search path when CUDA is enabled.Test plan
Notes
Fork staging: smanaton#1
Recommend merging before the prefer-mainline-llama PR.