The kernel architecture is the kernel’s “preferred” architecture; it’s the architecture given by
uname -m and
arch (which are equivalent). For example, on a 64-bit kernel running on a 64-bit x86-compatible CPU, that will be
On some platforms, the kernel can run binaries for multiple architectures; for example, a 64-bit x86 kernel can also run 32-bit binaries (with two ABIs, the “old”
i686 ABI, and
x32). It supports this by instructing the CPU to run in 32-bit mode when running such binaries, and providing translation between 32-bit system calls and its native 64-bit system calls. With the addition of user-land emulation via QEMU, the kernel can also run binaries for any architecture supported by QEMU: for example,
armhf on a 64-bit Intel CPU. In addition to the binaries themselves, and whatever translation layer is necessary, you’ll also need the appropriate libraries, in the same architecture as the binary; this is what multi-arch helps with, and before multi-arch, the
/lib64 division of labour. (And if you think dealing with two or three ABIs is a lot, take a look at MIPS systems...)
In this context, “operating system architecture” could mean a number of things: it could be the architecture used when installing the system, or the architecture used by the majority of binaries in the system, etc. On Debian derivatives, it’s the architecture of the installed
dpkg package, as given by
When you’re building a binary, the easiest architecture to target is your compiler’s default target architecture, assuming you’ve got the appropriate libraries too. Usually, this will be the operating system architecture, whatever that means. The kernel architecture isn’t particularly significant here. On Debian derivatives, the expansion of multi-arch to cover cross-compilation means that it’s getting easier to build binaries for any supported Debian architecture, on any Debian system; but that’s a fairly specific use-case and still requires a reasonable level of familiarity with cross-compilation constraints. So stick with the default architecture...
uname -i prints a variant of the kernel architecture, when it prints anything; uname -p -i are unknown will tell you more about that.