I am posting about cross-compiling the nim source package, not nim applications.
There is a build recipe on github, but it is a couple of years old, and didn't work for me. Also, it was incomplete:
https://github.com/aguspiza/meta-nim
I fixed the recipe, and now have cross-compiled nim, koch, nimble, nimgrep and nimsuggest. My recipes are posted here:
https://bkhome.org/news/202208/nim-compiled-in-openembedded-take-2.html
So on a x86_64 host OS, you can build for any target CPU.
Note that although OpenEmbedded (OE) is mostly for cross-compiling for embedded systems, it is powerful and I maintain EasyOS Linux distribution that has nearly all of its packages compiled in OE. Awhile back, I posted an intro to how this is done:
https://easyos.org/dev/how-to-compile-a-linux-distribution-from-source.html
Anyway, I have only been using Nim for just over a week, so the hacks I did in the OE recipes might not have been the best solution. If anyone can see how the recipe can be improved, suggestions are welcome.
I also raised an issue here:
Thanks! It’s great to get a recent Nim recipe for OE.
Your Linux distro piques my interest too. It looks like it could make a good basis for building custom embedded Linux OSes without setting up OE yourself.
I’m curious are you considering Nim for use in EasyOS tooling? I’d be a big fan of that.
Also could EasyOS be setup with an A/B partition setup? Looks like you have some rollback support. For embedded devices I prefer a/b updates but they’re a pain.
Ha ha, I didn't even know what "A/B partition" is! Until now, looked it up.
As EasyOS is built from cross-compiled packages, it was easy to build aarch64 packages, and consequently I did create an EasyOS for the rpi4. Getting a bit old though.
Mostly I write ash/bash shell scripts, some utilities in C, and some in BaCon:
https://easyos.org/dev/coding-for-easyos.html
But now I'm getting interested in writing utilities in Nim.
I learning process, have improved the recipes in OpenEmbedded. I have written a utility, 'debdb2pupdb.nim', that converts a Debian package database file to Puppy Linux package format. Posted about it here:
https://bkhome.org/news/202208/debdb2pupdbnim-cross-compiled-in-oe.html
One thing that had me stumped for awhile, is that "--cc:env" will cause nim to use the $CC variable -- however, in OpenEmbedded, $CC is not just the name of the cross-compiler, it also has parameters. I split it into two different variables, and got it to work.
Another issue was "--opt:" did not work as expected, and I ended up with "--opt:none" to get the smallest binary. Trying different options, went from 122KB down to 54KB.
That smallest one was still with "--mm:orc", so could probably have got even smaller with "--mm:arc".
I have cross-compiled Nim version 1.6.8 in OpenEmbedded and also greatly refined the build recipe, having learnt a bit more since being a raw beginner a couple of weeks ago.
I have posted the OE build recipes here:
https://bkhome.org/news/202209/nim-168-compiled-in-oe-with-simplified-recipe.html