Skip to content

windows: fix if_nametoindex() detection with autotools, improve with cmake#17982

Closed
vszakats wants to merge 11 commits intocurl:masterfrom
vszakats:xp
Closed

windows: fix if_nametoindex() detection with autotools, improve with cmake#17982
vszakats wants to merge 11 commits intocurl:masterfrom
vszakats:xp

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jul 20, 2025

  • autotools: fix auto-detection on the Windows platform.
    It was mis-detected when targeting Windows XP/2003 64-bit.
    It was permanently undetected when building for Windows 32-bit.

    lib/url.c: In function 'zonefrom_url':
    lib/url.c:1802:18: error: implicit declaration of function 'if_nametoindex' [-Wimplicit-function-declaration]
     1802 |       scopeidx = if_nametoindex(zoneid);
          |                  ^~~~~~~~~~~~~~
    lib/url.c:1802:18: error: nested extern declaration of 'if_nametoindex' [-Werror=nested-externs]
    

    Ref: https://github.com/curl/curl/actions/runs/16405598782/job/46351023138?pr=17982#step:10:29

    Reported-by: LoRd_MuldeR
    Fixes cURL 8.15.0 fails to build for 64-Bit Windows XP target (mingw-w64), but not for 32-Bit Windows target #17979

    Without this patch the workaround for the 8.15.0 release is:
    export ac_cv_func_if_nametoindex=0 for Windows XP/2003 64-bit.

    Background: Checking for the if_nametoindex() function via
    AC_CHECK_FUNCS() (autotools) or check_function_exists() (cmake) do
    not work on Windows, for two reasons:

    • the function may be disabled at compile-time in Windows headers
      when targeting old Windows versions (XP or WS2003 in curl context)
      via _WIN32_WINNT. But it's always present in the system implib
      iphlpapi where these checks are looking.
    • for 32-bit Windows the function signature in the implib requires
      a 4-byte argument, while these checks always use no arguments,
      making them always fail.
  • cmake: call if_nametoindex dynamically with mingw-w64 v1.0.
    This mingw-w64 version lacks prototype and implib entry for it.

  • cmake: add auto-detection for Windows and use as a fallback for
    non-pre-fill cases.

  • cmake: disable pre-fill with _CURL_PREFILL=OFF. (for testing)

  • cmake: disable pre-fill for untested compilers. (i.e. non-MSVC,
    non-mingw64)

  • GHA/windows: make an autotools job build for Windows XP.

Follow-up to 0d71b18 #17413

@vszakats vszakats added build Windows Windows-specific labels Jul 20, 2025
@vszakats vszakats marked this pull request as draft July 20, 2025 23:58
@github-actions github-actions bot added the CI Continuous Integration label Jul 20, 2025
@vszakats vszakats changed the title GHA/windows: make an autotools job build for XP windows: fix if_nametoindex() detection with autotools, improve with cmake Jul 21, 2025
@vszakats vszakats closed this in a751105 Jul 21, 2025
@vszakats vszakats deleted the xp branch July 21, 2025 11:30
whrvt added a commit to neomodnet/neomod that referenced this pull request Jul 22, 2025
maybe these are related?
curl/curl#17728
curl/curl#17982
curl/curl#17979

idk what the downsides of this are though
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build CI Continuous Integration Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

cURL 8.15.0 fails to build for 64-Bit Windows XP target (mingw-w64), but not for 32-Bit Windows target

1 participant