Windows Compilation Fails: CMake errors in setup_env and missing `const` in ggml-bitnet-mad
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- cmake, cpp
- Domain
- build-system, operating-systems
Research direction
Start with setup_env.py and src/ggml-bitnet-mad.cpp, then reproduce the Windows ClangCL configuration and AVX2 compilation described in the issue. Verify both reported compiler failures are resolved by running the Windows build and confirming it completes successfully.
Written by the indexing model from the issue text.
Description
Bug Description:
When attempting to compile BitNet from source on a standard Windows environment, the build fails in two separate places:
###Bug 1: CMake Generator Failure in setup_env .py
The compiler script passes the -T ClangCL argument to CMake on Windows. However, it does not explicitly specify a Generator (like -G "Visual Studio 17 2022"). On many Windows systems, CMake will default to the NMake Makefiles generator, which immediately crashes because NMake does not support the -T toolset flag.
Error log:
Generator NMake Makefiles does not support toolset specification, but toolset ClangCL was specified.
The Fix for Bug 1:
In setup_env .py (Line 72), explicitly define the Visual Studio Generator so CMake can actually use the ClangCL toolset.
Change from:
OS_EXTRA_ARGS = {
"Windows":["-T", "ClangCL"],
}
Change to:
OS_EXTRA_ARGS = {
"Windows":["-G", "Visual Studio 17 2022", "-T", "ClangCL"],
}
Bug 2: Missing const type-cast in ggml-bitnet-mad .cpp
Once CMake successfully generates the build files using ClangCL, the actual C++ compilation crashes. The strict Windows Clang compiler rejects an assignment on line 811 inside the AVX2 block of src/ggml-bitnet-mad .cpp because a const modifier was forgotten.
Error log:
error : cannot initialize a variable of type 'int8_t *' with an rvalue of type 'const int8_t *'
The Fix for Bug 2:
In src/ggml-bitnet-mad .cpp (Line 811), the pointer y is explicitly declared as a constant on line 794, so y_col must also be a constant.
Change from:
int8_t * y_col = y + col * by;
Change to:
const int8_t * y_col = y + col * by;
With these two tiny fixes applied, the system compiles flawlessly out-of-the-box on Windows using AVX2 and Clang!
- Dominant language
- C++
- Stars
- 40.3k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
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.
More from microsoft/BitNet
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
i2_s SIGSEGVs at n_ubatch >= 32: BLAS backend dequantises by a row stride 4x the real packed row Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
All issues in microsoft/BitNet
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·