

The architecture of the invoking process is not necessarily the native machine architecture, so you can’t assume that a compiler on an ARM Mac will default to arm64 output. If you don’t supply an -arch option, then it targets the same architecture as the process that invoked cc.

With this, cc -arch x86_64 targets x86_64, cc -arch arm64 targets arm64, and cc -arch x86_64 -arch arm64 creates a fat binary containing both architectures. Perhaps the clearest way to tell it which architecture to emit is to use the -arch flag.
BUILD BINARY FOR WINDOWS ON MAC CODE
The C compiler is a universal binary containing both arm64 and x86_64 “slices”, and it seems to be capable of emitting either arm64 or x86_64 code regardless of which slice of its own binary you invoke. How does the compiler decide which architecture(s) to emit? Then the answer is to run the build twice with separate output files and glue the resulting binaries together using the lipo tool which exists for the purpose. Some tools (such as the C compiler) can emit universal binaries directly when more than one architecture is requested, but this often isn’t good enough: perhaps it doesn’t fit in with the build system, or the architectures need different compiler flags or libraries. They were used in the earlier architecture transitions as well. Universal binariesĪ universal binary is one that contains builds for more than one processor architecture in separate “slices”. Elsewhere they may also be referred to as “amd64” for Intel, or “aarch64” for ARM. To refer to machine architectures here I will use “x86_64” for 64-bit Intel and “arm64” for 64-bit ARM, since these are the terms the Apple tools use.

I’m using an ARM Mac – M1 or Apple Silicon – with macOS 11 “Big Sur”, the application is in C++ using Qt, and everything is kicked off from the command line (I don’t use Xcode). See also my earlier notes about notarization. I might add to this if other things come up. A handful of notes I made while building and packaging the new Intel/ARM universal binary of Rubber Band Audio for Mac.
