Cross compilation - RPi 1B target

I am trying to cross compile some Nim code in Linux / x64 in order to make it work in a Rpi 1 B. I managed to compile it, but the binary is not working: Illegal instruction (core dumped).

The command line I am using is:

nim c --cpu:arm --os:linux --cc:clang --os:linux  --clang.exe="zigcc" --clang.linkerexe="zigcc" --passC:"-target arm-linux-musleabi -mtune=arm1176jzf_s" --passL:"-target arm-linux-musleabi" alarma.nim

Do you think I am using the right flags (on the zig side)? Or maybe I am hit by some of these issues?

Just to rule it out, try passing -fno-sanitize=undefined via --passC. It’s possible you’re hitting undefined behavior caught by the undefined behavior sanitizer that’s enabled by default.

Thanks squeek, but it is not working either.

Now I think you were right but I just added -mcpu. The following worked:

nim c --cpu:arm --os:linux --cc:clang --os:linux  --clang.exe="zigcc" --clang.linkerexe="zigcc" --passC:"-target arm-linux-musleabi -mcpu=arm1176jzf_s -fno-sanitize=undefined" --passL:"-target arm-linux-musleabi -mcpu=arm1176jzf_s" alarma.nim