LLVM-AR(1)

๐Ÿ“ฆ version 23.1.3, in centos-stream 9

๐ŸŽ€ llvm-ar โ€” LLVM-AR(1), from LLVM ๐ŸŽ€

๐Ÿ’– NAME ๐Ÿ’–

llvm-ar โ€” the LLVM archiver, periodt.

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

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

๐Ÿ’… DESCRIPTION ๐Ÿ’…

okay so bestie, the llvm-ar command is similar to the common Unix utility, ar. It archives several files, such as objects and LLVM bitcode files, into a single archive library that can be linked into a program. But here's the gag: the archive can contain any kind of file. By default, 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. iconic behavior, honestly.

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

Here's where llvm-ar departs from previous ar implementations โ€” pay attention, bestie:

๐Ÿšซ The following option is not supported ๐Ÿšซ

  • [f] โ€” truncate inserted filenames. yeah, this one is not supported, so don't even try it ๐Ÿ’€

๐Ÿ™ˆ The following options are ignored for compatibility ๐Ÿ™ˆ

  • --plugin=<string> โ€” load a plugin which adds support for other file formats. it's ignored for compatibility, so it's just vibing there ๐Ÿ™ˆ
  • [l] โ€” ignored in ar. that's the whole note, bestie.

๐Ÿ”ฎ Symbol Table ๐Ÿ”ฎ

Since llvm-ar supports bitcode files, the symbol table it creates includes both native and bitcode symbols. both kinds, slay โœจ

๐Ÿงš Deterministic Archives ๐Ÿงš

By default, llvm-ar always uses zero for timestamps and UIDs/GIDs to write archives in a deterministic mode. This is equivalent to the D modifier being enabled by default. If you wish to maintain compatibility with other ar implementations, you can pass the U modifier to write actual timestamps and UIDs/GIDs. so D is the default vibe, and U is the "give me the real timestamps and UIDs/GIDs" modifier ๐Ÿซถ

๐ŸชŸ Windows Paths ๐ŸชŸ

When on Windows, llvm-ar treats the names of archived files in the same case sensitive manner as the operating system. When on a non-Windows machine, llvm-ar does not consider character case. case sensitivity really said "it depends on the OS" ๐Ÿ˜ญ

โœจ OPTIONS โœจ

Okay bestie, so here's the tea โ˜• โ€” the operations in llvm-ar play nice with other ar implementations. Like, they're compatible. Except there's a couple of modifiers (hi L ๐Ÿ‘‹) that you literally won't find anywhere else. The options for llvm-ar are basically: one single basic Operation to do the thing, a bunch of Modifiers that tweak that Operation, the name of the archive file, and then optionally a list of file names. If you don't specify the files option, that generally means either "none" or "all" members โ€” depends on the operation you picked. All the deets on Options, Operations and Modifiers are in the sections below ๐Ÿ‘‡

The minimal set of options is at least one operator and the name of the archive. That's the bare minimum, no cap.


