Skip to content

Fix Windows/MinGW build and inference#1

Open
sd983527 wants to merge 1 commit into
microsoft:mainfrom
sd983527:windows-mingw-port
Open

Fix Windows/MinGW build and inference#1
sd983527 wants to merge 1 commit into
microsoft:mainfrom
sd983527:windows-mingw-port

Conversation

@sd983527

Copy link
Copy Markdown

Summary

Fixes three portability issues that prevented building and running VibeASR.cpp on Windows with MinGW GCC. With these changes the project builds with MinGW GCC 13.2 (Ninja) and transcribes correctly on CPU.

Changes

  • clock_gettime is POSIX-onlyclock_gettime / CLOCK_MONOTONIC / struct timespec are unavailable under MinGW, breaking src/vae.cpp, src/asr_server.cpp, and demo/asr_infer.cpp. Added include/time_compat.h, a std::chrono-based shim that is a no-op on platforms that already provide clock_gettime.
  • mmap model load fails on MinGW — llama.cpp aborts with PrefetchVirtualMemory unavailable. Set use_mmap = false for LM loading, guarded by #ifdef _WIN32.
  • 128 GB VAE context reservation — the VAE compute context reserves 128 GB, which relies on Linux memory overcommit and fails outright on Windows. Capped at 6 GB under #ifdef _WIN32 (ample for the intermediate tensors).

All changes are guarded so Linux/macOS behavior is unchanged.

Test plan

  • Configure + build with MinGW GCC 13.2 via Ninja (cmake -B build -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++)
  • Run asr_infer on a 16 kHz mono WAV (JFK sample) — transcription is correct
  • Confirm Linux/macOS builds are unaffected (changes are #ifdef _WIN32-guarded / no-op shim)

Note

On Windows the top-level CMakeLists.txt still requires Clang or GCC (MSVC is rejected), so users must point CMake at a MinGW/Clang toolchain, e.g. -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++. This PR does not change that requirement.

🤖 Generated with Claude Code

Three portability issues prevented building and running on Windows with
MinGW GCC:

- clock_gettime/CLOCK_MONOTONIC/struct timespec are POSIX-only and absent
  under MinGW. Add include/time_compat.h, a std::chrono-based shim that is
  a no-op on platforms that already provide clock_gettime.
- llama.cpp aborts model load with "PrefetchVirtualMemory unavailable" on
  MinGW builds. Disable mmap (use_mmap = false) for LM loading on _WIN32.
- The VAE compute context reserves 128 GB, which relies on Linux memory
  overcommit and fails outright on Windows. Cap the reservation at 6 GB on
  _WIN32, which is ample for the intermediate tensors.

Verified end-to-end: builds with MinGW GCC 13.2 (Ninja) and transcribes
correctly on CPU.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant