Skip to content

Windows Compilation Fails: CMake errors in setup_env and missing const in ggml-bitnet-mad #513

@Lakshay-Singh

Description

@Lakshay-Singh

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions