I have not looked very closely at this, but I see it uses a cross compiler, “aarch64-linux-gnu-gcc”. I wonder if it just couldn’t find this command (you might set your build script to explicitly give the full path of aarch64-linux-gnu-gcc), but more likely it produced or consumed code which differs across architectures. An example would be that if the code being compiled uses SSE instructions from an amd64 machine, then trying to compile on aarch64 would fail with an illegal instruction since aarch64 doesn’t have SSE. Or vice-versa, e.g., a thumb2 instruction exists on aarch64, but not on amd64.
If it is a case of not finding the compiler, then that’s easy to fix. If it is a case of using a bad mix of specialty code (e.g., SSE or thumb2) across architectures, then you’d have to find a way to cut out that specialty code (or find a compatibility option).