Skip to content

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

Merged
larsewi merged 1 commit intoNorthernTechHQ:masterfrom
larsewi:master
Mar 10, 2026
Merged

ENT-13766: Fix MinGW cross-compilation: ws2_32 linkage and snprintf C99 detection#265
larsewi merged 1 commit intoNorthernTechHQ: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>
@mender-test-bot
Copy link

There was an error running your pipeline, see logs for details.

@larsewi larsewi merged commit 6e319ed into NorthernTechHQ:master Mar 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants