xref: /freebsd/share/man/man7/arch.7 (revision 15d641f076ad05b71c86e174cf76d67334b4c31c)
1e6c0d5c3SKonstantin Belousov.\" Copyright (c) 2016-2017 The FreeBSD Foundation. All rights reserved.
2df9330b5SEd Maste.\"
3df9330b5SEd Maste.\" This documentation was created by Ed Maste under sponsorship of
4df9330b5SEd Maste.\" The FreeBSD Foundation.
5df9330b5SEd Maste.\"
6df9330b5SEd Maste.\" Redistribution and use in source and binary forms, with or without
7df9330b5SEd Maste.\" modification, are permitted provided that the following conditions
8df9330b5SEd Maste.\" are met:
9df9330b5SEd Maste.\" 1. Redistributions of source code must retain the above copyright
10df9330b5SEd Maste.\"    notice, this list of conditions and the following disclaimer.
11df9330b5SEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright
12df9330b5SEd Maste.\"    notice, this list of conditions and the following disclaimer in the
13df9330b5SEd Maste.\"    documentation and/or other materials provided with the distribution.
14df9330b5SEd Maste.\"
15df9330b5SEd Maste.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND
16df9330b5SEd Maste.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17df9330b5SEd Maste.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18df9330b5SEd Maste.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
19df9330b5SEd Maste.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20df9330b5SEd Maste.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21df9330b5SEd Maste.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22df9330b5SEd Maste.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23df9330b5SEd Maste.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24df9330b5SEd Maste.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25df9330b5SEd Maste.\" SUCH DAMAGE.
26df9330b5SEd Maste.\"
27df9330b5SEd Maste.\" $FreeBSD$
28df9330b5SEd Maste.\"
297b692b8eSWarner Losh.Dd November 20, 2019
30df9330b5SEd Maste.Dt ARCH 7
31df9330b5SEd Maste.Os
32df9330b5SEd Maste.Sh NAME
33df9330b5SEd Maste.Nm arch
34df9330b5SEd Maste.Nd Architecture-specific details
35df9330b5SEd Maste.Sh DESCRIPTION
36df9330b5SEd MasteDifferences between CPU architectures and platforms supported by
37df9330b5SEd Maste.Fx .
38de6fc272SKonstantin Belousov.Ss Introduction
3925b526e6SKonstantin BelousovThis document is a quick reference of key ABI details of
4025b526e6SKonstantin Belousov.Fx
4125b526e6SKonstantin Belousovarchitecture ports.
4225b526e6SKonstantin BelousovFor full details consult the processor-specific ABI supplement
4325b526e6SKonstantin Belousovdocumentation.
4425b526e6SKonstantin Belousov.Pp
45dddb1576SKonstantin BelousovIf not explicitly mentioned, sizes are in bytes.
4645801499SEd MasteThe architecture details in this document apply to
478b3c5418SEd Maste.Fx 11.0
4845801499SEd Masteand later, unless otherwise noted.
49de6fc272SKonstantin Belousov.Pp
50e6c0d5c3SKonstantin Belousov.Fx
517748ab43SKonstantin Belousovuses a flat address space.
527748ab43SKonstantin BelousovVariables of types
53e6c0d5c3SKonstantin Belousov.Vt unsigned long ,
54e6c0d5c3SKonstantin Belousov.Vt uintptr_t ,
55de6fc272SKonstantin Belousovand
56de6fc272SKonstantin Belousov.Vt size_t
577748ab43SKonstantin Belousovand pointers all have the same representation.
58de6fc272SKonstantin Belousov.Pp
59de6fc272SKonstantin BelousovIn order to maximize compatibility with future pointer integrity mechanisms,
60de6fc272SKonstantin Belousovmanipulations of pointers as integers should be performed via
61de6fc272SKonstantin Belousov.Vt uintptr_t
62de6fc272SKonstantin Belousovor
63de6fc272SKonstantin Belousov.Vt intptr_t
64de6fc272SKonstantin Belousovand no other types.
65de6fc272SKonstantin BelousovIn particular,
66de6fc272SKonstantin Belousov.Vt long
67de6fc272SKonstantin Belousovand
68de6fc272SKonstantin Belousov.Vt ptrdiff_t
69de6fc272SKonstantin Belousovshould be avoided.
70de6fc272SKonstantin Belousov.Pp
71098150fbSWarner LoshOn some architectures, e.g.,
72de6fc272SKonstantin Belousov.Dv sparc64 ,
73de6fc272SKonstantin Belousov.Dv powerpc
74de6fc272SKonstantin Belousovand AIM variants of
75de6fc272SKonstantin Belousov.Dv powerpc64 ,
76de6fc272SKonstantin Belousovthe kernel uses a separate address space.
77de6fc272SKonstantin BelousovOn other architectures, kernel and a user mode process share a
78de6fc272SKonstantin Belousovsingle address space.
79de6fc272SKonstantin BelousovThe kernel is located at the highest addresses.
80de6fc272SKonstantin Belousov.Pp
81de6fc272SKonstantin BelousovOn each architecture, the main user mode thread's stack starts near
82de6fc272SKonstantin Belousovthe highest user address and grows down.
8345801499SEd Maste.Pp
8445801499SEd Maste.Fx
8545801499SEd Mastearchitecture support varies by release.
8645801499SEd MasteThis table shows the first
8745801499SEd Maste.Fx
8845801499SEd Masterelease to support each architecture, and, for discontinued
8945801499SEd Mastearchitectures, the final release.
9045801499SEd Maste.Pp
9145801499SEd Maste.Bl -column -offset indent "Sy Architecture" "Sy Initial Release" "Sy Final Release"
9245801499SEd Maste.It Sy Architecture Ta Sy Initial Release Ta Sy Final Release
93f38b2297SIan Lepore.It aarch64     Ta 11.0
9404794d24SJohn Baldwin.It alpha       Ta 3.2   Ta 6.4
9545801499SEd Maste.It amd64       Ta 5.1
962fe25d16SEd Maste.It arm         Ta 6.0   Ta 12.x
97e9d6b13dSWarner Losh.It armeb       Ta 8.0   Ta 11.x
9845801499SEd Maste.It armv6       Ta 10.0
9913368c38SWarner Losh.It armv7       Ta 12.0
1001f3de6dcSEd Maste.It ia64        Ta 5.0   Ta 10.4
10145801499SEd Maste.It i386        Ta 1.0
10245801499SEd Maste.It mips        Ta 8.0
10345801499SEd Maste.It mipsel      Ta 9.0
10445801499SEd Maste.It mipselhf    Ta 12.0
10545801499SEd Maste.It mipshf      Ta 12.0
10645801499SEd Maste.It mipsn32     Ta 9.0
10745801499SEd Maste.It mips64      Ta 9.0
10845801499SEd Maste.It mips64el    Ta 9.0
10945801499SEd Maste.It mips64elhf  Ta 12.0
11045801499SEd Maste.It mips64hf    Ta 12.0
1117fb14275SEd Maste.It pc98        Ta 2.2   Ta 11.x
11245801499SEd Maste.It powerpc     Ta 6.0
11345801499SEd Maste.It powerpcspe  Ta 12.0
11445801499SEd Maste.It powerpc64   Ta 6.0
11545801499SEd Maste.It riscv64     Ta 12.0
11645801499SEd Maste.It riscv64sf   Ta 12.0
1174940bf26SEd Maste.It sparc64     Ta 5.0   Ta 12.x
11845801499SEd Maste.El
119df9330b5SEd Maste.Ss Type sizes
120e6c0d5c3SKonstantin BelousovAll
121e6c0d5c3SKonstantin Belousov.Fx
122e6c0d5c3SKonstantin Belousovarchitectures use some variant of the ELF (see
123de6fc272SKonstantin Belousov.Xr elf 5 )
124de6fc272SKonstantin Belousov.Sy Application Binary Interface
125de6fc272SKonstantin Belousov(ABI) for the machine processor.
126de6fc272SKonstantin BelousovAll supported ABIs can be divided into two groups:
127de6fc272SKonstantin Belousov.Bl -tag -width "Dv ILP32"
128de6fc272SKonstantin Belousov.It Dv ILP32
129de6fc272SKonstantin Belousov.Vt int ,
130de6fc272SKonstantin Belousov.Vt long ,
131de6fc272SKonstantin Belousov.Vt void *
132de6fc272SKonstantin Belousovtypes machine representations all have 4-byte size.
133de6fc272SKonstantin Belousov.It Dv LP64
134de6fc272SKonstantin Belousov.Vt int
135de6fc272SKonstantin Belousovtype machine representation uses 4 bytes,
136de6fc272SKonstantin Belousovwhile
137de6fc272SKonstantin Belousov.Vt long
138de6fc272SKonstantin Belousovand
139de6fc272SKonstantin Belousov.Vt void *
140de6fc272SKonstantin Belousovare 8 bytes.
141de6fc272SKonstantin Belousov.El
142*15d641f0SJohn Baldwin.Pp
143e6c0d5c3SKonstantin BelousovCompilers define the
144de6fc272SKonstantin Belousov.Dv _LP64
145de6fc272SKonstantin Belousovsymbol when compiling for an
146de6fc272SKonstantin Belousov.Dv LP64
147de6fc272SKonstantin BelousovABI.
148de6fc272SKonstantin Belousov.Pp
149fcfe2d66SIan LeporeSome machines support more than one
150e6c0d5c3SKonstantin Belousov.Fx
151e6c0d5c3SKonstantin BelousovABI.
152de6fc272SKonstantin BelousovTypically these are 64-bit machines, where the
153de6fc272SKonstantin Belousov.Dq native
154de6fc272SKonstantin Belousov.Dv LP64
155de6fc272SKonstantin Belousovexecution environment is accompanied by the
156de6fc272SKonstantin Belousov.Dq legacy
157de6fc272SKonstantin Belousov.Dv ILP32
158fcfe2d66SIan Leporeenvironment, which was the historical 32-bit predecessor for 64-bit evolution.
159de6fc272SKonstantin BelousovExamples are:
160e6c0d5c3SKonstantin Belousov.Bl -column -offset indent "Dv powerpc64" "Sy ILP32 counterpart"
161de6fc272SKonstantin Belousov.It Sy LP64        Ta Sy ILP32 counterpart
162de6fc272SKonstantin Belousov.It Dv amd64       Ta Dv i386
163de6fc272SKonstantin Belousov.It Dv powerpc64   Ta Dv powerpc
164de6fc272SKonstantin Belousov.It Dv mips64*     Ta Dv mips*
16514601230SOlivier Houchard.It Dv aarch64     Ta Dv armv6/armv7
166de6fc272SKonstantin Belousov.El
167*15d641f0SJohn Baldwin.Pp
168f38b2297SIan Lepore.Dv aarch64
16914601230SOlivier Houchardwill support execution of
170de6fc272SKonstantin Belousov.Dv armv6
17113368c38SWarner Loshor
17213368c38SWarner Losh.Dv armv7
17314601230SOlivier Houchardbinaries if the CPU implements
174de6fc272SKonstantin Belousov.Dv AArch32
17514601230SOlivier Houchardexecution state, however
17614601230SOlivier Houchard.Dv armv5
17714601230SOlivier Houchardbinaries aren't supported.
178de6fc272SKonstantin Belousov.Pp
179dddb1576SKonstantin BelousovOn all supported architectures:
180df9330b5SEd Maste.Bl -column -offset -indent "long long" "Size"
181df9330b5SEd Maste.It Sy Type Ta Sy Size
182df9330b5SEd Maste.It short Ta 2
183df9330b5SEd Maste.It int Ta 4
184df9330b5SEd Maste.It long Ta sizeof(void*)
185df9330b5SEd Maste.It long long Ta 8
186df9330b5SEd Maste.It float Ta 4
187df9330b5SEd Maste.It double Ta 8
188df9330b5SEd Maste.El
189*15d641f0SJohn Baldwin.Pp
1907748ab43SKonstantin BelousovIntegers are represented in two's complement.
191de6fc272SKonstantin BelousovAlignment of integer and pointer types is natural, that is,
192e6c0d5c3SKonstantin Belousovthe address of the variable must be congruent to zero modulo the type size.
193e6c0d5c3SKonstantin BelousovMost ILP32 ABIs, except
194e6c0d5c3SKonstantin Belousov.Dv arm ,
195e6c0d5c3SKonstantin Belousovrequire only 4-byte alignment for 64-bit integers.
196dddb1576SKonstantin Belousov.Pp
197dddb1576SKonstantin BelousovMachine-dependent type sizes:
198dddb1576SKonstantin Belousov.Bl -column -offset indent "Sy Architecture" "Sy void *" "Sy long double" "Sy time_t"
199dddb1576SKonstantin Belousov.It Sy Architecture Ta Sy void * Ta Sy long double Ta Sy time_t
200f38b2297SIan Lepore.It aarch64     Ta 8 Ta 16 Ta 8
2016554316cSKonstantin Belousov.It amd64       Ta 8 Ta 16 Ta 8
2026554316cSKonstantin Belousov.It arm         Ta 4 Ta  8 Ta 8
2036554316cSKonstantin Belousov.It armv6       Ta 4 Ta  8 Ta 8
2046554316cSKonstantin Belousov.It i386        Ta 4 Ta 12 Ta 4
2056554316cSKonstantin Belousov.It mips        Ta 4 Ta  8 Ta 8
2066554316cSKonstantin Belousov.It mipsel      Ta 4 Ta  8 Ta 8
2076554316cSKonstantin Belousov.It mipselhf    Ta 4 Ta  8 Ta 8
2086554316cSKonstantin Belousov.It mipshf      Ta 4 Ta  8 Ta 8
2096554316cSKonstantin Belousov.It mipsn32     Ta 4 Ta  8 Ta 8
2106554316cSKonstantin Belousov.It mips64      Ta 8 Ta  8 Ta 8
2116554316cSKonstantin Belousov.It mips64el    Ta 8 Ta  8 Ta 8
2126554316cSKonstantin Belousov.It mips64elhf  Ta 8 Ta  8 Ta 8
2136554316cSKonstantin Belousov.It mips64hf    Ta 8 Ta  8 Ta 8
214fbcf7bcdSJustin Hibbits.It powerpc     Ta 4 Ta  8 Ta 8
215fbcf7bcdSJustin Hibbits.It powerpcspe  Ta 4 Ta  8 Ta 8
2166554316cSKonstantin Belousov.It powerpc64   Ta 8 Ta  8 Ta 8
2174dd67957SJohn Baldwin.It riscv64     Ta 8 Ta 16 Ta 8
2184dd67957SJohn Baldwin.It riscv64sf   Ta 8 Ta 16 Ta 8
2196554316cSKonstantin Belousov.It sparc64     Ta 8 Ta 16 Ta 8
220df9330b5SEd Maste.El
221dddb1576SKonstantin Belousov.Pp
222dddb1576SKonstantin Belousov.Sy time_t
22349ccd3feSEd Masteis 8 bytes on all supported architectures except i386.
224df9330b5SEd Maste.Ss Endianness and Char Signedness
22542e83752SKonstantin Belousov.Bl -column -offset indent "Sy Architecture" "Sy Endianness" "Sy char Signedness"
226df9330b5SEd Maste.It Sy Architecture Ta Sy Endianness Ta Sy char Signedness
227f38b2297SIan Lepore.It aarch64     Ta little Ta unsigned
228df9330b5SEd Maste.It amd64       Ta little Ta   signed
229df9330b5SEd Maste.It arm         Ta little Ta unsigned
230df9330b5SEd Maste.It armv6       Ta little Ta unsigned
23113368c38SWarner Losh.It armv7       Ta little Ta unsigned
232df9330b5SEd Maste.It i386        Ta little Ta   signed
2338395cdc1SEd Maste.It mips        Ta big    Ta   signed
2348395cdc1SEd Maste.It mipsel      Ta little Ta   signed
2355bca2215SRuslan Bukin.It mipselhf    Ta little Ta   signed
2365bca2215SRuslan Bukin.It mipshf      Ta big    Ta   signed
2378395cdc1SEd Maste.It mipsn32     Ta big    Ta   signed
2388395cdc1SEd Maste.It mips64      Ta big    Ta   signed
239df9330b5SEd Maste.It mips64el    Ta little Ta   signed
2405bca2215SRuslan Bukin.It mips64elhf  Ta little Ta   signed
2415bca2215SRuslan Bukin.It mips64hf    Ta big    Ta   signed
242df9330b5SEd Maste.It powerpc     Ta big    Ta unsigned
243002cc1f9SJustin Hibbits.It powerpcspe  Ta big    Ta unsigned
244df9330b5SEd Maste.It powerpc64   Ta big    Ta unsigned
2454dd67957SJohn Baldwin.It riscv64     Ta little Ta   signed
2464dd67957SJohn Baldwin.It riscv64sf   Ta little Ta   signed
247df9330b5SEd Maste.It sparc64     Ta big    Ta   signed
248df9330b5SEd Maste.El
249df9330b5SEd Maste.Ss Page Size
2501859c867SKonstantin Belousov.Bl -column -offset indent "Sy Architecture" "Sy Page Sizes"
251df9330b5SEd Maste.It Sy Architecture Ta Sy Page Sizes
252f38b2297SIan Lepore.It aarch64     Ta 4K, 2M, 1G
253df9330b5SEd Maste.It amd64       Ta 4K, 2M, 1G
254df9330b5SEd Maste.It arm         Ta 4K
255780586e8SEd Maste.It armv6       Ta 4K, 1M
25613368c38SWarner Losh.It armv7       Ta 4K, 1M
257df9330b5SEd Maste.It i386        Ta 4K, 2M (PAE), 4M
258df9330b5SEd Maste.It mips        Ta 4K
259df9330b5SEd Maste.It mipsel      Ta 4K
2605bca2215SRuslan Bukin.It mipselhf    Ta 4K
2615bca2215SRuslan Bukin.It mipshf      Ta 4K
262df9330b5SEd Maste.It mipsn32     Ta 4K
263df9330b5SEd Maste.It mips64      Ta 4K
264df9330b5SEd Maste.It mips64el    Ta 4K
2655bca2215SRuslan Bukin.It mips64elhf  Ta 4K
2665bca2215SRuslan Bukin.It mips64hf    Ta 4K
267df9330b5SEd Maste.It powerpc     Ta 4K
268002cc1f9SJustin Hibbits.It powerpcspe  Ta 4K
269df9330b5SEd Maste.It powerpc64   Ta 4K
2704dd67957SJohn Baldwin.It riscv64     Ta 4K
2714dd67957SJohn Baldwin.It riscv64sf   Ta 4K
272df9330b5SEd Maste.It sparc64     Ta 8K
273df9330b5SEd Maste.El
274df9330b5SEd Maste.Ss Floating Point
2751859c867SKonstantin Belousov.Bl -column -offset indent "Sy Architecture" "Sy float, double" "Sy long double"
276df9330b5SEd Maste.It Sy Architecture Ta Sy float, double Ta Sy long double
277f38b2297SIan Lepore.It aarch64     Ta hard Ta soft, quad precision
278df9330b5SEd Maste.It amd64       Ta hard Ta hard, 80 bit
279df9330b5SEd Maste.It arm         Ta soft Ta soft, double precision
2808b3c5418SEd Maste.It armv6       Ta hard Ta hard, double precision
2818b3c5418SEd Maste.It armv7       Ta hard Ta hard, double precision
282df9330b5SEd Maste.It i386        Ta hard Ta hard, 80 bit
283df9330b5SEd Maste.It mips        Ta soft Ta identical to double
284df9330b5SEd Maste.It mipsel      Ta soft Ta identical to double
2855bca2215SRuslan Bukin.It mipselhf    Ta hard Ta identical to double
2865bca2215SRuslan Bukin.It mipshf      Ta hard Ta identical to double
287df9330b5SEd Maste.It mipsn32     Ta soft Ta identical to double
288df9330b5SEd Maste.It mips64      Ta soft Ta identical to double
289df9330b5SEd Maste.It mips64el    Ta soft Ta identical to double
2905bca2215SRuslan Bukin.It mips64elhf  Ta hard Ta identical to double
2915bca2215SRuslan Bukin.It mips64hf    Ta hard Ta identical to double
292df9330b5SEd Maste.It powerpc     Ta hard Ta hard, double precision
293002cc1f9SJustin Hibbits.It powerpcspe  Ta hard Ta hard, double precision
294df9330b5SEd Maste.It powerpc64   Ta hard Ta hard, double precision
295cb8c6df4SKevin Lo.It riscv64     Ta hard Ta hard, double precision
296cb8c6df4SKevin Lo.It riscv64sf   Ta soft Ta soft, double precision
297df9330b5SEd Maste.It sparc64     Ta hard Ta hard, quad precision
298df9330b5SEd Maste.El
2994ef28065SEd Maste.Ss Default Tool Chain
3004715c31eSEd Maste.Fx uses a variety of tool chain components for the supported CPU
3014715c31eSEd Mastearchitectures:
3024715c31eSEd Maste.Xr clang 1
3034715c31eSEd Masteand
3044715c31eSEd Maste.Xr ld.lld 1
3054715c31eSEd Masteprovided by the base system,
3064715c31eSEd MasteGNU
3074715c31eSEd Maste.Xr gcc 1
3084715c31eSEd Masteand Binutils
3094715c31eSEd Maste.Xr ld 1 ,
3104715c31eSEd Masteor an external toolchain compiler and linker provided by a port or package.
3114ef28065SEd MasteThis table shows the default tool chain for each architecture.
3124715c31eSEd Maste.Bl -column -offset indent "Sy Architecture" "Sy Compiler" "Sy Linker"
3134715c31eSEd Maste.It Sy Architecture Ta Sy Compiler Ta Sy Linker
3144715c31eSEd Maste.It aarch64     Ta Clang     Ta lld
3154715c31eSEd Maste.It amd64       Ta Clang     Ta lld
3164715c31eSEd Maste.It arm         Ta Clang     Ta GNU ld 2.17.50
31778c12e76SEd Maste.It armv6       Ta Clang     Ta lld
3184715c31eSEd Maste.It armv7       Ta Clang     Ta lld
3194715c31eSEd Maste.It i386        Ta Clang     Ta lld
3204715c31eSEd Maste.It mips        Ta GCC 4.2.1 Ta GNU ld 2.17.50
3214715c31eSEd Maste.It mipsel      Ta GCC 4.2.1 Ta GNU ld 2.17.50
3224715c31eSEd Maste.It mipselhf    Ta GCC 4.2.1 Ta GNU ld 2.17.50
3234715c31eSEd Maste.It mipshf      Ta GCC 4.2.1 Ta GNU ld 2.17.50
3244715c31eSEd Maste.It mipsn32     Ta GCC 4.2.1 Ta GNU ld 2.17.50
3254715c31eSEd Maste.It mips64      Ta GCC 4.2.1 Ta GNU ld 2.17.50
3264715c31eSEd Maste.It mips64el    Ta GCC 4.2.1 Ta GNU ld 2.17.50
3274715c31eSEd Maste.It mips64elhf  Ta GCC 4.2.1 Ta GNU ld 2.17.50
3284715c31eSEd Maste.It mips64hf    Ta GCC 4.2.1 Ta GNU ld 2.17.50
329678da4a2SJustin Hibbits.It powerpc     Ta Clang     Ta GNU ld 2.17.50
330678da4a2SJustin Hibbits.It powerpcspe  Ta Clang     Ta GNU ld 2.17.50
331678da4a2SJustin Hibbits.It powerpc64   Ta Clang     Ta lld
3324715c31eSEd Maste.It riscv64     Ta GCC(1)    Ta GNU ld(1)
3334715c31eSEd Maste.It riscv64sf   Ta GCC(1)    Ta GNU ld(1)
3344715c31eSEd Maste.It sparc64     Ta GCC 4.2.1 Ta GNU ld 2.17.50
3354715c31eSEd Maste.El
3364715c31eSEd Maste.Pp
3374715c31eSEd Maste(1) External toolchain provided by ports/packages.
338ff03c712SEd Maste.Pp
339ff03c712SEd MasteNote that GCC 4.2.1 is deprecated, and scheduled for removal on 2020-03-31.
340c06ccdd2SEd MasteAny CPU architectures not migrated by then
341c06ccdd2SEd Maste(to either base system Clang or external toolchain)
342c06ccdd2SEd Mastemay be removed from the tree after that date.
3435bc9524cSWarner LoshUnless the make variable
3445bc9524cSWarner Losh.Dv MAKE_OBSOLETE_GCC
345678da4a2SJustin Hibbitsis defined, make universe will not build mips or sparc64
3465bc9524cSWarner Losharchitectures unless the xtoolchain binaries have been installed for
3475bc9524cSWarner Loshthe architecture.
348c81e4a69SWarner Losh.Ss MACHINE_ARCH vs MACHINE_CPUARCH vs MACHINE
3497b692b8eSWarner Losh.Dv MACHINE_CPUARCH
3507b692b8eSWarner Loshshould be preferred in Makefiles when the generic
3517b692b8eSWarner Losharchitecture is being tested.
3527b692b8eSWarner Losh.Dv MACHINE_ARCH
3537b692b8eSWarner Loshshould be preferred when there is something specific to a particular type of
3547b692b8eSWarner Losharchitecture where there is a choice of many, or could be a choice of many.
355c81e4a69SWarner LoshUse
356c81e4a69SWarner Losh.Dv MACHINE
357c81e4a69SWarner Loshwhen referring to the kernel, interfaces dependent on a specific type of kernel
358c81e4a69SWarner Loshor similar things like boot sequences.
3597b692b8eSWarner Losh.Bl -column -offset indent "Dv MACHINE" "Dv MACHINE_CPUARCH" "Dv MACHINE_ARCH"
3607b692b8eSWarner Losh.It Dv MACHINE Ta Dv MACHINE_CPUARCH Ta Dv MACHINE_ARCH
3617b692b8eSWarner Losh.It arm64 Ta aarch64 Ta aarch64
3627b692b8eSWarner Losh.It amd64 Ta amd64 Ta amd64
3637b692b8eSWarner Losh.It arm Ta arm Ta arm, armv6, armv7
3647b692b8eSWarner Losh.It i386 Ta i386 Ta i386
3657b692b8eSWarner Losh.It mips Ta mips Ta mips, mipsel, mips64, mips64el, mipshf, mipselhf, mips64elhf, mipsn32
3667b692b8eSWarner Losh.It powerpc Ta powerpc Ta powerpc, powerpcspe, powerpc64
3677b692b8eSWarner Losh.It riscv Ta riscv Ta riscv64, riscv64sf
3687b692b8eSWarner Losh.It sparc64 Ta sparc64 Ta sparc64
3697b692b8eSWarner Losh.El
370df9330b5SEd Maste.Ss Predefined Macros
371df9330b5SEd MasteThe compiler provides a number of predefined macros.
372df9330b5SEd MasteSome of these provide architecture-specific details and are explained below.
373df9330b5SEd MasteOther macros, including those required by the language standard, are not
374df9330b5SEd Masteincluded here.
375df9330b5SEd Maste.Pp
376df9330b5SEd MasteThe full set of predefined macros can be obtained with this command:
377df9330b5SEd Maste.Bd -literal -offset indent
3788e71e112SEd Mastecc -x c -dM -E /dev/null
379df9330b5SEd Maste.Ed
380df9330b5SEd Maste.Pp
381df9330b5SEd MasteCommon type size and endianness macros:
3821859c867SKonstantin Belousov.Bl -column -offset indent "BYTE_ORDER" "Sy Meaning"
383df9330b5SEd Maste.It Sy Macro Ta Sy Meaning
384df9330b5SEd Maste.It Dv __LP64__ Ta 64-bit (8-byte) long and pointer, 32-bit (4-byte) int
385df9330b5SEd Maste.It Dv __ILP32__ Ta 32-bit (4-byte) int, long and pointer
386df9330b5SEd Maste.It Dv BYTE_ORDER Ta Either Dv BIG_ENDIAN or Dv LITTLE_ENDIAN .
3871859c867SKonstantin Belousov.Dv PDP11_ENDIAN
3881859c867SKonstantin Belousovis not used on
3891859c867SKonstantin Belousov.Fx .
390df9330b5SEd Maste.El
391df9330b5SEd Maste.Pp
392df9330b5SEd MasteArchitecture-specific macros:
3931859c867SKonstantin Belousov.Bl -column -offset indent "Sy Architecture" "Sy Predefined macros"
394df9330b5SEd Maste.It Sy Architecture Ta Sy Predefined macros
395f38b2297SIan Lepore.It aarch64     Ta Dv __aarch64__
396df9330b5SEd Maste.It amd64       Ta Dv __amd64__, Dv __x86_64__
397df9330b5SEd Maste.It arm         Ta Dv __arm__
398df9330b5SEd Maste.It armv6       Ta Dv __arm__, Dv __ARM_ARCH >= 6
39913368c38SWarner Losh.It armv7       Ta Dv __arm__, Dv __ARM_ARCH >= 7
400df9330b5SEd Maste.It i386        Ta Dv __i386__
401df9330b5SEd Maste.It mips        Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_o32
402df9330b5SEd Maste.It mipsel      Ta Dv __mips__, Dv __mips_o32
4035bca2215SRuslan Bukin.It mipselhf    Ta Dv __mips__, Dv __mips_o32
4045bca2215SRuslan Bukin.It mipshf      Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_o32
405df9330b5SEd Maste.It mipsn32     Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_n32
406df9330b5SEd Maste.It mips64      Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_n64
407df9330b5SEd Maste.It mips64el    Ta Dv __mips__, Dv __mips_n64
4085bca2215SRuslan Bukin.It mips64elhf  Ta Dv __mips__, Dv __mips_n64
4095bca2215SRuslan Bukin.It mips64hf    Ta Dv __mips__, Dv __MIPSEB__, Dv __mips_n64
410df9330b5SEd Maste.It powerpc     Ta Dv __powerpc__
411002cc1f9SJustin Hibbits.It powerpcspe  Ta Dv __powerpc__, Dv __SPE__
412df9330b5SEd Maste.It powerpc64   Ta Dv __powerpc__, Dv __powerpc64__
413ca20f8ecSRuslan Bukin.It riscv64     Ta Dv __riscv, Dv __riscv_xlen == 64
414ca20f8ecSRuslan Bukin.It riscv64sf   Ta Dv __riscv, Dv __riscv_xlen == 64
415df9330b5SEd Maste.It sparc64     Ta Dv __sparc64__
416df9330b5SEd Maste.El
417f84d8f0cSEd Maste.Pp
418f84d8f0cSEd MasteCompilers may define additional variants of architecture-specific macros.
419f84d8f0cSEd MasteThe macros above are preferred for use in
420f84d8f0cSEd Maste.Fx .
421691e6ea8SWarner Losh.Ss Important Xr make 1 variables
422691e6ea8SWarner LoshMost of the externally settable variables are defined in the
423691e6ea8SWarner Losh.Xr build 7
424691e6ea8SWarner Loshman page.
425691e6ea8SWarner LoshThese variables are not otherwise documented and are used extensively
426691e6ea8SWarner Loshin the build system.
427*15d641f0SJohn Baldwin.Bl -tag -width "MACHINE_CPUARCH"
428*15d641f0SJohn Baldwin.It Dv MACHINE
429*15d641f0SJohn BaldwinRepresent the hardware platform.
430691e6ea8SWarner LoshThis is the same as the native platform's
431691e6ea8SWarner Losh.Xr uname 1
432691e6ea8SWarner Losh.Fl m
433691e6ea8SWarner Loshoutput.
434691e6ea8SWarner LoshIt defines both the userland / kernel interface, as well as the
435691e6ea8SWarner Loshbootloader / kernel interface.
436691e6ea8SWarner LoshIt should only be used in these contexts.
437691e6ea8SWarner LoshEach CPU architecture may have multiple hardware platforms it supports
438691e6ea8SWarner Loshwhere
439691e6ea8SWarner Losh.Dv MACHINE
440691e6ea8SWarner Loshdiffers among them.
441691e6ea8SWarner LoshIt is used to collect together all the files from
442691e6ea8SWarner Losh.Xr config 8
443691e6ea8SWarner Loshto build the kernel.
444691e6ea8SWarner LoshIt is often the same as
445691e6ea8SWarner Losh.Dv MACHINE_ARCH
446691e6ea8SWarner Loshjust as one CPU architecture can be implemented by many different
447691e6ea8SWarner Loshhardware platforms, one hardware platform may support multiple CPU
448691e6ea8SWarner Losharchitecture family members, though with different binaries.
449691e6ea8SWarner LoshFor example,
450691e6ea8SWarner Losh.Dv MACHINE
451691e6ea8SWarner Loshof i386 supported the IBM-AT hardware platform while the
452691e6ea8SWarner Losh.Dv MACHINE
453691e6ea8SWarner Loshof pc98 supported the Japanese company NEC's PC-9801 and PC-9821
454691e6ea8SWarner Loshhardware platforms.
455691e6ea8SWarner LoshBoth of these hardware platforms supported only the
456691e6ea8SWarner Losh.Dv MACHINE_ARCH
457691e6ea8SWarner Loshof i386 where they shared a common ABI, except for certain kernel /
458691e6ea8SWarner Loshuserland interfaces relating to underlying hardware platform
459691e6ea8SWarner Loshdifferences in bus architecture, device enumeration and boot interface.
460ffab3cb6SWarner LoshGenerally,
461ffab3cb6SWarner Losh.Dv MACHINE
462ffab3cb6SWarner Loshshould only be used in src/sys and src/stand or in system imagers or
463ffab3cb6SWarner Loshinstallers.
464*15d641f0SJohn Baldwin.It Dv MACHINE_ARCH
465*15d641f0SJohn BaldwinRepresents the CPU processor architecture.
466691e6ea8SWarner LoshThis is the same as the native platforms
467691e6ea8SWarner Losh.Xr uname 1
468691e6ea8SWarner Losh.Fl p
469691e6ea8SWarner Loshoutput.
470691e6ea8SWarner LoshIt defines the CPU instruction family supported.
471691e6ea8SWarner LoshIt may also encode a variation in the byte ordering of multi-byte
472691e6ea8SWarner Loshintegers (endian).
473691e6ea8SWarner LoshIt may also encode a variation in the size of the integer or pointer.
474691e6ea8SWarner LoshIt may also encode a ISA revision.
475691e6ea8SWarner LoshIt may also encode hard versus soft floating point ABI and usage.
476320bd864SWarner LoshIt may also encode a variant ABI when the other factors do not
477320bd864SWarner Loshuniquely define the ABI (e.g., MIPS' n32 ABI).
478691e6ea8SWarner LoshIt, along with
479320bd864SWarner Losh.Dv MACHINE ,
480320bd864SWarner Loshdefines the ABI used by the system.
481691e6ea8SWarner LoshFor example, the MIPS CPU processor family supports 9 different
482098150fbSWarner Loshcombinations encoding pointer size, endian and hard versus soft float (for
483691e6ea8SWarner Losh8 combinations) as well as N32 (which only ever had one variation of
484691e6ea8SWarner Loshall these).
485691e6ea8SWarner LoshGenerally, the plain CPU name specifies the most common (or at least
486691e6ea8SWarner Loshfirst) variant of the CPU.
487691e6ea8SWarner LoshThis is why mips and mips64 imply 'big endian' while 'arm' and 'armv7'
488691e6ea8SWarner Loshimply little endian.
489691e6ea8SWarner LoshIf we ever were to support the so-called x32 ABI (using 32-bit
490691e6ea8SWarner Loshpointers on the amd64 architecture), it would most likely be encoded
491691e6ea8SWarner Loshas amd64-x32.
492d56b465cSJohn BaldwinIt is unfortunate that amd64 specifies the 64-bit evolution of the x86
493691e6ea8SWarner Loshplatform (it matches the 'first rule') as everybody else uses x86_64.
494691e6ea8SWarner LoshThere is no standard name for the processor: each OS selects its own
495691e6ea8SWarner Loshconventions.
496*15d641f0SJohn Baldwin.It Dv MACHINE_CPUARCH
497*15d641f0SJohn BaldwinRepresents the source location for a given
498ffab3cb6SWarner Losh.Dv MACHINE_ARCH .
4997b692b8eSWarner LoshIt is generally the common prefix for all the MACHINE_ARCH that
5007b692b8eSWarner Loshshare the same implementation, though 'riscv' breaks this rule.
501ffab3cb6SWarner LoshFor example,
502ffab3cb6SWarner Losh.Dv MACHINE_CPUARCH
503ffab3cb6SWarner Loshis defined to be mips for all the flavors of mips that we support
504ffab3cb6SWarner Loshsince we support them all with a shared set of sources.
505bf1dea9bSWarner LoshWhile amd64 and i386 are closely related, MACHINE_CPUARCH is not x86
506bf1dea9bSWarner Loshfor them.
507bf1dea9bSWarner LoshThe FreeBSD source base supports amd64 and i386 with two
508bf1dea9bSWarner Loshdistinct source bases living in subdirectories named amd64 and i386
509bf1dea9bSWarner Losh(though behind the scenes there's some sharing that fits into this
510bf1dea9bSWarner Loshframework).
511*15d641f0SJohn Baldwin.It Dv CPUTYPE
512*15d641f0SJohn BaldwinSets the flavor of
513691e6ea8SWarner Losh.Dv MACHINE_ARCH
514691e6ea8SWarner Loshto build.
515691e6ea8SWarner LoshIt is used to optimize the build for a specific CPU / core that the
516691e6ea8SWarner Loshbinaries run on.
517098150fbSWarner LoshGenerally, this does not change the ABI, though it can be a fine line
518691e6ea8SWarner Loshbetween optimization for specific cases.
519*15d641f0SJohn Baldwin.It Dv TARGET
520*15d641f0SJohn BaldwinUsed to set
521098150fbSWarner Losh.Dv MACHINE
522098150fbSWarner Loshin the top level Makefile for cross building.
523691e6ea8SWarner LoshUnused outside of that scope.
524691e6ea8SWarner LoshIt is not passed down to the rest of the build.
525098150fbSWarner LoshMakefiles outside of the top level should not use it at all (though
526691e6ea8SWarner Loshsome have their own private copy for hysterical raisons).
527*15d641f0SJohn Baldwin.It Dv TARGET_ARCH
528*15d641f0SJohn BaldwinUsed to set
529098150fbSWarner Losh.Dv MACHINE_ARCH
530098150fbSWarner Loshby the top level Makefile for cross building.
531691e6ea8SWarner LoshLike
532*15d641f0SJohn Baldwin.Dv TARGET ,
533*15d641f0SJohn Baldwinit is unused outside of that scope.
534691e6ea8SWarner Losh.El
535df9330b5SEd Maste.Sh SEE ALSO
536df9330b5SEd Maste.Xr src.conf 5 ,
537df9330b5SEd Maste.Xr build 7
538df9330b5SEd Maste.Sh HISTORY
539df9330b5SEd MasteAn
540df9330b5SEd Maste.Nm
541df9330b5SEd Mastemanual page appeared in
5422af3ea6bSEd Maste.Fx 11.1 .
543