Skip to content

fix: const-correctness in ggml-bitnet-mad.cpp + missing chrono includes (fixes #334)#422

Open
redhole-org wants to merge 1 commit intomicrosoft:mainfrom
redhole-org:fix/const-correctness-clangcl
Open

fix: const-correctness in ggml-bitnet-mad.cpp + missing chrono includes (fixes #334)#422
redhole-org wants to merge 1 commit intomicrosoft:mainfrom
redhole-org:fix/const-correctness-clangcl

Conversation

@redhole-org
Copy link

@redhole-org redhole-org commented Mar 11, 2026

Summary

Two build fixes for ClangCL (Windows) and strict compilers:

1. const-correctness in ggml-bitnet-mad.cpp (this commit)

Line 811 assigns const int8_t* y to int8_t* y_col, dropping the const qualifier. ClangCL and GCC with -Werror reject this.

Fix: int8_t * y_col = y -> const int8_t * y_col = y

2. Missing #include <chrono> in llama.cpp submodule (fixes #334)

Two files in the llama.cpp submodule use std::chrono without including <chrono>. This compiles on GCC/MSVC (transitive includes) but fails on ClangCL.

Files needing fix:

  • 3rdparty/llama.cpp/common/common.cpp (line 445: std::chrono::system_clock)
  • 3rdparty/llama.cpp/common/log.cpp (line 28: std::chrono::system_clock)

Fix: Add #include <chrono> to both files. Since these are in the llama.cpp submodule (Eddie-Wang1120/llama.cpp), the fix needs to be applied there and the submodule ref updated. The diff for each file is trivial — just add #include <chrono> with the other standard library includes.

Verification

Both fixes are validated in CI across macOS ARM64, Linux x64, and Windows x64:
https://github.com/redhole-org/bitnet-builds/actions

`y` is declared as `const int8_t *` (line 794) but `y_col` on line 811
drops the const qualifier by assigning to `int8_t *`. This is a
const-correctness violation that compiles as a hard error on Clang with
strict settings (e.g. ClangCL on Windows).

Additionally, the llama.cpp submodule has missing `#include <chrono>` in
`common/log.cpp` and `common/common.cpp` — both use
`std::chrono::system_clock` but rely on transitive includes that only
work on GCC/Apple Clang, not ClangCL. That fix should be applied to the
llama.cpp submodule (Eddie-Wang1120/llama.cpp branch merge-dev).
@ilhangrn
Copy link

Thanks, it helps but we need to update some more files with #include as mentioned here: #334

@redhole-org redhole-org changed the title fix: const-correctness in ggml-bitnet-mad.cpp fix: const-correctness in ggml-bitnet-mad.cpp + missing chrono includes (fixes #334) Mar 13, 2026
@redhole-org
Copy link
Author

@ilhangrn Good catch — you're right that #334 is a related build issue. I've updated this PR to cover both:

  1. This commit fixes const int8_t* correctness in src/ggml-bitnet-mad.cpp (BitNet's own code)
  2. solve the errors building llama.cpp #334 is a missing #include <chrono> in the llama.cpp submodule — specifically 3rdparty/llama.cpp/common/common.cpp and 3rdparty/llama.cpp/common/log.cpp

The chrono fix can't be committed directly here since those files live in the Eddie-Wang1120/llama.cpp submodule, but I've documented the exact fix in the PR description. The submodule would need to be patched upstream and the ref updated here.

We validate both fixes in our CI across all three platforms (macOS ARM64, Linux x64, Windows x64): https://github.com/redhole-org/bitnet-builds/actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

solve the errors building llama.cpp

2 participants