Hi,
I have installed Nim v1.4.2 installed via choosenim on an x64 Windows box, and allowed it to install the default MinGW64 toolchain. It works fine until I try to cross-compile an executable to Windows 32-bit. I'm aware MinGW is rather fiddly when it comes to cross-compiling to x86 targets, however as far as I'm aware, the x64 MinGW toolchain should support compiling to an x86 executable (provided DWARF or SEH isn't used). When trying to compile, I get errors as follows:
PS> nim c --cpu:i386 test.nim
Hint: used config file '<...>\.choosenim\toolchains\nim-1.4.2\config\nim.cfg' [Conf]
Hint: used config file '<...>\.choosenim\toolchains\nim-1.4.2\config\config.nims' [Conf]
....CC: stdlib_io.nim
CC: stdlib_system.nim
CC: test.nim
In file included from <...>\nimcache\test_d\stdlib_io.nim.c:11:
<...>\.choosenim\toolchains\nim-1.4.2\lib/nimbase.h:271:35: error: static assertion failed: ""
#define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
^~~~~~~~~~~~~~
<...>\.choosenim\toolchains\nim-1.4.2\lib/nimbase.h:542:1: note: in expansion of macro 'NIM_STATIC_ASSERT'
NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "");
^~~~~~~~~~~~~~~~~
In file included from In file included from <...>\nimcache\test_d\@mtest.nim.c:11:
<...>\nimcache\test_d\stdlib_system.nim.c:11:
<...>\.choosenim\toolchains\nim-1.4.2\lib/nimbase.h:271:35:<...>\.choosenim\toolchains\nim-1.4.2\lib/nimbase.h:271:35: error: error: static assertion failed: ""
#define NIM_STATIC_ASSERT(x, msg) static assertion failed: ""
#define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
_Static_assert((x), msg)
^~~~~~~~~~~~~~^~~~~~~~~~~~~~
<...>\.choosenim\toolchains\nim-1.4.2\lib/nimbase.h:542:1:<...>\.choosenim\toolchains\nim-1.4.2\lib/nimbase.h:542:1: note: note: in expansion of macro 'in expansion of macro ' NIM_STATIC_ASSERT'
'
NIM_STATIC_ASSERT (sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "");
(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "");
^~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
Error: execution of an external compiler program 'gcc.exe -c -w -fmax-errors=3 -mno-ms-bitfields -I<...>\.choosenim\toolchains\nim-1.4.2\lib -I<...>\test -o <...>\nimcache\test_d\@mtest.nim.c.o <...>\nimcache\test_d\@mtest.nim.c' failed with exit code: 1
Supplying the --passC:-m32 --passL:-m32 flags produces a series of errors such as "skipping incompatible <lib_path> when searching for -lmingw32", which would seem to indicate that, although it is looking in the x86..._mingw32 directory, it isn't being linked against the 32-bit versions of libraries.
In any case, near as I can tell, the mingw installation installed by choosenim does not support compiling x86 binaries. Would enabling cross-compilation to x86 require a custom mingw install? What would need to be changed/chosen during installation to enable this, short of ensuring that the SJLJ exception implementation is used?