llvm-ar.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. llvm-ar - LLVM archiver
  2. =======================
  3. .. program:: llvm-ar
  4. SYNOPSIS
  5. --------
  6. :program:`llvm-ar` [-]{dmpqrstx}[abcDilLNoOPsSTuUvV] [relpos] [count] archive [files...]
  7. DESCRIPTION
  8. -----------
  9. The :program:`llvm-ar` command is similar to the common Unix utility,
  10. :program:`ar`. It archives several files, such as objects and LLVM bitcode
  11. files into a single archive library that can be linked into a program. However,
  12. the archive can contain any kind of file. By default, :program:`llvm-ar`
  13. generates a symbol table that makes linking faster because only the symbol
  14. table needs to be consulted, not each individual file member of the archive.
  15. The :program:`llvm-ar` command can be used to *read* archive files in SVR4,
  16. GNU, BSD and Darwin format, and *write* in the GNU, BSD, and Darwin style
  17. archive files. If an SVR4 format archive is used with the :option:`r`
  18. (replace), :option:`d` (delete), :option:`m` (move) or :option:`q`
  19. (quick update) operations, the archive will be reconstructed in the format
  20. defined by :option:`--format`.
  21. Here's where :program:`llvm-ar` departs from previous :program:`ar`
  22. implementations:
  23. *The following option is not supported*
  24. [f] - truncate inserted filenames
  25. *The following options are ignored for compatibility*
  26. --plugin=<string> - load a plugin which adds support for other file formats
  27. [l] - ignored in :program:`ar`
  28. *Symbol Table*
  29. Since :program:`llvm-ar` supports bitcode files, the symbol table it creates
  30. includes both native and bitcode symbols.
  31. *Deterministic Archives*
  32. By default, :program:`llvm-ar` always uses zero for timestamps and UIDs/GIDs
  33. to write archives in a deterministic mode. This is equivalent to the
  34. :option:`D` modifier being enabled by default. If you wish to maintain
  35. compatibility with other :program:`ar` implementations, you can pass the
  36. :option:`U` modifier to write actual timestamps and UIDs/GIDs.
  37. *Windows Paths*
  38. When on Windows :program:`llvm-ar` treats the names of archived *files* in the same
  39. case sensitive manner as the operating system. When on a non-Windows machine
  40. :program:`llvm-ar` does not consider character case.
  41. OPTIONS
  42. -------
  43. :program:`llvm-ar` operations are compatible with other :program:`ar`
  44. implementations. However, there are a few modifiers (:option:`L`) that are not
  45. found in other :program:`ar` implementations. The options for
  46. :program:`llvm-ar` specify a single basic Operation to perform on the archive,
  47. a variety of Modifiers for that Operation, the name of the archive file, and an
  48. optional list of file names. If the *files* option is not specified, it
  49. generally means either "none" or "all" members, depending on the operation. The
  50. Options, Operations and Modifiers are explained in the sections below.
  51. The minimal set of options is at least one operator and the name of the
  52. archive.
  53. Operations
  54. ~~~~~~~~~~
  55. .. option:: d [NT]
  56. Delete files from the ``archive``. The :option:`N` and :option:`T` modifiers
  57. apply to this operation. The *files* options specify which members should be
  58. removed from the archive. It is not an error if a specified file does not
  59. appear in the archive. If no *files* are specified, the archive is not
  60. modified.
  61. .. option:: m [abi]
  62. Move files from one location in the ``archive`` to another. The :option:`a`,
  63. :option:`b`, and :option:`i` modifiers apply to this operation. The *files*
  64. will all be moved to the location given by the modifiers. If no modifiers are
  65. used, the files will be moved to the end of the archive. If no *files* are
  66. specified, the archive is not modified.
  67. .. option:: p [v]
  68. Print *files* to the standard output stream. If no *files* are specified, the
  69. entire ``archive`` is printed. With the :option:`v` modifier,
  70. :program:`llvm-ar` also prints out the name of the file being output. Printing
  71. binary files is ill-advised as they might confuse your terminal settings. The
  72. :option:`p` operation never modifies the archive.
  73. .. option:: q [LT]
  74. Quickly append files to the end of the ``archive`` without removing
  75. duplicates. If no *files* are specified, the archive is not modified. The
  76. behavior when appending one archive to another depends upon whether the
  77. :option:`L` and :option:`T` modifiers are used:
  78. * Appending a regular archive to a regular archive will append the archive
  79. file. If the :option:`L` modifier is specified the members will be appended
  80. instead.
  81. * Appending a regular archive to a thin archive requires the :option:`T`
  82. modifier and will append the archive file. The :option:`L` modifier is not
  83. supported.
  84. * Appending a thin archive to a regular archive will append the archive file.
  85. If the :option:`L` modifier is specified the members will be appended
  86. instead.
  87. * Appending a thin archive to a thin archive will always quick append its
  88. members.
  89. .. option:: r [abTu]
  90. Replace existing *files* or insert them at the end of the ``archive`` if
  91. they do not exist. The :option:`a`, :option:`b`, :option:`T` and :option:`u`
  92. modifiers apply to this operation. If no *files* are specified, the archive
  93. is not modified.
  94. t[v]
  95. .. option:: t [vO]
  96. Print the table of contents. Without any modifiers, this operation just prints
  97. the names of the members to the standard output stream. With the :option:`v`
  98. modifier, :program:`llvm-ar` also prints out the file type (B=bitcode,
  99. S=symbol table, blank=regular file), the permission mode, the owner and group,
  100. are ignored when extracting *files* and set to placeholder values when adding
  101. size, and the date. With the :option:`O` modifier, display member offsets. If
  102. any *files* are specified, the listing is only for those files. If no *files*
  103. are specified, the table of contents for the whole archive is printed.
  104. .. option:: V
  105. A synonym for the :option:`--version` option.
  106. .. option:: x [oP]
  107. Extract ``archive`` members back to files. The :option:`o` modifier applies
  108. to this operation. This operation retrieves the indicated *files* from the
  109. archive and writes them back to the operating system's file system. If no
  110. *files* are specified, the entire archive is extracted.
  111. Modifiers (operation specific)
  112. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113. The modifiers below are specific to certain operations. See the Operations
  114. section to determine which modifiers are applicable to which operations.
  115. .. option:: a
  116. When inserting or moving member files, this option specifies the destination
  117. of the new files as being after the *relpos* member. If *relpos* is not found,
  118. the files are placed at the end of the ``archive``. *relpos* cannot be
  119. consumed without either :option:`a`, :option:`b` or :option:`i`.
  120. .. option:: b
  121. When inserting or moving member files, this option specifies the destination
  122. of the new files as being before the *relpos* member. If *relpos* is not
  123. found, the files are placed at the end of the ``archive``. *relpos* cannot
  124. be consumed without either :option:`a`, :option:`b` or :option:`i`. This
  125. modifier is identical to the :option:`i` modifier.
  126. .. option:: i
  127. A synonym for the :option:`b` option.
  128. .. option:: L
  129. When quick appending an ``archive``, instead quick append its members. This
  130. is a feature for :program:`llvm-ar` that is not found in gnu-ar.
  131. .. option:: N
  132. When extracting or deleting a member that shares its name with another member,
  133. the *count* parameter allows you to supply a positive whole number that
  134. selects the instance of the given name, with "1" indicating the first
  135. instance. If :option:`N` is not specified the first member of that name will
  136. be selected. If *count* is not supplied, the operation fails.*count* cannot be
  137. .. option:: o
  138. When extracting files, use the modification times of any *files* as they
  139. appear in the ``archive``. By default *files* extracted from the archive
  140. use the time of extraction.
  141. .. option:: O
  142. Display member offsets inside the archive.
  143. .. option:: T
  144. When creating or modifying an archive, this option specifies that the
  145. ``archive`` will be thin. By default, archives are not created as thin
  146. archives and when modifying a thin archive, it will be converted to a regular
  147. archive.
  148. .. option:: v
  149. When printing *files* or the ``archive`` table of contents, this modifier
  150. instructs :program:`llvm-ar` to include additional information in the output.
  151. Modifiers (generic)
  152. ~~~~~~~~~~~~~~~~~~~
  153. The modifiers below may be applied to any operation.
  154. .. option:: c
  155. For the :option:`r` (replace)and :option:`q` (quick update) operations,
  156. :program:`llvm-ar` will always create the archive if it doesn't exist.
  157. Normally, :program:`llvm-ar` will print a warning message indicating that the
  158. ``archive`` is being created. Using this modifier turns off
  159. that warning.
  160. .. option:: D
  161. Use zero for timestamps and UIDs/GIDs. This is set by default.
  162. .. option:: P
  163. Use full paths when matching member names rather than just the file name.
  164. This can be useful when manipulating an ``archive`` generated by another
  165. archiver, as some allow paths as member names. This is the default behavior
  166. for thin archives.
  167. .. option:: s
  168. This modifier requests that an archive index (or symbol table) be added to the
  169. ``archive``, as if using ranlib. The symbol table will contain all the
  170. externally visible functions and global variables defined by all the bitcode
  171. files in the archive. By default :program:`llvm-ar` generates symbol tables in
  172. archives. This can also be used as an operation.
  173. .. option:: S
  174. This modifier is the opposite of the :option:`s` modifier. It instructs
  175. :program:`llvm-ar` to not build the symbol table. If both :option:`s` and
  176. :option:`S` are used, the last modifier to occur in the options will prevail.
  177. .. option:: u
  178. Only update ``archive`` members with *files* that have more recent
  179. timestamps.
  180. .. option:: U
  181. Use actual timestamps and UIDs/GIDs.
  182. Other
  183. ~~~~~
  184. .. option:: --format=<type>
  185. This option allows for default, gnu, darwin or bsd ``<type>`` to be selected.
  186. When creating an ``archive``, ``<type>`` will default to that of the host
  187. machine.
  188. .. option:: -h, --help
  189. Print a summary of command-line options and their meanings.
  190. .. option:: -M
  191. This option allows for MRI scripts to be read through the standard input
  192. stream. No other options are compatible with this option.
  193. .. option:: --version
  194. Display the version of the :program:`llvm-ar` executable.
  195. .. option:: @<FILE>
  196. Read command-line options and commands from response file ``<FILE>``.
  197. MRI SCRIPTS
  198. -----------
  199. :program:`llvm-ar` understands a subset of the MRI scripting interface commonly
  200. supported by archivers following in the ar tradition. An MRI script contains a
  201. sequence of commands to be executed by the archiver. The :option:`-M` option
  202. allows for an MRI script to be passed to :program:`llvm-ar` through the
  203. standard input stream.
  204. Note that :program:`llvm-ar` has known limitations regarding the use of MRI
  205. scripts:
  206. * Each script can only create one archive.
  207. * Existing archives can not be modified.
  208. MRI Script Commands
  209. ~~~~~~~~~~~~~~~~~~~
  210. Each command begins with the command's name and must appear on its own line.
  211. Some commands have arguments, which must be separated from the name by
  212. whitespace. An MRI script should begin with either a :option:`CREATE` or
  213. :option:`CREATETHIN` command and will typically end with a :option:`SAVE`
  214. command. Any text after either '*' or ';' is treated as a comment.
  215. .. option:: CREATE archive
  216. Begin creation of a regular archive with the specified name. Subsequent
  217. commands act upon this ``archive``.
  218. .. option:: CREATETHIN archive
  219. Begin creation of a thin archive with the specified name. Subsequent
  220. commands act upon this ``archive``.
  221. .. option:: ADDLIB archive
  222. Append the contents of ``archive`` to the current archive.
  223. .. option:: ADDMOD <file>
  224. Append ``<file>`` to the current archive.
  225. .. option:: DELETE <file>
  226. Delete the member of the current archive whose file name, excluding directory
  227. components, matches ``<file>``.
  228. .. option:: SAVE
  229. Write the current archive to the path specified in the previous
  230. :option:`CREATE`/:option:`CREATETHIN` command.
  231. .. option:: END
  232. Ends the MRI script (optional).
  233. EXIT STATUS
  234. -----------
  235. If :program:`llvm-ar` succeeds, it will exit with 0. Otherwise, if an error occurs, it
  236. will exit with a non-zero value.