lipo - create or operate on universal files

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.

It only ever produces one output file, and never alters the input file.

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 a detailed list of the architecture types in the input universal file (all the the information in the universal header, 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 specified architecture type, unnecessary if input_file is an object file, a universal file,
-arch_blank arch_type output for the arch_type will be MH_DYLIB_STUB , may not be used with any operation other than -create.
-output output_file
-create create one universal output file
-thin arch_type create a thin output file with arch_type.
-replace arch_type file_name In the output file, replace the arch_type contents of the input file with the contents of the specified file_name.
-remove arch_type remove the arch_type placing the result in the output file.
-extract arch_type copy the arch_type into a universal output file containing only that architecture.
-extract_family arch_typecopy all of the 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 or universal otherwise.
-verify_arch arch_type ... verify arch_types are present . If so then exit with a status of 0 else 1.
-segalign arch_type value Set the segment alignment of the specified arch_type when creating a universal file containing that architecture.
value is a hexadecimal number, an integral power of 2.
Only needed when lipo can't figure out the alignment of an input file (currently not an object file), or when it guesses at the alignment too conservatively. The default for files unknown to lipo is 0 (2^0, or an alignment of one byte), and the default alignment for archives is 4 (2^2, or 4-byte alignment).

arch -- print architecture type or run selected architecture of a universal binary

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      say what?
/Users/dgerman > machine
i486
/Users/dgerman > uname -m
x86_64
/Users/dgerman > uname -p
i386

Run a selected architecture of a universal binary. contains code that can run on different architectures. 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 will try to pick 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 used to 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.

arch_name : i386 | x86_64 Either prefix the architecture with a hyphen or use -arch followed by the architecture. 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
-c Clears the environment that will be passed to the command to be run.
-d envname Deletes the named environment variable from the environment that will be passed to the command to be run.
-e envname=value Assigns the given value to the named environment variable in the environment that will be passed to the command to be run. Any existing environment variable with the same name will be replaced.
-h
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, look at the files in /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

When a link is made 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

The environment variable ARCHPREFERENCE can be used to provide architecture order preferences. It is checked before looking for the corresponding property list file.

The value of the environment variable ARCHPREFERENCE is composed of one or more specifiers, separated by semicolons. A specifier is 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, if specified, is a name of a program, which selects this specifier if that name matches the program name in question. If the name field is empty or there is no name field, the specifier matches any program name. Thus, ordering of specifiers is important, and the one with no name should be last.

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