ARCH(7)
โจ arch(7) โ Architecture-specific details โจ
okay so this is arch(7) from the Miscellaneous Information Manual, and it's literally your cheat sheet for the differences between CPU architectures and platforms supported by FreeBSD. ๐ซถ
๐ DESCRIPTION ๐
Differences between CPU architectures and platforms supported by FreeBSD. Slay, that's the whole vibe. ๐ฆ
๐ธ Introduction ๐ธ
This document is a quick reference of key ABI details of FreeBSD architecture ports. For full details consult the processor-specific ABI supplement documentation. iykyk, this is the short version. โจ
If not explicitly mentioned, sizes are in bytes. The architecture details in this document apply to FreeBSD 13.0 and later, unless otherwise noted.
FreeBSD uses a flat address space. Variables of types unsigned long, uintptr_t, and size_t and pointers all have the same representation.
In order to maximize compatibility with future pointer integrity mechanisms, manipulations of pointers as integers should be performed via uintptr_t or intptr_t and no other types. In particular, long and ptrdiff_t should be avoided. bestie, do not do pointer-integer gymnastics with long or ptrdiff_t, okay? ๐ญ
On some architectures, e.g., AIM variants of powerpc64, the kernel uses a separate address space. On other architectures, kernel and a user mode process share a single address space. The kernel is located at the highest addresses.
On each architecture, the main user mode thread's stack starts near the highest user address and grows down.
FreeBSD architecture support varies by release. This table shows currently supported CPU architectures along with the first FreeBSD release to support each architecture.
aarch64โ initial release:11.0amd64โ initial release:5.1armv7โ initial release:12.0powerpc64โ initial release:9.0powerpc64leโ initial release:13.0riscv64โ initial release:12.0
Discontinued architectures are shown in the following table. rip to these icons, fr fr. ๐ฏ๏ธ
alphaโ initial release:3.2; final release:6.4armโ initial release:6.0; final release:12.4armebโ initial release:8.0; final release:11.4armv6โ initial release:10.0; final release:14.xia64โ initial release:5.0; final release:10.4i386โ initial release:1.0; final release:14.xmipsโ initial release:8.0; final release:13.5mipselโ initial release:9.0; final release:13.5mipselhfโ initial release:12.0; final release:13.5mipshfโ initial release:12.0; final release:13.5mipsn32โ initial release:9.0; final release:13.5mips64โ initial release:9.0; final release:13.5mips64elโ initial release:9.0; final release:13.5mips64elhfโ initial release:12.0; final release:13.5mips64hfโ initial release:12.0; final release:13.5pc98โ initial release:2.2; final release:11.4powerpcโ initial release:6.0; final release:14.xpowerpcspeโ initial release:12.0; final release:14.xriscv64sfโ initial release:12.0; final release:13.5sparc64โ initial release:5.0; final release:12.4
๐งฎ Type sizes ๐งฎ
All FreeBSD architectures use some variant of the ELF (see elf(5)) Application Binary Interface (ABI) for the machine processor. All supported ABIs can be divided into two groups:
ILP32โint,long,void *types machine representations all have 4-byte size.LP64โinttype machine representation uses 4 bytes, whilelongandvoid *are 8 bytes.
Some machines support more than one FreeBSD ABI. Typically these are 64-bit machines, where the โnativeโ LP64 execution environment is accompanied by the โlegacyโ ILP32 environment, which was the historical 32-bit predecessor for 64-bit evolution. Examples are:
amd64โ ILP32 counterpart:i386powerpc64โ ILP32 counterpart:powerpcaarch64โ ILP32 counterpart:armv7
aarch64 will support execution of armv7 binaries if the CPU implements AArch32 execution state. Binaries targeting armv6 and earlier are no longer supported by FreeBSD. the old stuff is giving legacy, and not in the cute way. ๐
On all supported architectures:
shortโ size:2intโ size:4longโ size:sizeof(void*)long longโ size:8floatโ size:4doubleโ size:8
Integers are represented in two's complement. Alignment of integer and pointer types is natural, that is, the address of the variable must be congruent to zero modulo the type size. Most ILP32 ABIs, except arm, require only 4-byte alignment for 64-bit integers.
Machine-dependent type sizes:
aarch64โvoid *:8;long double:16;time_t:8amd64โvoid *:8;long double:16;time_t:8armv7โvoid *:4;long double:8;time_t:8i386โvoid *:4;long double:12;time_t:4powerpcโvoid *:4;long double:8;time_t:8powerpcspeโvoid *:4;long double:8;time_t:8powerpc64โvoid *:8;long double:8;time_t:8powerpc64leโvoid *:8;long double:8;time_t:8riscv64โvoid *:8;long double:16;time_t:8
time_t is 8 bytes on all supported architectures except i386. not the i386 catching strays again ๐ญ
๐ฆ Endianness and Char Signedness ๐ฆ
aarch64โ endianness: little;charsignedness: unsignedamd64โ endianness: little;charsignedness: signedarmv7โ endianness: little;charsignedness: unsignedi386โ endianness: little;charsignedness: signedpowerpcโ endianness: big;charsignedness: unsignedpowerpcspeโ endianness: big;charsignedness: unsignedpowerpc64โ endianness: big;charsignedness: unsignedpowerpc64leโ endianness: little;charsignedness: unsignedriscv64โ endianness: little;charsignedness: signed
๐ Page Size ๐
aarch64โ page sizes:4K, 64K, 2M, 1Gamd64โ page sizes:4K, 2M, 1Garmv7โ page sizes:4K, 1Mi386โ page sizes:4K, 2M (PAE), 4Mpowerpcโ page sizes:4Kpowerpcspeโ page sizes:4Kpowerpc64โ page sizes:4Kpowerpc64leโ page sizes:4Kriscv64โ page sizes:4K, 2M, 1G
๐บ๏ธ User Address Space Layout ๐บ๏ธ
aarch64โ maximum address:0x0001000000000000; address space size:256TiBamd64 (LA48)โ maximum address:0x0000800000000000; address space size:128TiBamd64 (LA57)โ maximum address:0x0100000000000000; address space size:64PiBarmv7โ maximum address:0xbfc00000; address space size:3GiBi386โ maximum address:0xffc00000; address space size:4GiBpowerpcโ maximum address:0xfffff000; address space size:4GiBpowerpcspeโ maximum address:0x7ffff000; address space size:2GiBpowerpc64โ maximum address:0x000fffffc0000000; address space size:4PiBpowerpc64leโ maximum address:0x000fffffc0000000; address space size:4PiBriscv64 (Sv39)โ maximum address:0x0000004000000000; address space size:256GiBriscv64 (Sv48)โ maximum address:0x0000800000000000; address space size:128TiB
The layout of a process' address space can be queried via the KERN_PROC_VM_LAYOUT sysctl(3) MIB.
Historically, amd64 CPUs were limited to a 48-bit virtual address space. Newer CPUs support 5-level page tables, which extend the significant bits of addresses to 57 bits (LA57 mode). The address space layout is determined by the CPU's support for LA57. Setting the vm.pmap.la57 tunable to 0 forces the system into 4-level paging mode, even on hardware that supports 5-level paging. In this mode, all processes get a 48-bit address space. The vm.pmap.prefer_la48_uva tunable determines whether processes running on a LA57 system are limited to a 48-bit address space by default. Some applications make use of unused upper bits in pointer values to store information, and thus implicitly assume they are running in LA48 mode. To avoid breaking compatibility, all processes run in LA48 mode by default. The elfctl(1) utility can be used to request LA48 or LA57 mode for specific executables. Similarly, proccontrol(1) can be used to configure the address space layout when executing a process. LA57 is giving new-gen main character energy, but compatibility said โnot today.โ ๐
The RISC-V specification permits 3-level (Sv39), 4-level (Sv48), and 5-level (Sv57) page tables. Hardware is only required to implement Sv39; implementations which support Sv48 must also support Sv39, and implementations which support Sv57 must also support Sv48. The vm.pmap.mode tunable can be used to select the layout. FreeBSD currently supports Sv39 and Sv48 and defaults to using Sv39.
๐ Floating Point ๐
aarch64โfloat, double: hard;long double: soft, quad precisionamd64โfloat, double: hard;long double: hard, 80 bitarmv7โfloat, double: hard;long double: hard, double precisioni386โfloat, double: hard;long double: hard, 80 bitpowerpcโfloat, double: hard;long double: hard, double precisionpowerpcspeโfloat, double: hard;long double: hard, double precisionpowerpc64โfloat, double: hard;long double: hard, double precisionpowerpc64leโfloat, double: hard;long double: hard, double precisionriscv64โfloat, double: hard;long double: hard, quad precision
๐ ๏ธ Default Tool Chain ๐ ๏ธ
FreeBSD uses clang(1) as the default compiler on all supported CPU architectures, LLVM's ld.lld(1) as the default linker, and LLVM binary utilities such as objcopy(1) and readelf(1). the toolchain is lowkey iconic and consistent, periodt. ๐
๐ MACHINE_ARCH vs MACHINE_CPUARCH vs MACHINE ๐
MACHINE_CPUARCH should be preferred in Makefiles when the generic architecture is being tested. MACHINE_ARCH should be preferred when there is something specific to a particular type of architecture where there is a choice of many, or could be a choice of many. Use MACHINE when referring to the kernel, interfaces dependent on a specific type of kernel or similar things like boot sequences. okay so they are not interchangeable, bestie โ read the room and use the right one. โจ
MACHINE=arm64โMACHINE_CPUARCH:aarch64;MACHINE_ARCH:aarch64MACHINE=amd64โMACHINE_CPUARCH:amd64;MACHINE_ARCH:amd64MACHINE=armโMACHINE_CPUARCH:arm;MACHINE_ARCH:armv7MACHINE=i386โMACHINE_CPUARCH:i386;MACHINE_ARCH:i386MACHINE=powerpcโMACHINE_CPUARCH:powerpc;MACHINE_ARCH:powerpc,powerpcspe,powerpc64,powerpc64leMACHINE=riscvโMACHINE_CPUARCH:riscv;MACHINE_ARCH:riscv64
โจ Predefined Macros โจ
The compiler provides a number of predefined macros. Some of these provide architecture-specific details and are explained below. Other macros, including those required by the language standard, are not included here.
The full set of predefined macros can be obtained with this command:
cc -x c -dM -E /dev/null
Common type size and endianness macros:
__LP64__โ 64-bit (8-byte)longand pointer, 32-bit (4-byte)int__ILP32__โ 32-bit (4-byte)int,longand pointerBYTE_ORDERโ EitherBIG_ENDIANorLITTLE_ENDIAN.PDP11_ENDIANis not used on FreeBSD.
Architecture-specific macros:
aarch64โ__aarch64__amd64โ__amd64__,__x86_64__armv7โ__arm__,__ARM_ARCH >= 7i386โ__i386__powerpcโ__powerpc__powerpcspeโ__powerpc__,__SPE__powerpc64โ__powerpc__,__powerpc64__powerpc64leโ__powerpc__,__powerpc64__riscv64โ__riscv,__riscv_xlen == 64
Compilers can also go off and define their own extra variants of architecture-specific macros โ that's allowed. But for stuff in FreeBSD, the ones above are the preferred ones, periodt. ๐
๐ ๏ธ Important make(1) variables
Most of the variables you can set from the outside are documented over in the build(7) man page. The ones below are not documented anywhere else, and the build system uses them extensively โ so like, pay attention bestie. ๐
MACHINEโ this one's the hardware platform. It's literally the same thing as the native platform'suname(1) -moutput. It defines both the userland/kernel interface and the bootloader/kernel interface, and it should only be used in those contexts. Here's the thing: each CPU architecture may support multiple hardware platforms whereMACHINEdiffers between them. It's used to collect together all the files fromconfig(8)to build the kernel. It's often the same asMACHINE_ARCH, because just like one CPU architecture can be implemented by many different hardware platforms, one hardware platform may support multiple CPU architecture family members โ though with different binaries. Example time ๐: theMACHINEofi386supported the IBM-AT hardware platform, while theMACHINEofpc98supported the Japanese company NEC's PC-9801 and PC-9821 hardware platforms. Both of those hardware platforms supported only theMACHINE_ARCHofi386, where they shared a common ABI โ except for certain kernel/userland interfaces relating to underlying hardware platform differences in bus architecture, device enumeration and boot interface. Generally,MACHINEshould only be used insrc/sysandsrc/stand, or in system imagers or installers.MACHINE_ARCHโ the CPU processor architecture. Same as the native platform'suname(1) -poutput. It defines the CPU instruction family that's supported, and it can also encode a lot of other stuff:- a variation in the byte ordering of multi-byte integers (endian) ๐
- a variation in the size of the integer or pointer
- an ISA revision
- hard versus soft floating point ABI and usage
- a variant ABI, when the other factors don't uniquely define the ABI
It, along with MACHINE, defines the ABI used by the system. Generally the plain CPU name specifies the most common (or at least first) variant of the CPU โ which is exactly why powerpc and powerpc64 imply 'big endian' while armv7 and aarch64 imply little endian. If we ever supported the so-called x32 ABI (using 32-bit pointers on the amd64 architecture), it would most likely be encoded as amd64-x32. And yeah, it's unfortunate that amd64 specifies the 64-bit evolution of the x86 platform (it matches the 'first rule') since almost everybody else uses x86_64. The FreeBSD port was so early that it predated processor name standardization after Intel joined the market โ at the time, each OS just picked its own conventions. And backwards compatibility means it's not easy to change to the consensus name. ๐ญ
MACHINE_CPUARCHโ represents the source location for a givenMACHINE_ARCH. It's generally the common prefix for all theMACHINE_ARCHvalues that share the same implementation, thoughriscvbreaks this rule (iconic of it tbh). And whileamd64andi386are closely related,MACHINE_CPUARCHis notx86for them. The FreeBSD source base supportsamd64andi386with two distinct source bases living in subdirectories namedamd64andi386โ though behind the scenes there's some sharing that fits into this framework. ๐งCPUTYPEโ sets the flavor ofMACHINE_ARCHto build. It's used to optimize the build for a specific CPU/core that the binaries run on. Generally this does not change the ABI, though it can be a fine line between optimization for specific cases. โ๏ธTARGETโ used to setMACHINEin the top levelMakefilefor cross building. It's unused outside of that scope, and it is not passed down to the rest of the build. Makefiles outside of the top level should not use it at all โ though some have their own private copy for historical reasons, because of course they do. ๐TARGET_ARCHโ used to setMACHINE_ARCHby the top levelMakefilefor cross building. LikeTARGET, it's unused outside of that scope.
๐ SEE ALSO
elfctl(1), proccontrol(1), sysctl(3), src.conf(5), build(7), simd(7)
Go read them, bestie, they're all bangers. ๐โจ
๐ HISTORY
An arch manual page appeared in FreeBSD 11.1. ๐
And that's the whole vibe check โ this little Debian build of the page is dated July 14, 2025, and it's called ARCH(7). Slay, go forth and cross-compile responsibly. ๐ซถ๐๐
๐ฆ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2016-2017 The FreeBSD Foundation
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms