cuda: fix MSVC duplicate-COMDAT link failure from twice-nested retired_buf - #355
Merged
TheTom merged 1 commit intoSep 6, 2026
Conversation
…d_buf q8_cache and tq_rot_cache are unnamed member structs of ggml_backend_cuda_context, and each nested its own identical `struct retired_buf`. MSVC decorates a type nested in an unnamed struct as <unnamed-tag>, so both nested types mangle to the same decorated name and the two std::vector<retired_buf> instantiations emit COMDAT sections with identical names into a single ggml-cuda.cu.obj. link.exe rejects the object: ggml-cuda.cu.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT '??$?0$$V@?$_Compressed_pair@V?$allocator@Uretired_buf@<unnamed-tag>@ ggml_backend_cuda_context@@@std@@...' The two definitions are identical, so hoist a single retired_buf to class scope, where it is a member of a named class and mangles unambiguously. Every use is either `auto` or braced initialisation, so no call site changes. Neither parent commit is at fault on its own: 767b627 added the q8 cache and 3df06b1 the TQ rotation cache, and the collision only appears once both are in the same translation unit. Verified by building the full CUDA target on Windows with MSVC 14.51 and CUDA sm_120 (Ninja, Release, BUILD_SHARED_LIBS=ON): fails to link at 80007e7 and links cleanly with this change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
Thanks, and sorry: that nesting came from my fix on #343, and the hosted Windows jobs build with clang so they never saw it. Hoisting the one |
TheTom
merged commit Sep 6, 2026
407f323
into
TheTom:feature/turboquant-kv-cache
5 of 19 checks passed
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.
What
feature/turboquant-kv-cacheat80007e715does not link on Windows/MSVC.q8_cacheandtq_rot_cacheare unnamed member structs ofggml_backend_cuda_context, and each nested its ownidentical
struct retired_buf:MSVC decorates a type nested in an unnamed struct as
<unnamed-tag>, so both nested types mangleto the same decorated name. The two
std::vector<retired_buf>instantiations then emit COMDATsections with identical names into a single
ggml-cuda.cu.obj, andlink.exerejects the object:Because ninja deletes the target before linking, a failed build also leaves the tree without
ggml-cuda.dll, so an incremental rebuild on Windows takes the previously working binary with it.Fix
The two definitions are identical, so hoist a single
retired_bufto class scope. As a member ofa named class it mangles unambiguously, and the duplication goes away as a side effect. Every use
is either
autoor braced initialisation (ggml-cuda.cu:751-762,mmvq.cu:1300,mmvq-tq.cu:927), so no call site changes.Who introduced it
Neither parent is at fault alone:
767b6278eadded the q8 quantize cache and3df06b110the TQrotation cache, each with its own nested copy. The collision only exists once both are in the same
translation unit.
Verification
Windows 11, MSVC 14.51, CUDA sm_120 (RTX 5090 Laptop), Ninja, Release,
BUILD_SHARED_LIBS=ON,CMAKE_CUDA_ARCHITECTURES=120-real:80007e715unmodified:FAILED: bin/ggml-cuda.dll, LNK1179 as above80007e715+ this commit: fullcmake --buildcompletes, 0 errors,ggml-cuda.dllproducedNon-MSVC toolchains were not affected to begin with — GCC and Clang give the nested types distinct
mangled names — so this should be a no-op there.
🤖 Generated with Claude Code