Skip to content

migrate: declaration and macro system-header filters diverge on Windows #1109

Closed

Description

@ehartford

Windows migration enters SDK inline bodies because declaration and macro origin filters use different path classifiers. Found while validating #1102 / #1107: both Windows lanes fail behav_migrate_macro_origins and behav_migrate_private_token_paste during migration, before their assertions.

Windows x86 run 34415160251 captures untranslatable UCRT formatters followed by unsupported filtered system variable '__stdio_common_vfwprintf' from Windows Kits/.../ucrt/corecrt_wstdio.h. The ARM run 34415160198 reports the same two failed tests.

A local minimal reproduction is a header under Windows Kits/ucrt/mock.h containing:

extern int __sdk_private;
static inline int sdk_helper(void) { return __sdk_private; }

A project C file includes that header and defines int value(void) { return 7; }. Migration fails by entering sdk_helper and rejecting __sdk_private, even though the project does not call that helper.

LLDB observed ci_is_system_path return w0=0 for out/windows-origin/Windows Kits/ucrt/mock.h:3:19 to ci_migrate_decl_is_filtered+80 (PC 0x100776d24). The tbz takes the unfiltered branch at +92. Log: /tmp/with-macro-windows-origin-lldb.txt.

Root cause: src/CImport.w:ci_is_system_path recognizes only Unix/Apple paths, while ClangBridge.w:cimport_location_path_is_system already recognizes Windows Kits and MSVC. The latter also lacks backslash spellings for generic SDK paths.

The follow-up shares the bridge classifier with declaration filtering, covers both separator spellings, and adds a regression that retains project macros/code while skipping private SDK declarations. It does not suppress migration failures or weaken the existing macro tests.

Activity

  1. added a commit that references this issue on Sep 10, 2026
    88eaa3f
  2. joshhickson commented on Sep 15, 2026

    @joshhickson
    Contributor

    Reporting a repro that still fails, with the caveat up front: I cannot test against main, only against published binaries, and every published binary predates this fix. So this may well already be closed correctly — posting in case the case below is not covered, and because it currently affects anyone installing With on Windows.

    The repro

    A 13-line C file with zero #include directives:

    typedef struct { int weight_cg; int category; } Box;
    
    int mean_cg(const Box *boxes, int n) {
        long long total = 0;
        for (int i = 0; i < n; i++) total += boxes[i].weight_cg;
        return n > 0 ? (int)(total / n) : 0;
    }
    
    int is_outlier(int value, int mean, int tolerance) {
        int d = value - mean;
        if (d < 0) d = -d;
        return d > tolerance ? 1 : 0;
    }
    with migrate bare.c
    exit code: 1
    untranslatable functions: 140
    output produced: none
    

    All 140 come from the Windows SDK, none from the input:

    migrate: untranslatable function '_vfwprintf_l': bailed at ReturnStmt at
      C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_wstdio.h:309:9
    migrate: untranslatable function 'fwprintf': bailed at kind=111 at
      ...\ucrt\corecrt_wstdio.h:504:9
    migrate: untranslatable function 'sscanf': bailed at kind=111 at
      ...\ucrt\stdio.h:2250:9
    migrate: unsupported filtered system variable '__stdio_common_vfwprintf' from
      ...\ucrt\corecrt_wstdio.h:272:26; add an explicit binding or extend std.libc
    

    Two failure modes, bailed at ReturnStmt and bailed at kind=111, concentrated in corecrt_wstdio.h and ucrt\stdio.h. A variant of the same file with #include <stdint.h> fails identically, so the input's own includes make no difference to the outcome.

    Paths here are the ordinary all-backslash spelling under C:\Program Files (x86)\Windows Kits\10\Include\..., not the mixed-separator spelling that docs/migrate-windows-header-origin-debug.md describes — so if this case is already handled, please disregard.

    Why I cannot check it against the fix

    The newest published artifact of any kind is nightly-20260907-34132069721-1-8a729db8d01f (2026-09-07). This issue closed 2026-09-12, so no released or nightly binary contains the fix:

    Published Tag windows-x86_64.exe
    2026-09-07 nightly-20260907-… yes
    2026-09-06 v0.15.2.1 (latest release) yes
    2026-09-04 v0.15.1.8 yes

    Nightlies also appear to have paused after 2026-09-07, while main kept committing through 2026-09-12.

    Building from source on Windows to test main directly runs into #1145 — no Windows LLVM SDK is published in tagged releases — so I have not been able to get past that yet.

    What would help

    Either confirmation that the case above is covered by the fix, or a published Windows build containing it, and I will retest and report back. Testing on Windows is the thing I can most usefully do here: Win 10 and Win 11, Intel + Nvidia, happy to run diagnostic builds.

    Environment

    With v0.15.2.1 (with-windows-x86_64.exe, sha256 8f4817f2c4a3a916515ec93fd8a8f228bc9cfcd423689c5977dc564efc02a115, matching the seed.lock pin)
    Host Windows 11 Home 10.0.26200, x86_64
    Windows SDK 10.0.26100.0
    LLVM with-llvm-sdk-22.1.6-windows-x86_64 from the 2026-09-07 nightly, LLVM_PREFIX set
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