Building libunistring, which includes some Gnulib tests, with 32-bit MSVC
in a 64-bit Cygwin or MSYS2 environment, I get this build error:

test-localcharset-windows-utf8.res : fatal error LNK1112: module machine type 
'x64' conflicts with target machine type 'x86'

The cause is that the Makefile rule uses $(WINDRES), which under 64-bit Cygwin
or MSYS2 is 'windres', which produces 64-bit object files. But we need a
32-bit object file for this kind of build.

This patch fixes it.


2026-10-16  Bruno Haible  <[email protected]>

        tests: Fix build with 32-bit MSVC in 64-bit Cygwin/MSYS2 environment.
        * modules/localcharset-tests (Makefile.am): For building the .res file
        with MSVC, use 'rc' and 'cvtres' instead of $(WINDRES).
        * modules/localename-tests (Makefile.am): Likewise.
        * modules/mbrtowc-tests (Makefile.am): Likewise.
        * modules/nstrftime-tests (Makefile.am): Likewise.
        * modules/setlocale-tests (Makefile.am): Likewise.

diff --git a/modules/localcharset-tests b/modules/localcharset-tests
index cd661a4c31..511fb86c7b 100644
--- a/modules/localcharset-tests
+++ b/modules/localcharset-tests
@@ -23,6 +23,13 @@ TESTS += test-localcharset-w32utf8.sh
 noinst_PROGRAMS += test-localcharset-w32utf8
 test_localcharset_w32utf8_LDADD = $(LDADD) test-localcharset-windows-utf8.res 
$(SETLOCALE_LIB)
 test-localcharset-windows-utf8.res : $(srcdir)/windows-utf8.rc
-       $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-localcharset-windows-utf8.res --output-format=coff
+       if test '@OBJEXT@' = obj; then \
+         rcfile=`cygpath -w '$(srcdir)/windows-utf8.rc'`; \
+         rc -fotest-localcharset-windows-utf8.tmp.res "$$rcfile" \
+         && cvtres -out:test-localcharset-windows-utf8.res 
test-localcharset-windows-utf8.tmp.res \
+         && rm -f test-localcharset-windows-utf8.tmp.res; \
+       else \
+         $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-localcharset-windows-utf8.res --output-format=coff; \
+       fi
 MOSTLYCLEANFILES += test-localcharset-windows-utf8.res
 endif
diff --git a/modules/localename-tests b/modules/localename-tests
index b42ef1b7de..57ac9f796b 100644
--- a/modules/localename-tests
+++ b/modules/localename-tests
@@ -33,6 +33,13 @@ TESTS += test-localename-w32utf8.sh
 noinst_PROGRAMS += test-localename-w32utf8
 test_localename_w32utf8_LDADD = $(LDADD) test-localename-windows-utf8.res 
$(SETLOCALE_LIB)
 test-localename-windows-utf8.res : $(srcdir)/windows-utf8.rc
-       $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-localename-windows-utf8.res --output-format=coff
+       if test '@OBJEXT@' = obj; then \
+         rcfile=`cygpath -w '$(srcdir)/windows-utf8.rc'`; \
+         rc -fotest-localename-windows-utf8.tmp.res "$$rcfile" \
+         && cvtres -out:test-localename-windows-utf8.res 
test-localename-windows-utf8.tmp.res \
+         && rm -f test-localename-windows-utf8.tmp.res; \
+       else \
+         $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-localename-windows-utf8.res --output-format=coff; \
+       fi
 MOSTLYCLEANFILES += test-localename-windows-utf8.res
 endif
diff --git a/modules/mbrtowc-tests b/modules/mbrtowc-tests
index 136c940e7b..5110d47d49 100644
--- a/modules/mbrtowc-tests
+++ b/modules/mbrtowc-tests
@@ -63,6 +63,13 @@ TESTS += test-mbrtowc-w32utf8.sh
 noinst_PROGRAMS += test-mbrtowc-w32utf8
 test_mbrtowc_w32utf8_LDADD = $(LDADD) test-mbrtowc-windows-utf8.res 
$(SETLOCALE_LIB)
 test-mbrtowc-windows-utf8.res : $(srcdir)/windows-utf8.rc
-       $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-mbrtowc-windows-utf8.res --output-format=coff
+       if test '@OBJEXT@' = obj; then \
+         rcfile=`cygpath -w '$(srcdir)/windows-utf8.rc'`; \
+         rc -fotest-mbrtowc-windows-utf8.tmp.res "$$rcfile" \
+         && cvtres -out:test-mbrtowc-windows-utf8.res 
test-mbrtowc-windows-utf8.tmp.res \
+         && rm -f test-mbrtowc-windows-utf8.tmp.res; \
+       else \
+         $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-mbrtowc-windows-utf8.res --output-format=coff; \
+       fi
 MOSTLYCLEANFILES += test-mbrtowc-windows-utf8.res
 endif
diff --git a/modules/nstrftime-tests b/modules/nstrftime-tests
index 2b799868e9..68c9aae1f8 100644
--- a/modules/nstrftime-tests
+++ b/modules/nstrftime-tests
@@ -62,6 +62,13 @@ TESTS += test-nstrftime-w32utf8.sh
 noinst_PROGRAMS += test-nstrftime-w32utf8
 test_nstrftime_w32utf8_LDADD = $(LDADD) test-nstrftime-windows-utf8.res 
$(SETLOCALE_LIB) $(LIBTHREAD)
 test-nstrftime-windows-utf8.res : $(srcdir)/windows-utf8.rc
-       $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-nstrftime-windows-utf8.res --output-format=coff
+       if test '@OBJEXT@' = obj; then \
+         rcfile=`cygpath -w '$(srcdir)/windows-utf8.rc'`; \
+         rc -fotest-nstrftime-windows-utf8.tmp.res "$$rcfile" \
+         && cvtres -out:test-nstrftime-windows-utf8.res 
test-nstrftime-windows-utf8.tmp.res \
+         && rm -f test-nstrftime-windows-utf8.tmp.res; \
+       else \
+         $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-nstrftime-windows-utf8.res --output-format=coff; \
+       fi
 MOSTLYCLEANFILES += test-nstrftime-windows-utf8.res
 endif
diff --git a/modules/setlocale-tests b/modules/setlocale-tests
index 3d8e22452b..8c40dc8111 100644
--- a/modules/setlocale-tests
+++ b/modules/setlocale-tests
@@ -46,6 +46,13 @@ TESTS += test-setlocale-w32utf8.sh
 noinst_PROGRAMS += test-setlocale-w32utf8
 test_setlocale_w32utf8_LDADD = $(LDADD) test-setlocale-windows-utf8.res 
$(SETLOCALE_LIB)
 test-setlocale-windows-utf8.res : $(srcdir)/windows-utf8.rc
-       $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-setlocale-windows-utf8.res --output-format=coff
+       if test '@OBJEXT@' = obj; then \
+         rcfile=`cygpath -w '$(srcdir)/windows-utf8.rc'`; \
+         rc -fotest-setlocale-windows-utf8.tmp.res "$$rcfile" \
+         && cvtres -out:test-setlocale-windows-utf8.res 
test-setlocale-windows-utf8.tmp.res \
+         && rm -f test-setlocale-windows-utf8.tmp.res; \
+       else \
+         $(WINDRES) -i $(srcdir)/windows-utf8.rc -o 
test-setlocale-windows-utf8.res --output-format=coff; \
+       fi
 MOSTLYCLEANFILES += test-setlocale-windows-utf8.res
 endif




Reply via email to