]> git.saurik.com Git - apple/system_cmds.git/blame - arch.tproj/arch.1
system_cmds-433.8.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
34d340d7 34.Dd November 12, 2006
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
A
42.Nm arch
43.Op Fl h
44.Oo
45.Oo Fl Ns Ar arch_name | Fl arch Ar arch_name Oc Ns ...
46.Oc
47.Ar prog
48.Op Ar args No ...
b51d5b5f
A
49.Sh DESCRIPTION
50The
51.Nm arch
34d340d7
A
52command with no arguments, displays the machine's architecture type.
53.Pp
54The other use of the
55.Nm arch
56command it to run a selected architecture of a universal binary.
57A universal binary contains code that can run on different architectures.
58By default, the operating system will select the architecture that most closely
59matches the processor type.
60This means that an intel architecture is selected on intel processors and a
61powerpc architecture is selected on powerpc processors.
62A 64-bit architecuture is preferred over a 32-bit architecture on a 64-bit
63processor, while only 32-bit architectures can run on a 32-bit processor.
64.Pp
65When the most natural architecture is unavailable, the operating system will
66try to pick another architecture.
67On 64-bit processors, a 32-bit architecture is tried.
68If this is also unavailable, the operating system on an intel processor will
69try running a 32-bit powerpc architecture.
70Otherwise, no architecture is run, and an error results.
71.Pp
72The
73.Nm arch
74command can be use to alter the operating system's normal selection order.
75The most common use is to select the 32-bit architecture on a 64-bit processor,
76even if a 64-bit architecture is available.
77.Pp
78The
79.Fl h
80option prints a usage message and exits.
81.Pp
82The
83.Ar arch_name
84argument must be one of the currently supported architectures:
85.Bl -tag -width x86_64 -offset indent
86.It i386
8732-bit intel
88.It ppc
8932-bit powerpc
90.It ppc64
9164-bit powerpc
92.It x86_64
9364-bit intel
94.El
95.Pp
96Either prefix the architecture with a hyphen, or (for compatibility with
97other commands), use
98.Fl arch
99followed by the architecture.
100.Pp
101If more than one architecture is specified, the operating system will try each
102one in order, skipping an architecture that is not supported on the current
103processor, or is unavailable in the universal binary.
104.Pp
105The
106.Ar prog
107argument is the command to run, followed by any arguments to pass to the
108command.
109It can be a full or partial path, while a lone name will be lookup in the user's
110command search path.
111.Pp
112If no architectures are specified on the command line, the
113.Nm arch
114command takes the basename of the
115.Ar prog
116argument and searches for the first property list file with that basename and
117the
118.Pa \&.plist
119suffix, in the
120.Pa archSettings
121sub-directory in each of the standard domains, in the following order:
122.Bl -tag -width ".Pa /Network/Library/archSettings" -offset indent
123.It ~/Library/archSettings
124User settings
125.It /Library/archSettings
126Local settings
127.It /Network/Library/archSettings
128Network settings
129.It /System/Library/archSettings
130System settings
131.El
132.Pp
133This property list contains the architecture order preferences, as well
134as the full path to the real executable.
135For examples of the property list format, look at the files in
136.Pa /System/Library/archSettings .
137.Ss Example
138On an intel processor:
139.Bd -literal -offset indent
140% perl -MConfig -e 'printf "%s\\n", $Config{byteorder}'
1411234
142.Ed
143.Pp
144shows the intel little endian byte order, while:
145.Bd -literal -offset indent
146% arch -ppc perl -MConfig -e 'printf "%s\\n", $Config{byteorder}'
1474321
148.Ed
149.Pp
150runs the powerpc architecture, and displays big endian byte order.
151.Ss Making links to the arch command
152When a link is made to
153.Nm arch
154command with a different name, that name is used to find
155the corresponding property list file.
156Thus, other commands can be wrapped so that they have custom architecture
157selection order.
158.Pp
159Because of some internal logic in the code, hard links to the
160.Nm arch
161command may not work quite right.
162It is best to avoid using hard links, and only use symbolic links to the
163.Nm arch
164command.
165.Ss Environment
166The environment variable
167.Ev ARCHPREFERENCE
168can be used to provide architecture order preferences.
169It is checked before looking for the corresponding property list file.
170.Pp
171The value of the environment variable
172.Ev ARCHPREFERENCE
173is composed of one or more specifiers, separated by semicolons.
174A specifier is made up of one, two or three fields, separated by colons.
175Architectures specified in order, are separated by commas and make up the last
176(mandatory) field.
177The first field, if specified, is a name of a program, which selects this
178specifier if that name matches the program name in question.
179If the name field is empty or there is no name field, the specifier matches
180any program name.
181Thus, ordering of specifiers is important, and the one with no name should
182be last.
183.Pp
184When the
185.Nm arch
186command is called directly, the
187.Ar prog
188name provides the path information to the executable (possibly via the command
189search path).
190When a name is specified in a
191.Ev ARCHPREFERENCE
192specifier, the path information can alternately be specified as a second
193field following the name.
194When the
195.Nm arch
196command is called indirectly via a link, this path information must be
197specified.
198If not specified as a second field in a specifier, the executable path will
199be looked up in the corresponding property list file.
200.Ss Example ARCHPREFERENCE Values
201.Bl -tag -width " "
202.It ppc,i386,ppc64,x86_64
203A specifier that matches any name.
204.It foo:ppc,i386,ppc64,x86_64
205A specifier that matches the program named
206.Nm foo
207(the full executable path is in the
208.Pa foo.plist
209file).
210.It foo:/op/bin/boo:ppc,i386,ppc64,x86_64
211A specifier with all fields specified.
212.It baz:ppc,i386;i386,ppc
213A specifier for
214.Nm baz
215and a second specifier that would match any other name.
216.El
217.Sh BUGS
218Running the
219.Nm arch
220command on an interpreter script may not work if the interpreter is a link
221to the arch command, especially if a 64-bit architecture is specified (since the
222.Nm arch
223command is 2-way universal, 32-bit only).
b51d5b5f
A
224.Sh SEE ALSO
225.Xr machine 1