I've been playing around with nim's compiler today, trying to see if I can compile a nim program into a 3ds executable. I figured it would be pretty easy at first, just transpiling nim -> c and then using devkitpro's compiler, but what I've tried so far hasn't worked.
I've tried setting the cpu option in the nim compiler to ARM, which is what the 3ds uses, and then compiling the files left in nimcache with devkitpro's compiler, but this clearly isn't the right way to go about it, because it doesn't work, and it also feels...too simple? It doesn't feel like the right way to handle this, but I'm not sure.
I'm not very familiar with how nim's compiler works, which is likely causing a lot of my confusion, but also based on what I've looked up so far, it doesn't seem like anyone's attempted to do this yet.
So, a couple of questions:
Is this even possible in the first place? I feel like it would be, but I don't know enough about how either works to know.
Also, when transpiling nim code to c, it puts all the source files in the nimcache folder-- but I'm confused on what most of these files are. I'm not sure what all of the files with a bunch of "@ m..@ s...@ s.. " (and so on) do. Are they all part of the program? Do they all need to be compiled?
And then...how would this actually work? I'm not even sure what the process for this would be, if it really is just transpiling nim to c and then compiling that, or if there's something different I might need to do.
I could handle wrapping any of the libraries I need, I just don't know how to actually compile anything. Sorry if any of this is completely wrong-- I started poking into all this today and I am just very very confused if this is a reasonable path of exploration or not, and how to go about that. I might be fundamentally misunderstanding how either the nim compiler or the devkitpro compiler works, but I don't have much in-depth experience with either, just trying to learn new things and I thought that this would be a fun little project to do.
If you give me an error message I can help you more.
It should be possible, someone has at least got Nim running on the GBA before.
Not sure how you're compiling the C artifacts that Nim produces, but I believe this is your issue. The easiest is to set up Nim to use the C compiler of your choice, this way a simple nim c will not only compile all the Nim files, but also invoke the C compiler with all the right paths and flags to compile the final binary.
Maybe you can draw some inspiration from Natu or other projects compiling with a different C compiler and get something working. But without more details about the troubles you're facing it is indeed hard to point you in the right direction.
To throw my hat into the ring, the best place to start is to probably to also look at Nim's Nintendo Switch target.
Not only does it use the related devkitA64 (as opposed to devkitARM) toolchain, but also due to the provided system library (almost the same newlib provided by devkitpro in both cases) and OS (earlier version of Horizon).
https://nim-lang.org/docs/nimc.html#crossminuscompilation-for-nintendo-switch