Skip to content

Add ArchiveHandle for reading static archives - #63

Open
topolarity wants to merge 1 commit into
JuliaIO:masterfrom
topolarity:ct/archive-handle
Open

topolarity wants to merge 1 commit into
JuliaIO:masterfrom
topolarity:ct/archive-handle

Conversation

@topolarity

Copy link
Copy Markdown
Collaborator

Add preliminary static library (.a) support. Read the archive with readmeta(io, ArchiveHandle) to list an archive's members, and use readmeta(ah, member) / read(ah, member) open one as an object file or read its contents.

Intentionally not supported in readmeta(io) (i.e. no explicit ArchiveHandle), since many callers assume that the result is an object file (not an archive) of the expected type on their platform.

Assisted-by: Claude Code (Opus 5.5) 🤖

Static libraries (`libfoo.a`, `foo.lib`) are `ar` archives of object
files.  `readmeta(io, ArchiveHandle)` lists an archive's members, and
`readmeta(ah, member)` / `read(ah, member)` open one as an object file
or read its contents.  Each member starts with an `ArchiveMemberHeader`.

`ar` has no single specification: each kind of archive (GNU, BSD and
COFF, and the 64-bit variants of the former two) indexes its symbols
and stores long member names in members of its own reserved names.
As in LLVM, the kind is determined once from the first member(s), see
`archive_kind()`, and member names are then decoded by that kind's
rules only, with its symbol and name tables only accepted where they
belong.  GNU thin archives, whose members are stored outside of the
archive, are supported too.

`ArchiveHandle` is not registered in `ObjTypes`, so `readmeta(io)`
still only returns object files: existing callers that iterate the
result of `readmeta(io)` would otherwise start receiving archives.

The test fixtures are generated by `test/archives/build.sh`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.21488% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.84%. Comparing base (815c42e) to head (c8baa01).

Files with missing lines Patch % Lines
src/Archive/Archive.jl 94.21% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #63      +/-   ##
==========================================
+ Coverage   69.94%   71.84%   +1.90%     
==========================================
  Files          46       47       +1     
  Lines        1364     1488     +124     
==========================================
+ Hits          954     1069     +115     
- Misses        410      419       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant