https://bugs.openldap.org/show_bug.cgi?id=8383
--- Comment #4 from Ryan Tandy ryan@openldap.org --- Thanks Quanah for spending some time on this with me. I note this bug occurs under MSYS2 when running the "MSYS2 MinGW 64-bit" environment (MSYSTEM=MINGW64). It does not occur under the "MSYS2 MSYS" environment (MSYSTEM=MSYS).
Quanah's build system seems a bit unique (MSYSTEM=MSYS but adding /mingw64/bin to PATH, possibly other differences too). I think my patch is a correct fix for people wanting to build under a pure MinGW environment.