xref: /freebsd/share/man/man7/arch.7 (revision 1a88a6b5c3b8f194072ebf8154be864ecba10b7d)
17fde0187SEd Maste.\" Copyright (c) 2016-2017 The FreeBSD Foundation.
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.\"
2746b91601SEd Maste.Dd February 4, 2025
28df9330b5SEd Maste.Dt ARCH 7
29df9330b5SEd Maste.Os
30df9330b5SEd Maste.Sh NAME
31df9330b5SEd Maste.Nm arch
32df9330b5SEd Maste.Nd Architecture-specific details
33df9330b5SEd Maste.Sh DESCRIPTION
34df9330b5SEd MasteDifferences between CPU architectures and platforms supported by
35df9330b5SEd Maste.Fx .
36de6fc272SKonstantin Belousov.Ss Introduction
3725b526e6SKonstantin BelousovThis document is a quick reference of key ABI details of
3825b526e6SKonstantin Belousov.Fx
3925b526e6SKonstantin Belousovarchitecture ports.
4025b526e6SKonstantin BelousovFor full details consult the processor-specific ABI supplement
4125b526e6SKonstantin Belousovdocumentation.
4225b526e6SKonstantin Belousov.Pp
43dddb1576SKonstantin BelousovIf not explicitly mentioned, sizes are in bytes.
4445801499SEd MasteThe architecture details in this document apply to
4546b91601SEd Maste.Fx 13.0
4645801499SEd Masteand later, unless otherwise noted.
47de6fc272SKonstantin Belousov.Pp
48e6c0d5c3SKonstantin Belousov.Fx
497748ab43SKonstantin Belousovuses a flat address space.
507748ab43SKonstantin BelousovVariables of types
51e6c0d5c3SKonstantin Belousov.Vt unsigned long ,
52e6c0d5c3SKonstantin Belousov.Vt uintptr_t ,
53de6fc272SKonstantin Belousovand
54de6fc272SKonstantin Belousov.Vt size_t
557748ab43SKonstantin Belousovand pointers all have the same representation.
56de6fc272SKonstantin Belousov.Pp
57de6fc272SKonstantin BelousovIn order to maximize compatibility with future pointer integrity mechanisms,
58de6fc272SKonstantin Belousovmanipulations of pointers as integers should be performed via
59de6fc272SKonstantin Belousov.Vt uintptr_t
60de6fc272SKonstantin Belousovor
61de6fc272SKonstantin Belousov.Vt intptr_t
62de6fc272SKonstantin Belousovand no other types.
63de6fc272SKonstantin BelousovIn particular,
64de6fc272SKonstantin Belousov.Vt long
65de6fc272SKonstantin Belousovand
66de6fc272SKonstantin Belousov.Vt ptrdiff_t
67de6fc272SKonstantin Belousovshould be avoided.
68de6fc272SKonstantin Belousov.Pp
69098150fbSWarner LoshOn some architectures, e.g.,
70de6fc272SKonstantin Belousov.Dv powerpc
71de6fc272SKonstantin Belousovand AIM variants of
72de6fc272SKonstantin Belousov.Dv powerpc64 ,
73de6fc272SKonstantin Belousovthe kernel uses a separate address space.
74de6fc272SKonstantin BelousovOn other architectures, kernel and a user mode process share a
75de6fc272SKonstantin Belousovsingle address space.
76de6fc272SKonstantin BelousovThe kernel is located at the highest addresses.
77de6fc272SKonstantin Belousov.Pp
78de6fc272SKonstantin BelousovOn each architecture, the main user mode thread's stack starts near
79de6fc272SKonstantin Belousovthe highest user address and grows down.
8045801499SEd Maste.Pp
8145801499SEd Maste.Fx
8245801499SEd Mastearchitecture support varies by release.
839c943f7aSEd MasteThis table shows currently supported CPU architectures along with the first
8445801499SEd Maste.Fx
859c943f7aSEd Masterelease to support each architecture.
869c943f7aSEd Maste.Bl -column -offset indent "Architecture" "Initial Release"
879c943f7aSEd Maste.It Sy Architecture Ta Sy Initial Release
88f38b2297SIan Lepore.It aarch64     Ta 11.0
8945801499SEd Maste.It amd64       Ta 5.1
9013368c38SWarner Losh.It armv7       Ta 12.0
9145801499SEd Maste.It i386        Ta 1.0
929c943f7aSEd Maste.It powerpc     Ta 6.0
939c943f7aSEd Maste.It powerpcspe  Ta 12.0
949c943f7aSEd Maste.It powerpc64   Ta 9.0
959c943f7aSEd Maste.It powerpc64le Ta 13.0
969c943f7aSEd Maste.It riscv64     Ta 12.0
979c943f7aSEd Maste.El
989c943f7aSEd Maste.Pp
999c943f7aSEd MasteDiscontinued architectures are shown in the following table.
1009c943f7aSEd Maste.Bl -column -offset indent "Architecture" "Initial Release" "Final Release"
1019c943f7aSEd Maste.It Sy Architecture Ta Sy Initial Release Ta Sy Final Release
1029c943f7aSEd Maste.It alpha       Ta 3.2   Ta 6.4
103d06328c3SEd Maste.It arm         Ta 6.0   Ta 12.4
1049c943f7aSEd Maste.It armeb       Ta 8.0   Ta 11.4
10542fbb55dSEd Maste.It armv6       Ta 10.0  Ta 14.x
1069c943f7aSEd Maste.It ia64        Ta 5.0   Ta 10.4
107a721ac94SWarner Losh.It mips        Ta 8.0   Ta 13.x
108a721ac94SWarner Losh.It mipsel      Ta 9.0   Ta 13.x
109a721ac94SWarner Losh.It mipselhf    Ta 12.0  Ta 13.x
110a721ac94SWarner Losh.It mipshf      Ta 12.0  Ta 13.x
111a721ac94SWarner Losh.It mipsn32     Ta 9.0   Ta 13.x
112a721ac94SWarner Losh.It mips64      Ta 9.0   Ta 13.x
113a721ac94SWarner Losh.It mips64el    Ta 9.0   Ta 13.x
114a721ac94SWarner Losh.It mips64elhf  Ta 12.0  Ta 13.x
115a721ac94SWarner Losh.It mips64hf    Ta 12.0  Ta 13.x
1164f954864SEd Maste.It pc98        Ta 2.2   Ta 11.4
1171ca12bd9SJohn Baldwin.It riscv64sf   Ta 12.0  Ta 13.x
118d06328c3SEd Maste.It sparc64     Ta 5.0   Ta 12.4
11945801499SEd Maste.El
120df9330b5SEd Maste.Ss Type sizes
121e6c0d5c3SKonstantin BelousovAll
122e6c0d5c3SKonstantin Belousov.Fx
123e6c0d5c3SKonstantin Belousovarchitectures use some variant of the ELF (see
124de6fc272SKonstantin Belousov.Xr elf 5 )
125de6fc272SKonstantin Belousov.Sy Application Binary Interface
126de6fc272SKonstantin Belousov(ABI) for the machine processor.
127de6fc272SKonstantin BelousovAll supported ABIs can be divided into two groups:
128de6fc272SKonstantin Belousov.Bl -tag -width "Dv ILP32"
129de6fc272SKonstantin Belousov.It Dv ILP32
130de6fc272SKonstantin Belousov.Vt int ,
131de6fc272SKonstantin Belousov.Vt long ,
132de6fc272SKonstantin Belousov.Vt void *
133de6fc272SKonstantin Belousovtypes machine representations all have 4-byte size.
134de6fc272SKonstantin Belousov.It Dv LP64
135de6fc272SKonstantin Belousov.Vt int
136de6fc272SKonstantin Belousovtype machine representation uses 4 bytes,
137de6fc272SKonstantin Belousovwhile
138de6fc272SKonstantin Belousov.Vt long
139de6fc272SKonstantin Belousovand
140de6fc272SKonstantin Belousov.Vt void *
141de6fc272SKonstantin Belousovare 8 bytes.
142de6fc272SKonstantin Belousov.El
14315d641f0SJohn Baldwin.Pp
144fcfe2d66SIan LeporeSome machines support more than one
145e6c0d5c3SKonstantin Belousov.Fx
146e6c0d5c3SKonstantin BelousovABI.
147de6fc272SKonstantin BelousovTypically these are 64-bit machines, where the
148de6fc272SKonstantin Belousov.Dq native
149de6fc272SKonstantin Belousov.Dv LP64
150de6fc272SKonstantin Belousovexecution environment is accompanied by the
151de6fc272SKonstantin Belousov.Dq legacy
152de6fc272SKonstantin Belousov.Dv ILP32
153fcfe2d66SIan Leporeenvironment, which was the historical 32-bit predecessor for 64-bit evolution.
154de6fc272SKonstantin BelousovExamples are:
155ddc9d6e5SEd Maste.Bl -column -offset indent "powerpc64" "ILP32 counterpart"
156de6fc272SKonstantin Belousov.It Sy LP64        Ta Sy ILP32 counterpart
157de6fc272SKonstantin Belousov.It Dv amd64       Ta Dv i386
158de6fc272SKonstantin Belousov.It Dv powerpc64   Ta Dv powerpc
15942fbb55dSEd Maste.It Dv aarch64     Ta Dv armv7
160de6fc272SKonstantin Belousov.El
16115d641f0SJohn Baldwin.Pp
162f38b2297SIan Lepore.Dv aarch64
16314601230SOlivier Houchardwill support execution of
16413368c38SWarner Losh.Dv armv7
16514601230SOlivier Houchardbinaries if the CPU implements
166de6fc272SKonstantin Belousov.Dv AArch32
16760f098f8SWarner Loshexecution state, however older arm binaries are not supported by
16860f098f8SWarner Losh.Fx .
169de6fc272SKonstantin Belousov.Pp
170dddb1576SKonstantin BelousovOn all supported architectures:
171c013ca2cSGraham Percival.Bl -column -offset indent "long long" "Size"
172df9330b5SEd Maste.It Sy Type Ta Sy Size
173df9330b5SEd Maste.It short Ta 2
174df9330b5SEd Maste.It int Ta 4
175df9330b5SEd Maste.It long Ta sizeof(void*)
176df9330b5SEd Maste.It long long Ta 8
177df9330b5SEd Maste.It float Ta 4
178df9330b5SEd Maste.It double Ta 8
179df9330b5SEd Maste.El
18015d641f0SJohn Baldwin.Pp
1817748ab43SKonstantin BelousovIntegers are represented in two's complement.
182de6fc272SKonstantin BelousovAlignment of integer and pointer types is natural, that is,
183e6c0d5c3SKonstantin Belousovthe address of the variable must be congruent to zero modulo the type size.
184e6c0d5c3SKonstantin BelousovMost ILP32 ABIs, except
185e6c0d5c3SKonstantin Belousov.Dv arm ,
186e6c0d5c3SKonstantin Belousovrequire only 4-byte alignment for 64-bit integers.
187dddb1576SKonstantin Belousov.Pp
188dddb1576SKonstantin BelousovMachine-dependent type sizes:
189ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "void *" "long double" "time_t"
190dddb1576SKonstantin Belousov.It Sy Architecture Ta Sy void * Ta Sy long double Ta Sy time_t
191f38b2297SIan Lepore.It aarch64     Ta 8 Ta 16 Ta 8
1926554316cSKonstantin Belousov.It amd64       Ta 8 Ta 16 Ta 8
193bad7e1e8SWarner Losh.It armv7       Ta 4 Ta  8 Ta 8
1946554316cSKonstantin Belousov.It i386        Ta 4 Ta 12 Ta 4
195fbcf7bcdSJustin Hibbits.It powerpc     Ta 4 Ta  8 Ta 8
196fbcf7bcdSJustin Hibbits.It powerpcspe  Ta 4 Ta  8 Ta 8
1976554316cSKonstantin Belousov.It powerpc64   Ta 8 Ta  8 Ta 8
1981bdb1aa4SBrandon Bergren.It powerpc64le Ta 8 Ta  8 Ta 8
1994dd67957SJohn Baldwin.It riscv64     Ta 8 Ta 16 Ta 8
200df9330b5SEd Maste.El
201dddb1576SKonstantin Belousov.Pp
202dddb1576SKonstantin Belousov.Sy time_t
20349ccd3feSEd Masteis 8 bytes on all supported architectures except i386.
204df9330b5SEd Maste.Ss Endianness and Char Signedness
205ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "Endianness" "char Signedness"
206df9330b5SEd Maste.It Sy Architecture Ta Sy Endianness Ta Sy char Signedness
207f38b2297SIan Lepore.It aarch64     Ta little Ta unsigned
208df9330b5SEd Maste.It amd64       Ta little Ta   signed
20913368c38SWarner Losh.It armv7       Ta little Ta unsigned
210df9330b5SEd Maste.It i386        Ta little Ta   signed
211df9330b5SEd Maste.It powerpc     Ta big    Ta unsigned
212002cc1f9SJustin Hibbits.It powerpcspe  Ta big    Ta unsigned
213df9330b5SEd Maste.It powerpc64   Ta big    Ta unsigned
2141bdb1aa4SBrandon Bergren.It powerpc64le Ta little Ta unsigned
2154dd67957SJohn Baldwin.It riscv64     Ta little Ta   signed
216df9330b5SEd Maste.El
217df9330b5SEd Maste.Ss Page Size
218ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "Page Sizes"
219df9330b5SEd Maste.It Sy Architecture Ta Sy Page Sizes
2203e00c11aSAlan Cox.It aarch64     Ta 4K, 64K, 2M, 1G
221df9330b5SEd Maste.It amd64       Ta 4K, 2M, 1G
22213368c38SWarner Losh.It armv7       Ta 4K, 1M
223df9330b5SEd Maste.It i386        Ta 4K, 2M (PAE), 4M
224df9330b5SEd Maste.It powerpc     Ta 4K
225002cc1f9SJustin Hibbits.It powerpcspe  Ta 4K
226df9330b5SEd Maste.It powerpc64   Ta 4K
2271bdb1aa4SBrandon Bergren.It powerpc64le Ta 4K
228c4ef7cdbSMitchell Horne.It riscv64     Ta 4K, 2M, 1G
229df9330b5SEd Maste.El
230df9330b5SEd Maste.Ss Floating Point
231ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "float, double" "long double"
232df9330b5SEd Maste.It Sy Architecture Ta Sy float, double Ta Sy long double
233f38b2297SIan Lepore.It aarch64     Ta hard Ta soft, quad precision
234df9330b5SEd Maste.It amd64       Ta hard Ta hard, 80 bit
2358b3c5418SEd Maste.It armv7       Ta hard Ta hard, double precision
236df9330b5SEd Maste.It i386        Ta hard Ta hard, 80 bit
237df9330b5SEd Maste.It powerpc     Ta hard Ta hard, double precision
238002cc1f9SJustin Hibbits.It powerpcspe  Ta hard Ta hard, double precision
239df9330b5SEd Maste.It powerpc64   Ta hard Ta hard, double precision
2401bdb1aa4SBrandon Bergren.It powerpc64le Ta hard Ta hard, double precision
241c4ef7cdbSMitchell Horne.It riscv64     Ta hard Ta hard, quad precision
242df9330b5SEd Maste.El
2434ef28065SEd Maste.Ss Default Tool Chain
244ce0d5fb4SEd Maste.Fx
245ce0d5fb4SEd Masteuses
2464715c31eSEd Maste.Xr clang 1
247ce0d5fb4SEd Masteas the default compiler on all supported CPU architectures,
248e6f6c36cSEd MasteLLVM's
249e6f6c36cSEd Maste.Xr ld.lld 1
250e6f6c36cSEd Masteas the default linker, and
251e6f6c36cSEd MasteELF Tool Chain binary utilities such as
252ce0d5fb4SEd Maste.Xr objcopy 1
2534715c31eSEd Masteand
254ce0d5fb4SEd Maste.Xr readelf 1 .
255c81e4a69SWarner Losh.Ss MACHINE_ARCH vs MACHINE_CPUARCH vs MACHINE
2567b692b8eSWarner Losh.Dv MACHINE_CPUARCH
2577b692b8eSWarner Loshshould be preferred in Makefiles when the generic
2587b692b8eSWarner Losharchitecture is being tested.
2597b692b8eSWarner Losh.Dv MACHINE_ARCH
2607b692b8eSWarner Loshshould be preferred when there is something specific to a particular type of
2617b692b8eSWarner Losharchitecture where there is a choice of many, or could be a choice of many.
262c81e4a69SWarner LoshUse
263c81e4a69SWarner Losh.Dv MACHINE
264c81e4a69SWarner Loshwhen referring to the kernel, interfaces dependent on a specific type of kernel
265c81e4a69SWarner Loshor similar things like boot sequences.
2667b692b8eSWarner Losh.Bl -column -offset indent "Dv MACHINE" "Dv MACHINE_CPUARCH" "Dv MACHINE_ARCH"
2677b692b8eSWarner Losh.It Dv MACHINE Ta Dv MACHINE_CPUARCH Ta Dv MACHINE_ARCH
2687b692b8eSWarner Losh.It arm64 Ta aarch64 Ta aarch64
2697b692b8eSWarner Losh.It amd64 Ta amd64 Ta amd64
27042fbb55dSEd Maste.It arm Ta arm Ta armv7
2717b692b8eSWarner Losh.It i386 Ta i386 Ta i386
2721bdb1aa4SBrandon Bergren.It powerpc Ta powerpc Ta powerpc, powerpcspe, powerpc64, powerpc64le
2731ca12bd9SJohn Baldwin.It riscv Ta riscv Ta riscv64
2747b692b8eSWarner Losh.El
275df9330b5SEd Maste.Ss Predefined Macros
276df9330b5SEd MasteThe compiler provides a number of predefined macros.
277df9330b5SEd MasteSome of these provide architecture-specific details and are explained below.
278df9330b5SEd MasteOther macros, including those required by the language standard, are not
279df9330b5SEd Masteincluded here.
280df9330b5SEd Maste.Pp
281df9330b5SEd MasteThe full set of predefined macros can be obtained with this command:
282df9330b5SEd Maste.Bd -literal -offset indent
2838e71e112SEd Mastecc -x c -dM -E /dev/null
284df9330b5SEd Maste.Ed
285df9330b5SEd Maste.Pp
286df9330b5SEd MasteCommon type size and endianness macros:
287ddc9d6e5SEd Maste.Bl -column -offset indent "BYTE_ORDER" "Meaning"
288df9330b5SEd Maste.It Sy Macro Ta Sy Meaning
289df9330b5SEd Maste.It Dv __LP64__ Ta 64-bit (8-byte) long and pointer, 32-bit (4-byte) int
290df9330b5SEd Maste.It Dv __ILP32__ Ta 32-bit (4-byte) int, long and pointer
291df9330b5SEd Maste.It Dv BYTE_ORDER Ta Either Dv BIG_ENDIAN or Dv LITTLE_ENDIAN .
2921859c867SKonstantin Belousov.Dv PDP11_ENDIAN
2931859c867SKonstantin Belousovis not used on
2941859c867SKonstantin Belousov.Fx .
295df9330b5SEd Maste.El
296df9330b5SEd Maste.Pp
297df9330b5SEd MasteArchitecture-specific macros:
298ddc9d6e5SEd Maste.Bl -column -offset indent "Architecture" "Predefined macros"
299df9330b5SEd Maste.It Sy Architecture Ta Sy Predefined macros
300f38b2297SIan Lepore.It aarch64     Ta Dv __aarch64__
301df9330b5SEd Maste.It amd64       Ta Dv __amd64__ , Dv __x86_64__
30213368c38SWarner Losh.It armv7       Ta Dv __arm__ , Dv __ARM_ARCH >= 7
303df9330b5SEd Maste.It i386        Ta Dv __i386__
304df9330b5SEd Maste.It powerpc     Ta Dv __powerpc__
305002cc1f9SJustin Hibbits.It powerpcspe  Ta Dv __powerpc__ , Dv __SPE__
306df9330b5SEd Maste.It powerpc64   Ta Dv __powerpc__ , Dv __powerpc64__
3071bdb1aa4SBrandon Bergren.It powerpc64le Ta Dv __powerpc__ , Dv __powerpc64__
308ca20f8ecSRuslan Bukin.It riscv64     Ta Dv __riscv , Dv __riscv_xlen == 64
309df9330b5SEd Maste.El
310f84d8f0cSEd Maste.Pp
311f84d8f0cSEd MasteCompilers may define additional variants of architecture-specific macros.
312f84d8f0cSEd MasteThe macros above are preferred for use in
313f84d8f0cSEd Maste.Fx .
314691e6ea8SWarner Losh.Ss Important Xr make 1 variables
315691e6ea8SWarner LoshMost of the externally settable variables are defined in the
316691e6ea8SWarner Losh.Xr build 7
317691e6ea8SWarner Loshman page.
318691e6ea8SWarner LoshThese variables are not otherwise documented and are used extensively
319691e6ea8SWarner Loshin the build system.
32015d641f0SJohn Baldwin.Bl -tag -width "MACHINE_CPUARCH"
32115d641f0SJohn Baldwin.It Dv MACHINE
3222e4b206fSJohn BaldwinRepresents the hardware platform.
323691e6ea8SWarner LoshThis is the same as the native platform's
324691e6ea8SWarner Losh.Xr uname 1
325691e6ea8SWarner Losh.Fl m
326691e6ea8SWarner Loshoutput.
327691e6ea8SWarner LoshIt defines both the userland / kernel interface, as well as the
328691e6ea8SWarner Loshbootloader / kernel interface.
329691e6ea8SWarner LoshIt should only be used in these contexts.
330691e6ea8SWarner LoshEach CPU architecture may have multiple hardware platforms it supports
331691e6ea8SWarner Loshwhere
332691e6ea8SWarner Losh.Dv MACHINE
333691e6ea8SWarner Loshdiffers among them.
334691e6ea8SWarner LoshIt is used to collect together all the files from
335691e6ea8SWarner Losh.Xr config 8
336691e6ea8SWarner Loshto build the kernel.
337691e6ea8SWarner LoshIt is often the same as
338691e6ea8SWarner Losh.Dv MACHINE_ARCH
339691e6ea8SWarner Loshjust as one CPU architecture can be implemented by many different
340691e6ea8SWarner Loshhardware platforms, one hardware platform may support multiple CPU
341691e6ea8SWarner Losharchitecture family members, though with different binaries.
342691e6ea8SWarner LoshFor example,
343691e6ea8SWarner Losh.Dv MACHINE
344691e6ea8SWarner Loshof i386 supported the IBM-AT hardware platform while the
345691e6ea8SWarner Losh.Dv MACHINE
346691e6ea8SWarner Loshof pc98 supported the Japanese company NEC's PC-9801 and PC-9821
347691e6ea8SWarner Loshhardware platforms.
348691e6ea8SWarner LoshBoth of these hardware platforms supported only the
349691e6ea8SWarner Losh.Dv MACHINE_ARCH
350691e6ea8SWarner Loshof i386 where they shared a common ABI, except for certain kernel /
351691e6ea8SWarner Loshuserland interfaces relating to underlying hardware platform
352691e6ea8SWarner Loshdifferences in bus architecture, device enumeration and boot interface.
353ffab3cb6SWarner LoshGenerally,
354ffab3cb6SWarner Losh.Dv MACHINE
355*1a88a6b5SMaxim Konovalovshould only be used in src/sys and src/stand or in system imagers or
356ffab3cb6SWarner Loshinstallers.
35715d641f0SJohn Baldwin.It Dv MACHINE_ARCH
35815d641f0SJohn BaldwinRepresents the CPU processor architecture.
359691e6ea8SWarner LoshThis is the same as the native platforms
360691e6ea8SWarner Losh.Xr uname 1
361691e6ea8SWarner Losh.Fl p
362691e6ea8SWarner Loshoutput.
363691e6ea8SWarner LoshIt defines the CPU instruction family supported.
364691e6ea8SWarner LoshIt may also encode a variation in the byte ordering of multi-byte
365691e6ea8SWarner Loshintegers (endian).
366691e6ea8SWarner LoshIt may also encode a variation in the size of the integer or pointer.
367691e6ea8SWarner LoshIt may also encode a ISA revision.
368691e6ea8SWarner LoshIt may also encode hard versus soft floating point ABI and usage.
369320bd864SWarner LoshIt may also encode a variant ABI when the other factors do not
3706dcd6d19SJohn Baldwinuniquely define the ABI.
371691e6ea8SWarner LoshIt, along with
372320bd864SWarner Losh.Dv MACHINE ,
373320bd864SWarner Loshdefines the ABI used by the system.
374691e6ea8SWarner LoshGenerally, the plain CPU name specifies the most common (or at least
375691e6ea8SWarner Loshfirst) variant of the CPU.
37660f098f8SWarner LoshThis is why powerpc and powerpc64 imply 'big endian' while armv7 and aarch64
377691e6ea8SWarner Loshimply little endian.
378691e6ea8SWarner LoshIf we ever were to support the so-called x32 ABI (using 32-bit
379691e6ea8SWarner Loshpointers on the amd64 architecture), it would most likely be encoded
380691e6ea8SWarner Loshas amd64-x32.
38160f098f8SWarner LoshIt is unfortunate that amd64 specifies the 64-bit evolution of the x86 platform
38260f098f8SWarner Losh(it matches the 'first rule') as almost everybody else uses x86_64.
38360f098f8SWarner LoshThe
38460f098f8SWarner Losh.Fx
38560f098f8SWarner Loshport was so early, it predated processor name standardization after Intel joined
38660f098f8SWarner Loshthe market.
38760f098f8SWarner LoshAt the time, each OS selected its own conventions.
38860f098f8SWarner LoshBackwards compatibility means it is not easy to change to the consensus name.
38915d641f0SJohn Baldwin.It Dv MACHINE_CPUARCH
39015d641f0SJohn BaldwinRepresents the source location for a given
391ffab3cb6SWarner Losh.Dv MACHINE_ARCH .
3927b692b8eSWarner LoshIt is generally the common prefix for all the MACHINE_ARCH that
3937b692b8eSWarner Loshshare the same implementation, though 'riscv' breaks this rule.
394bf1dea9bSWarner LoshWhile amd64 and i386 are closely related, MACHINE_CPUARCH is not x86
395bf1dea9bSWarner Loshfor them.
39655ed6718SBenedict ReuschlingThe
39755ed6718SBenedict Reuschling.Fx
39855ed6718SBenedict Reuschlingsource base supports amd64 and i386 with two
399bf1dea9bSWarner Loshdistinct source bases living in subdirectories named amd64 and i386
400bf1dea9bSWarner Losh(though behind the scenes there's some sharing that fits into this
401bf1dea9bSWarner Loshframework).
40215d641f0SJohn Baldwin.It Dv CPUTYPE
40315d641f0SJohn BaldwinSets the flavor of
404691e6ea8SWarner Losh.Dv MACHINE_ARCH
405691e6ea8SWarner Loshto build.
406691e6ea8SWarner LoshIt is used to optimize the build for a specific CPU / core that the
407691e6ea8SWarner Loshbinaries run on.
408098150fbSWarner LoshGenerally, this does not change the ABI, though it can be a fine line
409691e6ea8SWarner Loshbetween optimization for specific cases.
41015d641f0SJohn Baldwin.It Dv TARGET
41115d641f0SJohn BaldwinUsed to set
412098150fbSWarner Losh.Dv MACHINE
413098150fbSWarner Loshin the top level Makefile for cross building.
414691e6ea8SWarner LoshUnused outside of that scope.
415691e6ea8SWarner LoshIt is not passed down to the rest of the build.
416098150fbSWarner LoshMakefiles outside of the top level should not use it at all (though
417b7f2a457SMaxim Konovalovsome have their own private copy for historical reasons).
41815d641f0SJohn Baldwin.It Dv TARGET_ARCH
41915d641f0SJohn BaldwinUsed to set
420098150fbSWarner Losh.Dv MACHINE_ARCH
421098150fbSWarner Loshby the top level Makefile for cross building.
422691e6ea8SWarner LoshLike
42315d641f0SJohn Baldwin.Dv TARGET ,
42415d641f0SJohn Baldwinit is unused outside of that scope.
425691e6ea8SWarner Losh.El
426df9330b5SEd Maste.Sh SEE ALSO
427df9330b5SEd Maste.Xr src.conf 5 ,
428d41afb81SRobert Clausecker.Xr build 7 ,
429d41afb81SRobert Clausecker.Xr simd 7
430df9330b5SEd Maste.Sh HISTORY
431df9330b5SEd MasteAn
432df9330b5SEd Maste.Nm
433df9330b5SEd Mastemanual page appeared in
4342af3ea6bSEd Maste.Fx 11.1 .
435