This is an archive of the discontinued LLVM Phabricator instance.

Access ADDLIB in llvm-ar via command line
ClosedPublic

Authored by gbreynoo on Oct 16 2018, 10:05 AM.

Details

Summary

ADDLIB is called to add the contents of an archive to another archive. This is currently only available in llvm-ar and gnu-ar through the use of an MRI script. We propose adding a new modifier to the llvm-ar command line so workflows that require the ADDLIB functionality are not forced to use MRI scripts.

With the use of a new "L" modifier, archive files can treated in the manner above when using quick append.

"L" was chosen as a key letter only because it is not used by gnu-ar, any alternate suggestions would be appreciated.

Diff Detail

Event Timeline

gbreynoo created this revision.Oct 16 2018, 10:05 AM

Other than the minor comment I had, this looks sensible to me. Do we have any policy or predecent on adding this kind of custom additions to tools like ar from before? (I'd like to at least have some sort of ack from someone else to approve this.)

tools/llvm-ar/llvm-ar.cpp
553

Any reason why this path can't just call the default addMember?

gbreynoo added inline comments.Oct 18 2018, 5:40 AM
tools/llvm-ar/llvm-ar.cpp
553

It would mean repeating the getFile() call, I wasn't sure it was worth the overhead.

mstorsjo added inline comments.Oct 18 2018, 6:02 AM
tools/llvm-ar/llvm-ar.cpp
553

Ah, I see. That makes sense to me.

Ping.

Still looks sensible to me, but I'd like some sort of ack from at least someone else, since we're extending the interface of an otherwise standardized tool.

rupprecht accepted this revision.Oct 25 2018, 10:52 AM
rupprecht added a subscriber: rupprecht.

Seems reasonable to use L given that gnu-ar doesn't mention it/POSIX spec doesn't say it's reserved for anything. I'm fine with any other letter that fits that requirement too.

It would mean that anything using this would no longer be buildable w/ a GNU toolchain, but that's true of any other reason someone might be motivated to switch to an llvm binutils toolchain. Requiring MRI scripts for portable libraries doesn't seem too bad.

This revision is now accepted and ready to land.Oct 25 2018, 10:52 AM
MaskRay added inline comments.Oct 25 2018, 11:26 AM
tools/llvm-ar/llvm-ar.cpp
681

I think { } is redundant as there is another case below that does not add { } for simple statement like this..

Hi after a revision is accepted, you can run arc amend to update Reviewed By: Reviewers: lines from Phabricator to local git commit description.

Make sure your git commit has a line Differential Revision: ... to associate it with the Phabricator revision, so that when you commit the revision can be automatically closed.

jyknight added inline comments.
tools/llvm-ar/llvm-ar.cpp
99

Maybe say "For ar archives in [files], add each member, rather than the archive itself." or something along those lines, to indicate that both .a and .o files are handled with L.

344

Seems a bit odd that it doesn't work with 'r'?

rupprecht closed this revision.Oct 29 2018, 10:54 AM

Manually closing this -- it was committed in rL345383