The other day I came across an Issure regarding Aporia failing to install via nimble on x64 machines (due to lack of x64 dependencies for Windows). This made me think: is it possible to have on the same machine Nim 32 and 64 bits?
I thought that the compiling bitness was handled by GCC, ie: that you could compile both 32 and 64 bit binaries by choosing the architecture options to pass to GCC. But the above Aporia issue made me think that there are no such options when it comes to Nimble.
So, is it possible to build both 32 and 64 bits binaries with Nim? Does is it require a dual Nim installation? And how can one handle that? I'm thinking of the ~\.nimble\ folder, and how having both 32 and 64bit versions relying on the same packages folder might cause conflicts.
Side note: I haven't put my hands on Nim for quite a long time: since v0.17.0 came out. I started out with quite some entusiasm with v0.15 (bought the book Nim In Action and wanted to have a go at it), but then since v0.17 the installers weren't provided any longer, and had experienced trouble setting it up, so I gave up. This week I've decided to give it another try, and am facing again problems with the setup on Win 10 x64 (yes, I've followed all the instructions, installed all the files from the Windows download page, including MinGW, and did run finish.exe: Nim does compile, but if I run the tests they fail).
Therefore, the question above is from a year-old newby, still struggling to get Nim up and running.
on linux, if I try to compile with -passC:"-m32" it breaks with
Error: execution of an external compiler program 'gcc -c -w -m32 -I/usr/lib/nim -o /tmp/nimcache/hello.o /tmp/nimcache/hello.c' failed with exit code: 1
In file included from /tmp/nimcache/hello.c:10:0:
/usr/lib/nim/nimbase.h:482:13: error: size of array ‘Nim_and_C_compiler_disagree_on_target_architecture’ is negative
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
then I guess multilib it's not supportedthen I guess multilib it's not supported
That's bad news!
In theory, on Windows one could avoid adding Nim's bin folder to the PATH, and have different batch scripts to add it to the PATH for the current CMD env at usage time, this would allow to chose between Nim 32- and 64-bit. But the problem would remain for the ~\.nimble\ folder though!
If there is a way to configure each Nim setup to have Nimble handle packages in custom folders, then maybe dual setup would be possible.
I haven't found any references in Nim documentation regarding this; I would though it was a crucial question — If one wishes to publish a DLL for both x86 and x86-64 how is he going to do it?
Maybe it's just me that I'm missing out something.
Multilib IS supported
thanks! So I did remember right (it's been really long I haven't used Nim, so I forgot most of what I learned).
Basically, having Nim/MinGW x64 is the best choice, and I shall be able to compile x64 (natively) and x32 with options?
But what about the Nimble example I gave above, and the fact that with Nim x64 you can't install Aporia? Isn't there a way to also tell Nimble to compile for x86? From Nimble documentation page I couldn't find any references on this.