Skip to content

32-bit Windows target (i686-windows-msvc) fails to parse <Windows.h> in module BMI build: MS-style inline assembly is not available: target MC unavailable #100

Done

Description

@julixian

Summary

When targeting 32-bit Windows ("mcppls.buildDiscovery.mcppTarget": "i686-windows-msvc" / --target=i686-pc-windows-msvc), the bundled clangd.okb fails to build module BMIs for any C++23 module that directly or indirectly includes <Windows.h> (or <winnt.h>), reporting:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\winnt.h:1064:5: error: MS-style inline assembly is not available: target MC unavailable
 1064 |     __asm    {
      |     ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\winnt.h:1080:5: error: MS-style inline assembly is not available: target MC unavailable
 1080 |     __asm {
      |     ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\winnt.h:1096:5: error: MS-style inline assembly is not available: target MC unavailable
 1096 |     __asm    {
      |     ^
3 errors generated.
module worker compilation failed

This cascades and causes all downstream modules depending on <Windows.h>-using modules to fail prerequisite BMI compilation, while non-<Windows.h> modules (such as std, std.compat, boost, spdlog, etc.) build cleanly.


Environment

  • OS: Windows 11 (win32-x64, 10.0.26300)
  • VS Code: 1.147.0
  • mcppls: 0.24.1 (mcppls-kit-openkal-0.24.4)
  • Bundled clangd: 23.1.0-mcppls.12 (clangd/openkal/bin/clangd.okb, llvm-base-version: 23.1.0)
  • mcpp: 2026.11.22.1
  • Target: i686-windows-msvc (--target=i686-pc-windows-msvc)
  • MSVC Sysroot: 14.44.35207
  • Windows SDK: 10.0.26100.0

Minimal Reproduction

  1. Create a C++23 mcpp project with a module interface unit (.ixx) that includes <Windows.h> in the global module fragment:
    module;
    #include <Windows.h>
    export module win_demo;
    
    export inline DWORD getTick() {
        return GetTickCount();
    }
  2. Configure VS Code with:
    {
      "mcppls.buildDiscovery.mcppTarget": "i686-windows-msvc"
    }
  3. Open a .cpp file importing win_demo in VS Code with mcppls enabled.
  4. Observe the module worker failing with winnt.h:1064/1080/1096: error: MS-style inline assembly is not available: target MC unavailable.

Verification & Comparison

  • CLI build succeeds: Running mcpp build --target i686-windows-msvc (which invokes full clang++ with the X86 target backend) compiles the exact same modules and <Windows.h> headers with zero errors.
  • 64-bit target workaround succeeds: Switching mcppls.buildDiscovery.mcppTarget to "x86_64-windows-msvc" eliminates the errors immediately, because winnt.h only uses __asm blocks under _M_IX86 (lines 1018–1103) and uses plain C shift macros under _M_AMD64 (lines 1013–1015).

Root Cause & Suggested Fix

  • Under 32-bit Windows (_M_IX86), Windows SDK um/winnt.h defines Int64ShllMod32, Int64ShraMod32, and Int64ShrlMod32 using MSVC-style __asm { ... } inline assembly blocks.
  • Clang requires LLVM's X86 Target MC / X86AsmParser to parse MS-style inline assembly even during syntax/semantic/BMI compilation.
  • The bundled clangd.okb (23.1.0-mcppls.12) appears to be built without linking/initializing the LLVM X86 Target MC / X86AsmParser components.
  • Suggested fix: Enable and link LLVM X86 Target MC / X86AsmParser (e.g. include X86 in LLVM_TARGETS_TO_BUILD and initialize LLVMInitializeX86AsmParser / LLVMInitializeX86TargetMC) when building the bundled clangd.okb payload so 32-bit i686-windows-msvc Windows SDK headers parse cleanly.

Activity

  1. Sunrisepeak commented on Nov 26, 2026

    @Sunrisepeak
    Owner

    Thanks for the detailed report and the 64-bit comparison — it pinned this down quickly.

    Cause (not an engine without X86; the bundled engine has always built it): clang parses MS-style __asm { } with the target's MC and assembly parser, which clangd did not register. clangd's editor path hides the resulting "target MC unavailable" diagnostic, but a module build cannot: clang writes no module interface once an error has been reported, so the module that includes <Windows.h> for i686-windows-msvc (and every module importing it) failed. winnt.h uses __asm only under _M_IX86, which is why x86_64-windows-msvc was never affected.

    Fix: mcppls-clangd 0.0.24 (23.1.0-mcppls.13, patch 0049: the x86 MC and assembly parser are linked and registered before anything compiles, the module worker included), carried by mcppls 0.24.2 / VS Code extension 0.24.2 (release vscode-v0.24.2, currently a draft until it is verified and published). Reproduced on the unmodified engine on Linux (--target=i686-pc-windows-msvc, a module with an __asm block: the worker prints your error and the importer reports module not found), fixed on the patched one, and covered by two conformance fixtures: compdb-i686-asm (an __asm module, Linux) and compdb-clangxx-msvc-i686-windows-h (your shape with the SDK's own <Windows.h>, Windows), both green in CI.

    Limit: the libraries are not linked for an arm64 engine (Apple silicon, Linux arm64): the arm64 image that linked them ended by SIGBUS in CI, cause not found. On an arm64 host the module still does not build; an x64 host is fixed.

    Design and what implementation found: .agents/docs/2026-11-26-issue-100-engine-batch-design.md. I'll close this once the release is published.

  2. Sunrisepeak commented on Nov 26, 2026

    @Sunrisepeak
    Owner

    Correction: the fix ships as 0.25.0 (the whole series), not 0.24.2 as I wrote earlier. 0.24.2 never shipped: any change to the server (here the engine payload, mcppls-clangd 0.0.24 / clangd 23.1.0-mcppls.13) moves the series, and the release rule is now written in docs/92-release.md and enforced in tooling (#102). The v0.25.0 release is a draft until the maintainer publishes it; the fix covers x64 hosts (the aarch64 image keeps the old behaviour: see the 0.25.0 changelog). I will close this once the release is published.

  3. Sunrisepeak commented on Nov 26, 2026

    @Sunrisepeak
    Owner

    插件已上传

  4. Sunrisepeak commented on Nov 26, 2026

    @Sunrisepeak
    Owner

    0.25.0 is published (https://github.com/Sunrisepeak/mcpp-language-server/releases/tag/v0.25.0). The fix covers x64 hosts; the aarch64 limit and the other follow-ups are tracked in #104.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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