BitNet icon indicating copy to clipboard operation
BitNet copied to clipboard

Adding MinGW/GCC Compiler support for Cross-Platform Development

Open saifxyzyz opened this issue 2 months ago • 0 comments

Summary

This PR introduces necessary changes to the build system, CMake files, and source code to enable successful compilation and running of BitNet using MinGW (Minimalist GNU for Windows) and GCC compiler. This change significantly improves cross-platform compatibility and allows developers who prefer or require open-source toolchains (like those on Linux or using MinGW on Windows) to contribute and utilize the project without relying on Microsoft Visual C++ (MSVC).

Key Changes

The modifications span build logic and low-level kernel definitions to ensure seamless compatibility with the GNU toolchain:

  • Build System Adaptation: Modified setup_env.py to correctly detect and select the MinGW/GCC toolchain and invoke CMake with the appropriate compiler flags.
  • Source Code Refactoring: Applied necessary changes to critical header files (including bitnet-lut-kernels.h, ggml-bitnet.h, and kernel_config.h) to: - Resolve MSVC-specific syntax or intrinsic function calls. - Implement conditional compilation logic (via preprocessor checks) to ensure the core kernel behavior is correct when compiled under GCC.
  • Compiler Configuration: Added/updated configuration files to manage toolchain-specific dependencies.

Testing

successfully compiled and run essential tests/examples using MinGW toolchain to verify functionality.

Testing Environment:

Operating System: Windows 11
Compiler: MinGW (GCC 15.1.0, built by MSYS2)
Build System: CMake 4.1.1

saifxyzyz avatar Oct 22 '25 19:10 saifxyzyz