[Bug] Windows build fails with Clang/MSVC due to missing #include <chrono>
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 40.3k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Building on Windows with ClangCL fails due to missing #include header and const pointer type mismatch in bitnet-mad.cpp.
Steps to Reproduce
- Clone the repository on Windows 11
- Install Clang 19 via Visual Studio 2022 Build Tools + clang-cl
- Run CMake configuration and build
- Observe compilation errors
Expected Behavior
Code should compile on Windows with ClangCL without errors
Actual Behavior
Two compilation errors occur:
Error 1: Missing #include
The following files use std::chrono without explicitly including :
- 3rdparty/llama.cpp/common/common.cpp
- 3rdparty/llama.cpp/common/log.cpp
- 3rdparty/llama.cpp/examples/imatrix/imatrix.cpp
- 3rdparty/llama.cpp/examples/perplexity/perplexity.cpp
On Linux/GCC, is pulled in implicitly, but Clang on Windows is stricter.
Error 2: Const pointer mismatch (src/ggml-bitnet-mad.cpp line 811)
error: cannot initialize a variable of type 'int8_t *' with an rvalue of type 'const int8_t *'
Root Cause Analysis
The root cause is platform-specific header dependency and type constness:
- Header Issue: GCC on Linux transitively includes through other headers, but Clang/MSVC on Windows does not
- Type Issue: The code at line 811 declares
int8_t *but receives aconst int8_t *, which should beconst int8_t *
Proposed Solution
- Add
#include <chrono>to the four affected files - Change line 811 from
int8_t *toconst int8_t *
Environment
- OS: Windows 11
- Compiler: Clang 19 (via Visual Studio 2022 Build Tools + clang-cl)
- CMake: 3.x
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the four listed files under 3rdparty/llama.cpp/common and examples, then inspect src/ggml-bitnet-mad.cpp around line 811. Reproduce the CMake build with clang-cl on Windows and verify that the missing chrono headers and const pointer error are resolved without introducing other compiler errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100