This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Improve MRI script CREATE command handling
ClosedPublic

Authored by gbreynoo on Jun 17 2022, 6:53 AM.

Details

Summary

I discovered that when compared to GNU the llvm-ar MRI script parsing of CREATE could lead to some strange behaviour. This fix improves the error message in the case when no archive name is given and will not allow the adding of members until CREATE is called. Along with this change I added more testing of the CREATE command.

Diff Detail

Event Timeline

gbreynoo created this revision.Jun 17 2022, 6:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 6:53 AM
gbreynoo requested review of this revision.Jun 17 2022, 6:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 6:53 AM

Consider precommitting the tests to make the change more focused?

llvm/test/tools/llvm-ar/mri-addlib.test
2–3

# RUN: rm -rf %t && split-file %s %t && cd %t

split-file doesn't need mkdir.

llvm/tools/llvm-ar/llvm-ar.cpp
1066

output archive is not opened?

MaskRay added inline comments.Jun 17 2022, 4:14 PM
llvm/test/tools/llvm-ar/mri-addlib.test
38

You may use SYMS2-COUNT-2:

llvm/test/tools/llvm-ar/mri-addmod.test
30

-COUNT-2

jhenderson added inline comments.Jun 20 2022, 12:37 AM
llvm/test/tools/llvm-ar/mri-addlib.test
27

Nit: here and below, missing full stop at end of sentence.

31

I believe you should use one of the %errc substitutions (I think %errc_NOENT if memory serves correctly, but look it up!)

That way, the message is platform independent.

41–42

FILES2-COUNT-2 along the same lines as above, assuming they are in adjacent lines in the output.

llvm/test/tools/llvm-ar/mri-addmod.test
1

Same comments from me apply to this test.

llvm/test/tools/llvm-ar/mri-create.test
11

Nit: missing full stops.

30

Is CREATE -> SAVE -> CREATE supported? If so, do you need test coverage for that too?

llvm/tools/llvm-ar/llvm-ar.cpp
1066

I prefer "no output archive has been opened"

gbreynoo updated this revision to Diff 439444.Jun 23 2022, 10:02 AM

Fixed comments, added use of errc_NOENT and COUNT-2, added missing coverage of SAVE between calls to CREATE and improved error message.

gbreynoo added inline comments.Jun 23 2022, 10:04 AM
llvm/test/tools/llvm-ar/mri-addlib.test
31

Thanks, didn't know about that.

38

Thanks, I didn't know about that.

llvm/test/tools/llvm-ar/mri-create.test
114

I'll fix this before I commit

llvm/tools/llvm-ar/llvm-ar.cpp
1066

I went with "no output archive has been opened" as it seemed clearer.

jhenderson added a comment.EditedJun 23 2022, 11:15 PM

There's a potentially relevant pre-merge failure in mri-create.test on debian (see above), which you should look at before landing this (I suspect it's the missing %errc substitution I highlighted inline).

llvm/test/tools/llvm-ar/mri-create.test
27

Missing %errc substitution usage here?

gbreynoo updated this revision to Diff 439806.Jun 24 2022, 9:59 AM

Updated error message check.

llvm/test/tools/llvm-ar/mri-create.test
27

Thanks, should be fixed now.

jhenderson accepted this revision.Jun 27 2022, 12:36 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jun 27 2022, 12:36 AM
This revision was landed with ongoing or failed builds.Jun 27 2022, 3:11 AM
This revision was automatically updated to reflect the committed changes.