2
2
Fork
You've already forked Zar
0
LLvm-ar clone in Zig
  • C 81.8%
  • Zig 16.6%
  • C++ 1%
  • Assembly 0.6%
2026年05月09日 23:13:45 +02:00
src Add MoveOperation and RanLib Test 2026年05月09日 23:13:45 +02:00
test Add MoveOperation and RanLib Test 2026年05月09日 23:13:45 +02:00
.gitignore ArrayHashMapType changed 2026年04月27日 01:17:14 +02:00
build.zig Adding First Tests 2026年04月30日 19:29:25 +02:00
build.zig.zon zar 0.0.1 Inital commit 2026年04月27日 00:59:00 +02:00
LICENSE Initial commit 2026年04月27日 00:55:26 +02:00
README.md Add MoveOperation and RanLib Test 2026年05月09日 23:13:45 +02:00

Zar

LLvm-ar clone in Zig

Current Goal is to provide a Zig native alternative to the llvm-ar c++ code, currently used in Zig to provide ar functionaily. As zig dropped AIXsupport, AIX and xcoff are not supported. Neither is llvm bytecode.

Thus focus is on the "ar" command.

"libdriver" or "dlltool" are not implemented yet. Neither is MRI script functionality.

Usage:

 zar ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [files...]

Lookup usage on llvm

Operations

  • d - delete files from the archive
  • m - move files in the archive
  • p - print contents of files found in the archive
  • q - quick append files to the archive
  • r - replace or insert files into the archive
  • s - act as ranlib
  • t - display list of files in archive
  • x - extract files from the archive

Modifiers

  • a - put files after relpos
  • b - put files before relpos (same as i)
  • c - do not warn if archive had to be created
  • D - use zero for timestamps and uids/gids (default)
  • h - display this help and exit
  • i - put files before relpos (same as b)
  • l - ignored for compatibility
  • L - add archive's contents
  • N - use instance count of name
  • o - preserve original dates
  • O - display member offsets
  • P - use full names when matching (implied for thin archives)
  • s - create an archive index (cf. ranlib)
  • S - do not build a symbol table
  • T - deprecated, use --thin instead
  • u - update only files newer than archive contents
  • U - use actual timestamps and uids/gids
  • v - be verbose about actions taken

Test Coverage

The current testing scheme uses zstd as a library source to compile for different targets and then test ar functionality of this programm against the current llvm-ar (zig ar) version, testing for byte-by-byte same output, for all formats in question (coff, bsd, darwin, gnu).

Test Coverages is currently limited (by simply adding targets to tests.zig) to:

  • "x86_64-windows-msvc",
  • "x86_64-windows-gnu",
  • "x86_64-linux-gnu",
  • "x86_64-linux-musl",
  • "x86_64-macos",
  • "x86_64-netbsd",
  • "x86_64-openbsd",
  • "x86_64-freebsd",
  • "aarch64-linux-gnu",
  • "aarch64-linux-musl",
  • "aarch64-macos",
  • "aarch64-freebsd",
  • "powerpc-linux-gnueabi",

But we do pass the test for byte-by-byte for

zar.exe ar -q --format=format libname objectfiles

zar.exe ar -r --format=format libname objectfiles

zar.exe ar -d --format=format libname objectfiles

zar.exe ar -rb --format=format objectfile libname objectfiles

zar.exe ar -ra --format=format objectfile libname

zar.exe ar -mb --format=format objectfile libname objectfiles

zar.exe ar -ma --format=format objectfile libname objectfiles

zar.exe ar -s libname

zar.exe ar -tv libname

zar.exe ar -x libname

(from my windows machine ...)

Feel free to contribute to test\test.zig.

TODOs:

  • Write and perform way more tests (operation / modifier combinations)
  • Go over and remove all TODOs inside the codebase
  • Implement wasm objectfile handeling
  • Handle Errors better
  • Implement missing tools and MRI script compatibility

Wishful Thinking:

  • Remove Symbolic.zig by shipping PR's to zig std
  • become the main Zig ar tool
  • unify all usages of archives inside zig