๐Ÿ› ๏ธ Operations ๐Ÿ› ๏ธ

  • d [NT] โ€” Delete files from the archive. The N and T modifiers apply here. The files options specify which members should be removed from the archive. It is not an error if a specified file doesn't appear in the archive, so don't stress ๐Ÿ’…. If no files are specified, the archive is not modified.
  • m [abi] โ€” Move files from one location in the archive to another. The a, b, and i modifiers apply to this operation. The files will all be moved to the location given by the modifiers. If no modifiers are used, the files get moved to the end of the archive. If no files are specified, the archive is not modified.
  • p [v] โ€” Print files to the standard output stream. If no files are specified, the entire archive is printed. With the v modifier, llvm-ar also prints out the name of the file being output. Printing binary files is ill-advised as they might confuse your terminal settings ๐Ÿ˜ญ. The p operation never modifies the archive โ€” it's a look-don't-touch situation.
  • q [LT] โ€” Quickly append files to the end of the archive without removing duplicates. If no files are specified, the archive is not modified. The behavior when appending one archive to another depends upon whether the L and T modifiers are used:
    • Appending a regular archive to a regular archive will append the archive file. If the L modifier is specified the members will be appended instead.
    • Appending a regular archive to a thin archive requires the T modifier and will append the archive file. The L modifier is not supported.
    • Appending a thin archive to a regular archive will append the archive file. If the L modifier is specified the members will be appended instead.
    • Appending a thin archive to a thin archive will always quick append its members.
  • r [abTu] โ€” Replace existing files or insert them at the end of the archive if they don't exist. The a, b, T and u modifiers apply to this operation. If no files are specified, the archive is not modified.
  • t (t[v], 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 v modifier, 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 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. ๐Ÿ‘‘
  • V โ€” A synonym for the --version option.
  • x [oPN] โ€” Extract archive members back to files. The o and N modifiers apply to this operation. This operation retrieves the indicated files from the archive and writes them back to the operating system's file system. If no files are specified, the entire archive is extracted. Very "unpacking my whole personality" energy ๐ŸŽ€

๐ŸŽ€ Modifiers (operation specific) ๐ŸŽ€

These modifiers below are specific to certain operations. Peep the Operations section to figure out which modifiers are applicable to which operations, iykyk.

  • a โ€” When inserting or moving member files, this option specifies the destination of the new files as being after the relpos member. If relpos is not found, the files are placed at the end of the archive. relpos cannot be consumed without either a, b or i.
  • b โ€” When inserting or moving member files, this option specifies the destination of the new files as being before the relpos member. If relpos is not found, the files are placed at the end of the archive. relpos cannot be consumed without either a, b or i. This modifier is identical to the i modifier.
  • i โ€” A synonym for the b option. Twins fr ๐Ÿ’–
  • L โ€” When quick appending an archive, instead quick append its members. This is a feature for llvm-ar that is not found in gnu-ar โ€” main character exclusive โœจ
  • N โ€” When extracting or deleting a member that shares its name with another member, the count parameter allows you to supply a positive whole number that selects the instance of the given name, with "1" indicating the first instance. If N is not specified the first member of that name will be selected. If count is not supplied, the operation fails. count cannot be consumed without either x or d.
  • o โ€” When extracting files, use the modification times of any files as they appear in the archive. By default files extracted from the archive use the time of extraction.
  • O โ€” Display member offsets inside the archive.
  • T โ€” Alias for --thin. Heads up though: in many ar implementations T has a different meaning, as specified by X/Open System interface. ๐Ÿ™ˆ
  • v โ€” When printing files or the archive table of contents, this modifier instructs llvm-ar to include additional information in the output. Verbose era ๐Ÿ’…

๐ŸŒธ Modifiers (generic) ๐ŸŒธ

The modifiers below may be applied to any operation. Universal besties ๐Ÿซถ

  • c โ€” For the r (replace) and q (quick update) operations, llvm-ar will always create the archive if it doesn't exist. Normally, llvm-ar will print a warning message indicating that the archive is being created. Using this modifier turns off that warning. Shhh ๐Ÿคซ
  • D โ€” Use zero for timestamps and UIDs/GIDs. This is set by default.
  • P โ€” Use full paths when matching member names rather than just the file name. This can be useful when manipulating an archive generated by another archiver, as some allow paths as member names. This is the default behavior for thin archives.
  • s โ€” This modifier requests that an archive index (or symbol table) be added to the archive, as if using ranlib. The symbol table will contain all the externally visible functions and global variables defined by all the bitcode files in the archive. By default llvm-ar generates symbol tables in archives. This can also be used as an operation.
  • S โ€” This modifier is the opposite of the s modifier. It instructs llvm-ar to not build the symbol table. If both s and S are used, the last modifier to occur in the options will prevail. Last one standing wins, periodt.
  • u โ€” Only update archive members with files that have more recent timestamps.
  • U โ€” Use actual timestamps and UIDs/GIDs.

๐Ÿฆ‹ Other ๐Ÿฆ‹

  • --format=<type> โ€” This option allows for default, gnu, darwin, bsd or coff <type> to be selected. When creating an archive with the default <type>, llvm-ar will attempt to infer it from the input files and fallback to the default toolchain target if unable to do so.
  • -h, --help โ€” Print a summary of command-line options and their meanings. Your little safety net ๐Ÿงš
  • -M โ€” This option allows for MRI scripts to be read through the standard input stream. No other options are compatible with this option. It's a one-option-only party.
  • --output=<dir> โ€” Specify a directory where archive members should be extracted to. By default the current working directory is used.
  • --rsp-quoting=<type> โ€” This option selects the quoting style <type> for response files, either posix or windows. The default when on Windows is windows, otherwise the default is posix.
  • --thin โ€” When creating or modifying an archive, this option specifies that the archive will be thin. By default, archives are not created as thin archives and when modifying a thin archive, it will be converted to a regular archive.
  • --version โ€” Display the version of the llvm-ar executable.
  • -X mode โ€” Specifies the type of object file llvm-ar will recognise. The mode must be one of the following:
    • 32 โ€” Process only 32-bit object files.
    • 64 โ€” Process only 64-bit object files.
    • 32_64 โ€” Process both 32-bit and 64-bit object files.
    • any โ€” Process all object files.

The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes ar to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable. So -X is the boss here ๐Ÿ‘‘

  • @<FILE> โ€” Read command-line options and commands from response file <FILE>.

๐Ÿ’œ MRI SCRIPTS ๐Ÿ’œ

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 -M option allows for an MRI script to be passed to llvm-ar through the standard input stream.

Okay but real talk, llvm-ar has known limitations regarding the use of MRI scripts, and you need to know them:

  • Each script can only create one archive.
  • Existing archives can not be modified. Nope. Not happening. ๐Ÿ™…โ€โ™€๏ธ

๐Ÿงš 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 CREATE or CREATETHIN command and will typically end with a SAVE command. Any text after either '*' or ';' is treated as a comment.

  • CREATE archive โ€” Begin creation of a regular archive with the specified name. Subsequent commands act upon this archive.
  • CREATETHIN archive โ€” Begin creation of a thin archive with the specified name. Subsequent commands act upon this archive.
  • ADDLIB archive โ€” Append the contents of archive to the current archive.
  • ADDMOD <file> โ€” Append <file> to the current archive.
  • DELETE <file> โ€” Delete the member of the current archive whose file name, excluding directory components, matches <file>.
  • SAVE โ€” Write the current archive to the path specified in the previous CREATE/CREATETHIN command.
  • END โ€” Ends the MRI script (optional).

๐Ÿ’… EXIT STATUS ๐Ÿ’…

okay bestie, the vibe check here is literally so simple:

  • 0 โ€” if llvm-ar succeeds, it exits with 0. slay. flawless. ate and left no crumbs. โœจ
  • non-zero โ€” if an error occurs, it exits with a non-zero value. that's your cue to go "๐Ÿ˜ญ" and go read what went wrong, ngl.
fr fr, don't sleep on that exit status โ€” it's the main character of your shell scripts. check it, respect it, iykyk. ๐Ÿซถ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Maintained by the LLVM Team (https://llvm.org/). iconic behavior, honestly โ€” they've been holding it down. ๐ŸŽ€


2003-2026, LLVM Project โ€” that's over two decades of lowkey legendary work, periodt. ๐Ÿ’œ


and that's the whole page, bestie!! ๐Ÿฆ‹๐ŸŒธ go forth and archive things with confidence. this was LLVM-AR(1), version 23, dated 2026-10-06 โ€” mwah ๐Ÿ’…โœจ๐Ÿ“

๐Ÿ“ฆ where this page comes from