I have printf-debugged. The problem is related to OS_NT being now a macro in Msys2's toolchain. Thus, when Emacs is compiled, OS_NT = OS_9X = 1 !!! See this patch that was submitted to my repo https://github.com/juanjosegarciaripoll/emacs-build/blob/757284e60e13da8341e181b86cda4a7c0d5d079c/patches/0001-Using-other-enum-than-OS_NT-which-is-a-define-in-Win.patch

El dom., 16 may. 2021 21:14, Eli Zaretskii <eliz@gnu.org> escribió:
> From: Juan José García-Ripoll
>  <juanjose.garciaripoll@gmail.com>
> Date: Sun, 16 May 2021 20:38:41 +0200
>
> Hi,
>
> I am trying to build emacs using my own script
> (https://github.com/juanjosegarciaripoll/emacs-build) for cloning the
> official repo, downloading MSYS2 and building from scratch.
>
> This which worked in the past but with a recent MSYS2 distribution,
> Emacs does not seem to build. When it launches 'temacs' it aborts with
> an error window that complains about UNICOWS.DLL not being available in
> the system (which it is not).

This means Emacs thinks you are on Windows 9X.  When did you last
updated from Git, and which branch of the repository are you building?