Skip to content

cmake: conditionally enable ASM via check_language to fix MSVC/CMake configuration failures#29

Open
turbolego wants to merge 3 commits into
AtomicBot-ai:feature/turboquant-kv-cachefrom
turbolego:feature/turboquant-kv-cache
Open

cmake: conditionally enable ASM via check_language to fix MSVC/CMake configuration failures#29
turbolego wants to merge 3 commits into
AtomicBot-ai:feature/turboquant-kv-cachefrom
turbolego:feature/turboquant-kv-cache

Conversation

@turbolego

Copy link
Copy Markdown

Overview

This PR fixes a Windows/MSVC configuration failure in ggml caused by unconditional enabling of the ASM language in CMake.

On modern CMake versions (CMake 4.x / CMP0194 policy behavior), MSVC is not reliably treated as a valid ASM compiler. This leads to early configuration failures such as:

  • "No CMAKE_ASM_COMPILER could be found"
  • "The ASM compiler identification is unknown"

even when a fully functional Visual Studio toolchain is present.

To address this, ASM support is now enabled conditionally using check_language(ASM), and only activated when the toolchain actually supports it. On MSVC, ASM is skipped while remaining enabled for toolchains where it is supported (GNU, Clang, NASM, etc.).

This preserves ASM optimizations where available while fixing Windows/MSVC build reliability issues without globally disabling ASM.


Additional information

This change avoids forcing ASM via:

project("ggml" C CXX ASM)

Instead, ASM is now enabled only when CMake confirms support:

include(CheckLanguage)

check_language(ASM)
if (CMAKE_ASM_COMPILER AND NOT MSVC)
    enable_language(ASM)
endif()

project("ggml" C CXX)

Why this is needed

Recent CMake versions changed ASM handling under policy CMP0194:

  • MSVC is no longer considered a valid ASM compiler candidate
  • enable_language(ASM) may fail early in configuration
  • Projects that unconditionally enable ASM can break even without using assembly sources

Since ggml does not require ASM for CUDA / CPU builds on Windows, disabling ASM conditionally avoids breaking configuration while keeping ASM support intact on supported toolchains.

Impact

  • Fixes Windows/MSVC configuration failures
  • Preserves ASM optimizations on Linux/macOS/other toolchains
  • No runtime behavior changes
  • CUDA and CPU backends are unaffected

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: AI was used to draft, tested manually by me before submission.

…ke detection failure on Windows

MSVC toolchains on Windows (especially with modern CMake versions) are not reliably
recognized as valid ASM compilers, causing CMake to fail during project() configuration
with "No CMAKE_ASM_COMPILER could be found".

Although GGML does not strictly require assembly support on Windows (CUDA and CPU
backends function without it), the project was declaring ASM in the top-level CMake
configuration:

    project(ggml C CXX ASM)

This causes CMake to attempt ASM compiler detection before MSVC MASM (ml64) is properly
initialized, leading to hard configuration failures.

This change removes ASM from the project declaration:

    project(ggml C CXX)

This avoids premature ASM language enablement and allows the build to proceed normally
on MSVC toolchains while still supporting CUDA and CPU backends.

Fixes Windows build failures related to CMake ASM detection (CMP194 / MSVC ASM incompatibility).
…of unconditional MSVC inclusion

Replace unconditional ASM language declaration in ggml with a conditional
CMake check using `check_language(ASM)`.

On MSVC toolchains, modern CMake versions (CMP0194) do not reliably
support treating MSVC as a valid ASM compiler, causing configuration
failures such as:

  "No CMAKE_ASM_COMPILER could be found"

This change ensures ASM is only enabled when CMake confirms ASM support
is available for the current toolchain, while preserving ASM usage on
toolchains where it is properly supported (GNU/Clang/NASM/etc).

No change in runtime behavior. Windows/MSVC builds are stabilized without
disabling ASM globally.
@github-actions github-actions Bot added the ggml label Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant