apple-support-ar-wrapper: ar r drops the members already in the archive
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp, macos
- Domain
- build-system
Research direction
Start with the ar mode handling in crosstool/libtool.cc, where the wrapper decides between a fresh libtool -static write and the q path that passes the existing archive back in. Reproduce with the two cr calls in an empty directory and check ar t lib.a; expected output is a.o b.o. Done means r, cr and crs keep earlier members with matching names, and the q behaviour from #670 still holds.
Written by the indexing model from the issue text.
Description
Since #601, apple-support-ar-wrapper accepts ar arguments. For r (with or without c, s, D) it runs libtool -static -D -o lib.a <new objects>, which writes a new archive. The members that an earlier call added are lost. The command exits 0, so the first sign is undefined symbols at link time.
#670 fixed the same problem for q: it passes the existing archive back to libtool as an input. That approach is not correct for r. r replaces each member that has the same name, so if the whole archive is passed back, the old member stays next to its replacement, and the linker takes the first one, which is the stale one.
Repro
Build the wrapper from the 2.11.0 tag (crosstool:exec_libtool, or xcrun clang -std=c++17 -lc++ -o apple-support-ar-wrapper crosstool/libtool.cc). Set DEVELOPER_DIR and SDKROOT (any values; the wrapper only requires them). Use any two objects a.o and b.o, and start each row of the table in an empty directory.
apple-support-ar-wrapper cr lib.a a.o
apple-support-ar-wrapper cr lib.a b.o
ar t lib.a
Expected: a.o and b.o. Actual: only b.o. (ar t also lists __.SYMDEF SORTED in both cases.)
Members after two calls (a.o, then b.o), from crosstool/libtool.cc at 2.11.0 and from /usr/bin/ar:
| Mode | wrapper | /usr/bin/ar |
|---|---|---|
r |
b.o |
a.o b.o |
cr |
b.o |
a.o b.o |
crs |
b.o |
a.o b.o |
crD |
b.o |
(D not supported) |
q |
a.o b.o |
a.o b.o |
cq |
a.o b.o |
a.o b.o |
Notes for a fix
ar rputs each new member in the place of the first old member with the same name, and appends the new members that replace nothing.- To match by name, the wrapper must name members after their files in
armode, asardoes. Today it renames duplicate basenames to<stem>_<hash>.o.
Versions: apple_support 2.11.0, macOS 26.6.2 arm64, Xcode.
- Dominant language
- Starlark
- Stars
- 109
- Forks
- 79
- Avg merge
- 4h 29m
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bazelbuild/apple_support
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
bazelbuild/apple_support#707 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
bazelbuild/apple_support#466 · 3 comments ·
Maintainers usually reply within 1 day
All issues in bazelbuild/apple_support
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
out-of-date
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
Maintainers usually reply within 1 day
-
blast/large refactor risk/low spend-dem
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
chriskelly/MusicWall#87 · 2 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
neilotoole/sq#1503 ·
Maintainers usually reply within 1 day
-
ci-alert
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day