Skip to content

ENT-13766: Fix MinGW cross-compilation: ws2_32 linkage and snprintf C99 detection#6053

Open
larsewi wants to merge 1 commit intocfengine:masterfrom
larsewi:master
Open

ENT-13766: Fix MinGW cross-compilation: ws2_32 linkage and snprintf C99 detection#6053
larsewi wants to merge 1 commit intocfengine:masterfrom
larsewi:master

Conversation

@larsewi
Copy link
Contributor

@larsewi larsewi commented Mar 9, 2026

When cross-compiling for MinGW with GCC 13 / mingw-w64 v11:

  1. AC_SEARCH_LIBS(setsockopt, socket) didn't find setsockopt because on
    MinGW it lives in ws2_32, not socket. This caused AC_REPLACE_FUNCS to
    compile replacement inet_ntop/inet_pton that conflict with the
    MinGW-w64 declarations (socklen_t vs size_t parameter types).
    Fix: search [socket ws2_32] so -lws2_32 is in LIBS.

  2. HW_FUNC_VSNPRINTF/HW_FUNC_SNPRINTF use AC_RUN_IFELSE to test C99
    compliance, which can't execute when cross-compiling, defaulting to
    "no". This caused #define vfprintf rpl_vfprintf etc., which conflicts
    with mingw-w64 v11 inline stdio functions.
    Fix: default to C99-compliant for mingw* targets in cross-compile.

Ticket: ENT-13766
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

When cross-compiling for MinGW with GCC 13 / mingw-w64 v11:

1. AC_SEARCH_LIBS(setsockopt, socket) didn't find setsockopt because on
   MinGW it lives in ws2_32, not socket. This caused AC_REPLACE_FUNCS to
   compile replacement inet_ntop/inet_pton that conflict with the
   MinGW-w64 declarations (socklen_t vs size_t parameter types).
   Fix: search [socket ws2_32] so -lws2_32 is in LIBS.

2. HW_FUNC_VSNPRINTF/HW_FUNC_SNPRINTF use AC_RUN_IFELSE to test C99
   compliance, which can't execute when cross-compiling, defaulting to
   "no". This caused #define vfprintf rpl_vfprintf etc., which conflicts
   with mingw-w64 v11 inline stdio functions.
   Fix: default to C99-compliant for mingw* targets in cross-compile.

Ticket: ENT-13766
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant