lipo

create or operate on apple universal executables

lipo [-info] [-detailed_info]
[-verify_arch arch_type]
[-arch arch_type input_file][-arch_blank arch_type]
[-create]
[-thin arch_type]
[-replace arch_type filename][-remove arch_type]
[-extract arch_type][-extract_family arch_type]
[-segalign arch_type value] …                         [ input_file] …     [-output output_file]

Creates or operates on `universal' (multi-architecture) files.
Produces one output file, and idows not alter the input.

Only one option can be specified, with the exception of -arch, -arch_blank, -output, and -segalign, which are used in combination with other options.
The input_file is required, and only -create allows more than one input_file to be specified.
-output must be used, except with -info and -detailed_info .
The arch_type may be any of the supported architecture names listed in the man page arch(3).

-info Briefly list the architecture types in the input universal file (just the names of each architecture).
> lipo -info `which lipo`
Non-fat file: /Library/Developer/CommandLineTools/usr/bin/lipo is architecture: x86_64

> lipo -info `which arch`
Architectures in the fat file: /usr/bin/arch are: x86_64 i386 
-detailed_info Display list of the architecture types in the input universal file for each architecture in the file).
> lipo -detailed_info `which lipo`
input file /Library/Developer/CommandLineTools/usr/bin/lipo is not a fat file
Non-fat file: /Library/Developer/CommandLineTools/usr/bin/lipo is architecture: x86_64

> lipo -detailed_info `which arch`
Fat header in: /usr/bin/arch
fat_magic 0xcafebabe
nfat_arch 2
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    offset 4096
    size 30032
    align 2^12 (4096)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 36864
    size 29776
    align 2^12 (4096)

-arch arch_type input_file Input_file contains the architecture type,
unnecessary if input_file is an object file, a universal file,
-output output_file
Create options
-create create universal output file
-arch_blank arch_type output for the arch_type will be MH_DYLIB_STUB
only with -create.
-thin arch_type create a thin output file with arch_type.
-replace arch_type file replace the arch_type contents of the input file with the contents of filee.
-remove arch_type remove arch_type placing the result in the output file.
-extract arch_type extract arch_type into a universal output file containing only that architecture.
-extract_family arch_typeextract all arch_types for the family that arch_type is in into an output file containing only those architectures.
The file will be thin if only one architecture is found.
-verify_arch arch_type … If arch_types are present exit with a status of 0
-segalign arch_type value Set segment alignment of arch_type when creating a universal file containing that architecture.
Only needed when lipo can't determine the alignment of an file (currently not an object file), or when it determines the alignment too conservatively.
For archives 4-byte alignment, for unknown files 0 byte alignment

arch

run selected architecture of a universal binary or
outptut architecture type

arch [-32] [-64] [[-arch_name | -arch arch_name]] [-c] [-d envname][-e envname=value][-h]
          prog [args]

With no arguments, displays the machine's architecture type.

> arch
i386  or maybe arm64
> machine
i486 or maybe arm64e
> uname -m
x86_64 or maybe arm64
> uname -p
i386 or maybe arm

Alter the operating system's normal selection. Commonly, select the 32-bit architecture on a 64-bit processor, even if a 64-bit architecture is available. By default, the operating system will select the architecture that most closely matches the processor type.
A 64-bit architecture is preferred over 32-bit on a 64-bit processor, while only 32-bit architectures can run on a 32-bit processor.
When the most natural architecture is unavailable, the operating system picks another architecture.
On 64-bit processors, a 32-bit architecture is tried.
If this is also unavailable, the operating system on an intel processor will try running a 32-bit powerpc architecture.
Otherwise, no architecture is run, and an error results.

arch_name : -i386 | -x86_64 If more than one architecture is specified, the operating system will try each one in order, skipping an architecture that is not supported on the current processor, or is unavailable

-32 Add the native 32-bit architecture to the list of architectures.
-64 … 64 …
-c Clears the environment passed to the command .
-d envname Deletes the named environment variable
-e envname=value Assigns the value to envname to be run.
-h Help
Usage: arch
       Display the machine's architecture type
Usage: arch {-arch_name | -arch arch_name} ... [-c] [-d envname] ... [-e envname=value] ... [-h] prog [arg ...]
       Run prog with any arguments, using the given architecture
       order.  If no architectures are specified, use the
       ARCHPREFERENCE environment variable, or a property list file.
       -c will clear out all environment variables before running prog.
       -d will delete the given environment variable before running prog.
       -e will add the given environment variable/value before running prog.
       -h will print usage message and exit.
The prog is the command to run, followed by any arguments to pass to the command. It can be a full or partial path, while a lone name will be looked up in the user's command search path.

If no architectures are specified on the command line, the arch command takes the basename of the prog argument and searches for the first property list file with that basename and the .plist suffix, in the archSettings sub-directory in each of the standard domains, in the following order:

  1. ~/Library/archSettings User settings
  2. /Library/archSettings Local settings
  3. /Network/Library/archSettings Network settings
  4. /System/Library/archSettings System settings
This property list contains the architecture order preferences, as well as the full path to the real executable. For examples of the property list format, see /System/Library/archSettings. Example On an intel processor:
 % perl -MConfig -e 'printf "%s\n", $Config{byteorder}'
           1234
shows the intel little endian byte order.

Making links to arch

A link to arch with a different name, that name is used to find the corresponding property list file. Thus, other commands can be wrapped so that they have custom architecture selection order.

Because of some internal logic in the code, hard links to the arch command may not work quite right. It is best to avoid using hard links, and only use symbolic links to the arch command.

Environment

$ARCHPREFERENCE provides architecture order preferences. It is checked before looking for the corresponding property list file.
One or more specifiers, separated by semicolons. made up of one, two or three fields, separated by colons. Architectures specified in order, are separated by commas and make up the last (mandatory) field.
The first field, is a program, which selects this specifier if that name matches the program name in question.
empty or no name field, the specifier matches any program name.

When arch is called directly, the prog name provides the path information to the executable (possibly via the command search path). When a name is specified in a ARCHPREFERENCE specifier, the path information can alternately be specified as a sec- ond field following the name.

When the arch command is called indirectly via a link, this path information must be specified. If not specified as a second field in a specifier, the executable path will be looked up in the corresponding property list file.

Example ARCHPREFERENCE Values

matches any name. i386,x86_64
matches the program named foo (the full executable path is in the foo.plist file). foo:i386,x86_64
all fields specified. foo:/op/bin/boo:i386,x86_64
baz and a second specifier that would match any other name. baz:i386;x86_64