So, that's the case.
Basically, the main use scenario is having a Github workflow compile binaries for the M1.
(I'm mainly using a Mac, and as a matter of fact I also have an M1-powered one around, but I would totally love it if I was able to automate the whole process. And given that GitHub's runners for macOS are non-M1 powered - at least for now, AFAIK - that would be the only solution)
Any ideas? Anybody that has actually tried it?
In NimForUE we compile one of the dynlibs for x86 and ARM and then we unify it with lipo. Didnt test it from x86 but it works fine from a M1. Here is the code in case you want to take a look:
I don't use Mac but I've successfully done it for fedora/arm64. At least I think so.
Basically you'll need to cross-compile the compiler (from Nim) into C sources (by specifying the --os and --cpu options), then move the generated C files to the target machine, using a C compiler installed there to do the remaining tasks. Commands for C compiler and linker can be found in a json file generated during the cross-compilation. The config files are also needed (probably with some of them written).
Nimble has to be cross-compiled, either. Because it requires the compiler package which needs nimble to install.
https://github.com/mratsim/constantine/blob/915f89f/constantine.nimble#L441-L445
compile "lib" & bindingsName & ".dylib.arm", "--cpu:arm64 -l:'-target arm64-apple-macos11' -t:'-target arm64-apple-macos11'"
compile "lib" & bindingsName & ".dylib.x64", "--cpu:amd64 -l:'-target x86_64-apple-macos10.12' -t:'-target x86_64-apple-macos10.12'"
exec "lipo bindings/generated/lib" & bindingsName & ".dylib.arm " &
" bindings/generated/lib" & bindingsName & ".dylib.x64 " &
" -output bindings/generated/lib" & bindingsName & ".dylib -create"