llvm-ar.rst 12 KB

llvm-ar - LLVM archiver

SYNOPSIS

:program:`llvm-ar` [-]{dmpqrstx}[abcDilLNoOPsSTuUvV] [relpos] [count] archive [files...]

DESCRIPTION

The :program:`llvm-ar` command is similar to the common Unix utility, :program:`ar`. It archives several files, such as objects and LLVM bitcode files into a single archive library that can be linked into a program. However, the archive can contain any kind of file. By default, :program:`llvm-ar` generates a symbol table that makes linking faster because only the symbol table needs to be consulted, not each individual file member of the archive.

The :program:`llvm-ar` command can be used to read archive files in SVR4, GNU, BSD and Darwin format, and write in the GNU, BSD, and Darwin style archive files. If an SVR4 format archive is used with the :option:`r` (replace), :option:`d` (delete), :option:`m` (move) or :option:`q` (quick update) operations, the archive will be reconstructed in the format defined by :option:`--format`.

Here's where :program:`llvm-ar` departs from previous :program:`ar` implementations:

The following option is not supported

[f] - truncate inserted filenames

The following options are ignored for compatibility

--plugin=<string> - load a plugin which adds support for other file formats

[l] - ignored in :program:`ar`

Symbol Table

Since :program:`llvm-ar` supports bitcode files, the symbol table it creates includes both native and bitcode symbols.

Deterministic Archives

By default, :program:`llvm-ar` always uses zero for timestamps and UIDs/GIDs to write archives in a deterministic mode. This is equivalent to the :option:`D` modifier being enabled by default. If you wish to maintain compatibility with other :program:`ar` implementations, you can pass the :option:`U` modifier to write actual timestamps and UIDs/GIDs.

Windows Paths

When on Windows :program:`llvm-ar` treats the names of archived files in the same case sensitive manner as the operating system. When on a non-Windows machine :program:`llvm-ar` does not consider character case.

OPTIONS

:program:`llvm-ar` operations are compatible with other :program:`ar` implementations. However, there are a few modifiers (:option:`L`) that are not found in other :program:`ar` implementations. The options for :program:`llvm-ar` specify a single basic Operation to perform on the archive, a variety of Modifiers for that Operation, the name of the archive file, and an optional list of file names. If the files option is not specified, it generally means either "none" or "all" members, depending on the operation. The Options, Operations and Modifiers are explained in the sections below.

The minimal set of options is at least one operator and the name of the archive.

Operations

t[v] .. option:: t [vO]

Print the table of contents. Without any modifiers, this operation just prints the names of the members to the standard output stream. With the :option:`v` modifier, :program:`llvm-ar` also prints out the file type (B=bitcode, S=symbol table, blank=regular file), the permission mode, the owner and group, are ignored when extracting files and set to placeholder values when adding size, and the date. With the :option:`O` modifier, display member offsets. If any files are specified, the listing is only for those files. If no files are specified, the table of contents for the whole archive is printed.

Modifiers (operation specific)

The modifiers below are specific to certain operations. See the Operations section to determine which modifiers are applicable to which operations.

Modifiers (generic)

The modifiers below may be applied to any operation.

Other

MRI SCRIPTS

:program:`llvm-ar` understands a subset of the MRI scripting interface commonly supported by archivers following in the ar tradition. An MRI script contains a sequence of commands to be executed by the archiver. The :option:`-M` option allows for an MRI script to be passed to :program:`llvm-ar` through the standard input stream.

Note that :program:`llvm-ar` has known limitations regarding the use of MRI scripts:

  • Each script can only create one archive.
  • Existing archives can not be modified.

MRI Script Commands

Each command begins with the command's name and must appear on its own line. Some commands have arguments, which must be separated from the name by whitespace. An MRI script should begin with either a :option:`CREATE` or :option:`CREATETHIN` command and will typically end with a :option:`SAVE` command. Any text after either '*' or ';' is treated as a comment.

EXIT STATUS

If :program:`llvm-ar` succeeds, it will exit with 0. Otherwise, if an error occurs, it will exit with a non-zero value.