LLVM-AR(1)

okay bestie, this is LLVM-AR(1) from the LLVM manual, and it’s literally the archiver page you didn’t know you needed πŸ’…βœ¨

🌸 NAME 🌸

llvm-ar β€” LLVM archiver. short, sweet, iconic 🫢

✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

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 bestie, the archive can contain any kind of file β€” it’s giving flexible. 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. periodt πŸ’…

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. slay πŸŽ€

here’s where llvm-ar departs from previous ar implementations, and this is the part where you go β€œoh πŸ‘€β€:

πŸ’€ The following option is not supported πŸ’€

  • [f] β€” truncate inserted filenames. not supported, bestie β€” she does not do this one πŸ™ˆ

😌 The following options are ignored for compatibility 😌

  • --plugin=<string> β€” load a plugin which adds support for other file formats. ignored for compatibility
  • [l] β€” ignored in ar.

🧚 Symbol Table 🧚

Since llvm-ar supports bitcode files, the symbol table it creates includes both native and bitcode symbols. no cap, that’s the tea β˜•

πŸŽ€ 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. highkey useful 🫢

🌈 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. that’s the vibe check βœ…

πŸ’… OPTIONS πŸ’…

okay so real talk β€” the way llvm-ar options work is genuinely compatible with other ar implementations, no cap. literally the only exception is a couple of modifiers (L) that you won't find anywhere else. here's the vibe: the options tell llvm-ar one single basic Operation to do to the archive, plus a bunch of Modifiers for that Operation, plus the name of the archive file, plus optionally a list of file names. and if you don't give the files option? it usually means either "none" or "all" members, depending on what operation you're doing. lowkey confusing but we get into it below. πŸ’–

the absolute minimum set of options is at least one operator and the name of the archive. that's it. that's the floor.


πŸ› οΈ Operations

  • d [NT] β€” Delete files from the archive. the N and T modifiers apply here. the files option tells you which members get yeeted from the archive. and ngl, it is not an error if a file you named isn't actually in the archive β€” it just vibes. if you specify no files at all, the archive isn't modified. 🫢
  • m [abi] β€” Move files from one location in the archive to another. the a, b, and i modifiers apply. all the files get moved to whatever location those modifiers point at. no modifiers? they all get moved to the end of the archive. no files specified? archive stays exactly as it was. ✨
  • p [v] β€” Print files to the standard output stream. no files specified means the entire archive gets printed. add the v modifier and llvm-ar also prints the name of the file it's outputting. > ⚠️ printing binary files is ill-advised β€” they might confuse your terminal settings, bestie, and your terminal does not deserve that. good news: the p operation never modifies the archive. ever.
  • q [LT] β€” Quickly append files to the end of the archive without removing duplicates. no files specified? archive not modified, periodt. now the behavior when you append one archive to another depends on whether you're using the L and T modifiers:
    • appending a regular archive to a regular archive will append the archive file. if the L modifier is specified, the members get 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 here.
    • appending a thin archive to a regular archive will append the archive file. if the L modifier is specified, the members get appended instead.
    • appending a thin archive to a thin archive will always quick append its members. always.
  • r [abTu] β€” Replace existing files, or insert them at the end of the archive if they don't exist yet. the a, b, T and u modifiers apply. no files specified means no modification. simple as that. πŸ¦‹
  • t [vO] β€” Print the table of contents. with no modifiers it 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 (ignored when extracting files and set to placeholder values when adding), the size, and the date. with the O modifier it displays member offsets. if you name files, the listing is only for those files. no files named? you get the table of contents for the whole archive. πŸ‘‘
πŸ™ˆ side quest: the rendered manpage literally shows this heading as t[v] .. option:: t [vO] β€” leftover rst crumbs. we love a messy queen.
  • V β€” a synonym for the --version option. that's it, that's the whole thing. ⭐
  • x [oP] β€” Extract archive members back to files. the o modifier applies. this operation pulls the indicated files out of the archive and writes them back to the operating system's file system. no files specified? the whole archive gets extracted. main character energy fr fr. 🌸

πŸŽ€ Modifiers (operation specific)

