This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Fix thin archive being wrongly converted to a full archive
ClosedPublic

Authored by gbreynoo on Apr 5 2022, 9:45 AM.

Details

Summary

When using the L option to quick append a full archive to a thin archive, the thin archive was being wrongly converted to a full archive. I've fixed the issue and added a check for it in thin-to-full-archive.test and expanded some tests.

Diff Detail

Event Timeline

gbreynoo created this revision.Apr 5 2022, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 9:45 AM
gbreynoo requested review of this revision.Apr 5 2022, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 9:45 AM

The following tests have been modified:

  • flatten-thin-archive.test now explicitly checks that %t.a is thin after the other archives have been added.
  • full-to-thin-archive.test uses Inputs/a.txt as an input rather than itself as spurious passes could have occurred when looking for strings contained in the archive file. Corrected a comment, added a test case for an existing archive and a case attempting to convert an existing archive.
  • thin-to-full-archive.test now tests the contents to ensure the thin archives member have been added and not the archive itself. Added a test case for an existing archive and a case attempting to convert an existing archive.
jhenderson added inline comments.Apr 5 2022, 11:31 PM
llvm/test/tools/llvm-ar/full-to-thin-archive.test
11 ↗(On Diff #420553)
15 ↗(On Diff #420553)

You've used the term "full archive" here and in the comment above, but simply "archive" in other places. Be consistent, use one version. FWIW, the error message is "regular archive".

24 ↗(On Diff #420553)

I recommend checking the error message here.

llvm/test/tools/llvm-ar/thin-to-full-archive.test
28 ↗(On Diff #420553)

This isn't used anywhere. Did you mean FULL-NOT? If so, I'd recommend instead adding --implicit-check-not=thin.a to the FileCheck command, since NOT matches are order-sensitive.

32 ↗(On Diff #420553)

Also elsewhere with other comments.

llvm/tools/llvm-ar/llvm-ar.cpp
1031–1032

I've not looked at the full code paths, but at an educated guess, moving this code here will cause this error to occur in other cases which don't add new members, such as t operations? Is that desirable (I'm inclined to say so, but at least want to flag up the possibility of an issue)?

gbreynoo updated this revision to Diff 422524.Apr 13 2022, 9:03 AM

Corrected comments including replacing use of "full archive" with "regular archive" as suggested. To remain consistent two tests have been renamed to use the term "regular". The checks for "thinness" in llvm-ar.cpp now only applies for write commands.

gbreynoo marked 5 inline comments as done.Apr 13 2022, 9:14 AM
gbreynoo added inline comments.
llvm/test/tools/llvm-ar/thin-to-full-archive.test
28 ↗(On Diff #420553)

Thanks, I've made the change as suggested.

llvm/tools/llvm-ar/llvm-ar.cpp
1031–1032

Good catch, this has been changed to only check on write commands.

Perhaps precommit the test updates with renaming and -T => --thin.

gbreynoo marked an inline comment as done.

Good idea @MaskRay, I've split that into https://reviews.llvm.org/D123778 and will update this one when D123778 is complete.

MaskRay accepted this revision.Apr 14 2022, 2:26 PM
This revision is now accepted and ready to land.Apr 14 2022, 2:26 PM

Good idea @MaskRay, I've split that into https://reviews.llvm.org/D123778 and will update this one when D123778 is complete.

There is no particular reason to wait - you could rebase this patch on top of that one, so that this patch doesn't include the other changes that will have already landed. To indicate that this patch isn't intended as a standalone patch, you then use the "Edit Related Revisions" UI option to the right of hte patch description.

Holding off approving until that's happen, as it would be easier for me to review exactly what this patch is finally doing.

llvm/tools/llvm-ar/llvm-ar.cpp
1031–1032

Is there a test case you could add that would have failed with the previous version of this patch?

gbreynoo updated this revision to Diff 423634.Apr 19 2022, 8:36 AM
gbreynoo edited the summary of this revision. (Show Details)
gbreynoo set the repository for this revision to rG LLVM Github Monorepo.

Updated after https://reviews.llvm.org/D123778 was accepted and committed.

gbreynoo marked 2 inline comments as done.Apr 19 2022, 8:37 AM
gbreynoo added inline comments.
llvm/tools/llvm-ar/llvm-ar.cpp
1031–1032

Added to regular-to-thin-archive.test.

jhenderson added inline comments.Apr 20 2022, 12:01 AM
llvm/test/tools/llvm-ar/regular-to-thin-archive.test
28

Nit: I'd delete this blank line, since the line before is strongly tied to the lines immediately after.

llvm/test/tools/llvm-ar/thin-to-regular-archive.test
34

This test is failing the premerge checks, presumably because of the out-of-date %tfull2.a name.

36

Nit: consistency between singular versus plural.

gbreynoo updated this revision to Diff 423913.Apr 20 2022, 8:23 AM
gbreynoo marked an inline comment as done.

Fixed failing test and @jhenderson's other points.

gbreynoo marked 3 inline comments as done.Apr 20 2022, 8:24 AM