]> git.saurik.com Git - apple/system_cmds.git/blame - arch.tproj/arch.1
system_cmds-880.60.2.tar.gz
[apple/system_cmds.git] / arch.tproj / arch.1
CommitLineData
b51d5b5f
A
1.\" Copyright (c) 1994 SigmaSoft, Th. Lockert
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by SigmaSoft, Th. Lockert.
15.\" 4. The name of the author may not be used to endorse or promote products
16.\" derived from this software without specific prior written permission
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28.\"
29.\" $OpenBSD: arch.1,v 1.2 1996/06/29 20:29:34 tholo Exp $
30.\"
31.\" Modifications made 8/20/97 (c) Apple Computer, Inc.
34d340d7 32.\" Modifications made 11/12/06 (c) Apple Computer, Inc.
b51d5b5f 33
8459d725 34.Dd July 8, 2010
b51d5b5f 35.Dt ARCH 1
34d340d7 36.Os "Mac OS X"
b51d5b5f
A
37.Sh NAME
38.Nm arch
34d340d7 39.Nd print architecture type or run selected architecture of a universal binary
b51d5b5f
A
40.Sh SYNOPSIS
41.Nm arch
34d340d7 42.Nm arch
8459d725
A
43.Op Fl 32
44.Op Fl 64
34d340d7
A
45.Oo
46.Oo Fl Ns Ar arch_name | Fl arch Ar arch_name Oc Ns ...
47.Oc
8459d725
A
48.Op Fl c
49.Oo Fl d Ar envname Oc Ns ...
50.Oo Fl e Ar envname=value Oc Ns ...
51.Op Fl h
34d340d7
A
52.Ar prog
53.Op Ar args No ...
b51d5b5f
A
54.Sh DESCRIPTION
55The
56.Nm arch
34d340d7
A
57command with no arguments, displays the machine's architecture type.
58.Pp
59The other use of the
60.Nm arch
d52496fd 61command is to run a selected architecture of a universal binary.
34d340d7
A
62A universal binary contains code that can run on different architectures.
63By default, the operating system will select the architecture that most closely
64matches the processor type.
ef8ad44b 65A 64-bit architecture is preferred over a 32-bit architecture on a 64-bit
34d340d7
A
66processor, while only 32-bit architectures can run on a 32-bit processor.
67.Pp
68When the most natural architecture is unavailable, the operating system will
69try to pick another architecture.
70On 64-bit processors, a 32-bit architecture is tried.
34d340d7
A
71Otherwise, no architecture is run, and an error results.
72.Pp
73The
74.Nm arch
ef8ad44b 75command can be used to alter the operating system's normal selection order.
34d340d7
A
76The most common use is to select the 32-bit architecture on a 64-bit processor,
77even if a 64-bit architecture is available.
78.Pp
79The
34d340d7
A
80.Ar arch_name
81argument must be one of the currently supported architectures:
c0bbac3a 82.Bl -tag -width x86_64h -offset indent
34d340d7
A
83.It i386
8432-bit intel
34d340d7
A
85.It x86_64
8664-bit intel
c0bbac3a
A
87.It x86_64h
8864-bit intel (haswell)
0813f9a6
A
89.It arm64
9064-bit arm
91.It arm64e
9264-bit arm (Apple Silicon)
34d340d7
A
93.El
94.Pp
0813f9a6
A
95If the binary does not contain code for
96.Ar arch_name ,
97the
98.Nm arch
99command may try to select a close match. If arm64 is specified and not found,
100arm64e will be tried next. If this happens, the order the architectures will
101be tried is not guaranteed.
102.Pp
34d340d7
A
103Either prefix the architecture with a hyphen, or (for compatibility with
104other commands), use
105.Fl arch
106followed by the architecture.
107.Pp
108If more than one architecture is specified, the operating system will try each
109one in order, skipping an architecture that is not supported on the current
110processor, or is unavailable in the universal binary.
111.Pp
8459d725
A
112The other options are:
113.Bl -tag -width ".Fl e Ar envname=value"
114.It Fl 32
115Add the native 32-bit architecture to the list of architectures.
116.It Fl 64
117Add the native 64-bit architecture to the list of architectures.
118.It Fl c
119Clears the environment that will be passed to the command to be run.
120.It Fl d Ar envname
121Deletes the named environment variable from the environment that will be passed
122to the command to be run.
123.It Fl e Ar envname=value
124Assigns the given value to the named environment variable in the environment
125that will be passed to the command to be run.
126Any existing environment variable with the same name will be replaced.
127.It Fl h
128Prints a usage message and exits.
129.El
130.Pp
34d340d7
A
131The
132.Ar prog
133argument is the command to run, followed by any arguments to pass to the
134command.
ef8ad44b 135It can be a full or partial path, while a lone name will be looked up in the user's
34d340d7
A
136command search path.
137.Pp
138If no architectures are specified on the command line, the
139.Nm arch
140command takes the basename of the
141.Ar prog
142argument and searches for the first property list file with that basename and
143the
144.Pa \&.plist
145suffix, in the
146.Pa archSettings
147sub-directory in each of the standard domains, in the following order:
148.Bl -tag -width ".Pa /Network/Library/archSettings" -offset indent
149.It ~/Library/archSettings
150User settings
151.It /Library/archSettings
152Local settings
153.It /Network/Library/archSettings
154Network settings
155.It /System/Library/archSettings
156System settings
157.El
158.Pp
159This property list contains the architecture order preferences, as well
160as the full path to the real executable.
161For examples of the property list format, look at the files in
162.Pa /System/Library/archSettings .
163.Ss Example
164On an intel processor:
165.Bd -literal -offset indent
166% perl -MConfig -e 'printf "%s\\n", $Config{byteorder}'
1671234
168.Ed
169.Pp
8459d725 170shows the intel little endian byte order.
34d340d7
A
171.Ss Making links to the arch command
172When a link is made to
173.Nm arch
174command with a different name, that name is used to find
175the corresponding property list file.
176Thus, other commands can be wrapped so that they have custom architecture
177selection order.
178.Pp
179Because of some internal logic in the code, hard links to the
180.Nm arch
181command may not work quite right.
182It is best to avoid using hard links, and only use symbolic links to the
183.Nm arch
184command.
185.Ss Environment
186The environment variable
187.Ev ARCHPREFERENCE
188can be used to provide architecture order preferences.
189It is checked before looking for the corresponding property list file.
190.Pp
191The value of the environment variable
192.Ev ARCHPREFERENCE
193is composed of one or more specifiers, separated by semicolons.
194A specifier is made up of one, two or three fields, separated by colons.
195Architectures specified in order, are separated by commas and make up the last
196(mandatory) field.
197The first field, if specified, is a name of a program, which selects this
198specifier if that name matches the program name in question.
199If the name field is empty or there is no name field, the specifier matches
200any program name.
201Thus, ordering of specifiers is important, and the one with no name should
202be last.
203.Pp
204When the
205.Nm arch
206command is called directly, the
207.Ar prog
208name provides the path information to the executable (possibly via the command
209search path).
210When a name is specified in a
211.Ev ARCHPREFERENCE
212specifier, the path information can alternately be specified as a second
213field following the name.
214When the
215.Nm arch
216command is called indirectly via a link, this path information must be
217specified.
218If not specified as a second field in a specifier, the executable path will
219be looked up in the corresponding property list file.
220.Ss Example ARCHPREFERENCE Values
221.Bl -tag -width " "
0813f9a6 222.It i386,x86_64,x86_64h,arm64,arm64e
34d340d7 223A specifier that matches any name.
0813f9a6 224.It foo:i386,x86_64,x86_64h,arm64,arm64e
34d340d7
A
225A specifier that matches the program named
226.Nm foo
227(the full executable path is in the
228.Pa foo.plist
229file).
0813f9a6 230.It foo:/op/bin/boo:i386,x86_64,x86_64h,arm64,arm64e
34d340d7 231A specifier with all fields specified.
0813f9a6 232.It baz:i386;x86_64;x86_64h,arm64,arm64e
34d340d7
A
233A specifier for
234.Nm baz
235and a second specifier that would match any other name.
236.El
237.Sh BUGS
238Running the
239.Nm arch
240command on an interpreter script may not work if the interpreter is a link
241to the arch command, especially if a 64-bit architecture is specified (since the
242.Nm arch
243command is 2-way universal, 32-bit only).
b51d5b5f
A
244.Sh SEE ALSO
245.Xr machine 1