these modifiers below are specific to certain operations. peek at the Operations section above to figure out which modifiers go with which operations β€” they are not universal bestie.

  • a β€” when inserting or moving member files, this specifies the destination of the new files as being after the relpos member. if relpos isn't found, the files get placed at the end of the archive. and relpos cannot be consumed without either a, b or i.
  • b β€” when inserting or moving member files, this specifies the destination of the new files as being before the relpos member. if relpos isn't found, files go to the end of the archive. relpos cannot be consumed without either a, b or i. this modifier is literally identical to the i modifier.
  • i β€” a synonym for the b option. πŸ‘―
  • L β€” when quick appending an archive, quick append its members instead. this is a feature for llvm-ar that is not found in gnu-ar β€” so don't go looking for it there, iykyk.
  • N β€” when extracting or deleting a member that shares its name with another member, the count parameter lets you supply a positive whole number that selects the instance of the given name, with "1" meaning the first instance. if N isn't specified, the first member of that name gets selected. if count isn't supplied, the operation fails.
πŸ’€ heads up β€” the source page genuinely cuts off here mid-sentence: "count cannot be". that's all she wrote.
  • 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 instead.
  • O β€” display member offsets inside the archive.
  • T β€” alias for --thin. > ⚠️ in many ar implementations T means something totally different, as specified by X/Open System interface. so like, check which ar you're talking to, bestie.
  • v β€” when printing files or the archive table of contents, this modifier tells llvm-ar to include additional information in the output. more info = more ✨lore✨.

✨ Modifiers (generic)

these ones you can throw at any operation. universal slay. 🌈

  • 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 prints a warning message saying the archive is being created β€” using this modifier turns that warning off. silence is golden. πŸŽ€
  • 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, since some of them 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. it can also be used as an operation. πŸ‘‘
  • S β€” the opposite of the s modifier. it tells llvm-ar to not build the symbol table. if both s and S are used, the last modifier to occur in the options wins. farewell to the loser. πŸ’…
  • u β€” only update archive members with files that have more recent timestamps. no fresh timestamp, no update. πŸ•°οΈ
  • U β€” use actual timestamps and UIDs/GIDs.

🌟 Other

  • --format=<type> β€” this option lets you select default, gnu, darwin, bsd or coff as the <type>. when creating an archive with the default <type>, :program:llvm-ar will attempt to infer it from the input files and fall back to the default toolchain target if it's unable to do so. detective work, honestly. πŸ”
  • -h, --help β€” print a summary of command-line options and their meanings. the classic cry for help. 🫢
  • -M β€” this option lets MRI scripts be read through the standard input stream. > ⚠️ no other options are compatible with this one. it's a solo act, main character energy only.
  • --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. πŸͺŸ vs 🐧
  • --thin β€” when creating or modifying an archive, this option says the archive will be thin. by default archives are not created as thin archives, and when modifying a thin archive, it gets converted to a regular archive. (yes, it changes the vibe. be aware. πŸ’€)
  • --version β€” display the version of the llvm-ar executable.
  • -X mode β€” specifies the type of object file llvm-ar will recognise. mode must be one of these:
    • 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. and the -X flag overrides the OBJECT_MODE variable. flag wins, always. ⭐

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

🧚 MRI SCRIPTS 🧚

llvm-ar understands a subset of the MRI scripting interface that's commonly supported by archivers following in the ar tradition. an MRI script is just a sequence of commands for the archiver to execute, and the -M option lets you pass an MRI script to llvm-ar through the standard input stream. πŸŽ€

⚠️ but bestie, llvm-ar has known limitations with MRI scripts and you need to know them: - 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 sit 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. cute, right? πŸ’–

  • 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. the grand finale. πŸ‘‘
  • END β€” ends the MRI script. optional, but iconic. ✨

🫢 EXIT STATUS 🫢

if llvm-ar succeeds, it exits with 0. otherwise, if an error occurs, it exits with a non-zero value. that's the whole mood. πŸ’…

✨ AUTHOR ✨

So who's the main character behind all this? πŸ‘‘

This page is maintained by the LLVM Team β€” you can find them at https://llvm.org/ 🫢. That's it, that's the whole credit. They keep it alive, they keep it updated, and honestly? Slay. πŸ’…


The copyright line, verbatim, because legal stuff is not the vibe to freestyle:

2003-2025, LLVM Project

That's 2003-2025, LLVM Project β€” two decades-plus of tooling, no cap. πŸ—“οΈβœ¨


And that's the whole page, bestie! πŸ¦‹ You made it to the end, which means the vibe check is complete. πŸ’œ This was LLVM-AR from version 19, dated 2025-01-17 β€” screenshot it, bookmark it, tattoo it on your forearm, whatever works for you. πŸ˜­πŸ’–

Go archive something iconic. πŸŽ€πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from