microsoft / microsoft/BitNet

[Bug] Windows build fails with Clang/MSVC due to missing #include <chrono>

Open
#492 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Clone the repository on Windows 11
  2. Install Clang 19 via Visual Studio 2022 Build Tools + clang-cl
  3. Run CMake configuration and build
  4. 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:

  1. Header Issue: GCC on Linux transitively includes through other headers, but Clang/MSVC on Windows does not
  2. Type Issue: The code at line 811 declares int8_t * but receives a const int8_t *, which should be const int8_t *

Proposed Solution

  1. Add #include <chrono> to the four affected files
  2. Change line 811 from int8_t * to const 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.