Repository navigation
cmake: ease Windows clang and custom ROCm builds from source - #16974
Open
tenderdeve wants to merge 1 commit into
Open
tenderdeve wants to merge 1 commit into
tenderdeve wants to merge 1 commit into
Conversation
Two friction points when building from source on Windows with clang and with non-standard ROCm toolchains: - With clang as the C/C++ compiler, CMake can't locate the Windows Resource Compiler (rc.exe) and the build fails unless the user passes a version-specific -DCMAKE_RC_COMPILER. Search the installed Windows SDKs and select the newest rc.exe automatically. Only runs on Windows when CMAKE_RC_COMPILER isn't already set. - Custom ROCm layouts (TheRock, self-built, nightly) keep the device bitcode at a non-standard path and need --rocm-device-lib-path, which currently means patching the vendored ggml-hip CMake. Add an opt-in OLLAMA_HIP_DEVICE_LIB_PATH cache variable that injects the flag, routed through CXX flags on Windows where ggml-hip builds with CXX_IS_HIPCC. Both changes are gated and default to no-ops, so non-Windows and default ROCm builds are unaffected.
This branch has not been deployed
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.
Fixes #16889
Two build-from-source friction points reported on Windows + clang / custom ROCm toolchains, both fixed with gated, opt-in CMake changes.
1. Auto-detect the Windows Resource Compiler. With clang as the C/C++ compiler (instead of MSVC), CMake can't find
rc.exeon its own, so the build fails unless you pass a version-specific-DCMAKE_RC_COMPILER=".../Windows Kits/10/bin/10.0.xxxxx.0/x64/rc.exe". The top-level CMake now globs the installed Windows SDKs and picks the newestrc.exeautomatically. Runs only on Windows, only whenCMAKE_RC_COMPILERisn't already set — globbing avoids hardcoding SDK versions.2.
OLLAMA_HIP_DEVICE_LIB_PATHcache variable. Custom ROCm layouts (TheRock, self-built, nightly) keep the device bitcode at e.g.<rocm>/lib/llvm/amdgcn/bitcodeinstead of<rocm>/amdgcn/bitcode, requiring--rocm-device-lib-path. Today that means patching the vendoredggml-hipCMake. The new opt-in cache var injects the flag into the existingrocm_v*HIP block, routed through CXX flags on Windows (where ggml-hip builds withCXX_IS_HIPCC, soCMAKE_HIP_FLAGSis ignored) and HIP flags elsewhere.Both default to no-ops and are gated on
WIN32/ the cache var being set, so non-Windows and standard ROCm builds are unchanged.Verification: I don't have a Windows/ROCm box, so I validated the CMake logic in isolation rather than a full Windows build — the SDK glob+sort picks the newest
rc.exefrom a fake SDK tree, the$ENV{ProgramFiles(x86)}escaping parses, and the device-lib-path flag routes to CXX flags on Windows. A configure on macOS executes the new top-level block cleanly. Would appreciate a maintainer with a Windows + clang / custom-ROCm setup confirming the end-to-end build.