This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Fix MRI ADDLIB command when used with thin archives
ClosedPublic

Authored by gbreynoo on Jun 17 2022, 9:07 AM.

Details

Summary

We did not properly handle using CREATETHIN in an MRI script and attempting to use ADDLIB to add the contents of a regular archive. This fix outputs a meaningful error message in this case and provides some more testing.

Diff Detail

Event Timeline

gbreynoo created this revision.Jun 17 2022, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 9:07 AM
gbreynoo requested review of this revision.Jun 17 2022, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 9:07 AM
MaskRay accepted this revision.Jun 17 2022, 12:01 PM

An alternative way organizing MRI tests is to place them into regular-to-thin-archive.test and thin-to-regular-archive.test , but a dedicated test file for MRI & Thin looks fine, too.

llvm/test/tools/llvm-ar/mri-thin-archive.test
1–3

My personal feeling is that placing rm, split-file, mkdir on one line is fine (many tests do this). It's still clear.

1–3

# UNSUPPORTED: system-aix

AIX doesn't use <arch>, and I am unsure how thin archives work for them.

9–10

ditto below

llvm/tools/llvm-ar/llvm-ar.cpp
1070

grammar mistakes in "a regular archives contents"

I'd suggest cannot merge a regular archive into a thin archive, but happy to use one @jhenderson prefers.

This revision is now accepted and ready to land.Jun 17 2022, 12:01 PM
jhenderson added inline comments.Jun 20 2022, 12:18 AM
llvm/test/tools/llvm-ar/mri-thin-archive.test
1–3

Alternatively, use a --format option in the llvm-ar invocations, but it's probably simpler to use the # UNSUPPORTED as @MaskRay suggests.

13

I'd give this check an explicit prefix, rather than relying on the default, since you have other prefixes elsewhere.

18

This will only show that delete.o is not the last member of the archive. It would probably be more advisable to use FileCheck --implicit-check-not=delete.o (I know that this was here before, but since you're basically rewriting the test, you might as well improve it whilst here).

23

What is the purpose of this line? All it does is show that elf.o appears somewhere in the archive, and doesn't confirm whether or not a) there are any other members and b) whether the name is a full path (because FileCheck looks for substrings unless told to do otherwise).

llvm/tools/llvm-ar/llvm-ar.cpp
1070

I'm not a fan of the word "merge" here, because it has implications around the old regular archive no longer existing. I think the original is closer to being correct, but missing an apostrophe: "cannot add a regular archive's contents to a thin archive".

gbreynoo updated this revision to Diff 439449.Jun 23 2022, 10:08 AM

Fixed whitespace, added UNSUPPORTED: system-aix, placed rm, split-file, mkdir on one line, added explicit prefix and improved error message.

gbreynoo added inline comments.Jun 23 2022, 10:10 AM
llvm/test/tools/llvm-ar/mri-thin-archive.test
23

This was just to check the archive was regular, I've removed the unneeded check for elf.o

llvm/tools/llvm-ar/llvm-ar.cpp
1070

I went for adding the apostrophe.

jhenderson added inline comments.Jun 23 2022, 11:19 PM
llvm/test/tools/llvm-ar/mri-thin-archive.test
16

Perhaps worth adding --match-full-lines to the FileCheck output, to ensure your path is as expected here? (e.g. this will also match addlib/elf.o/ or myelf.other.o etc as things stand)

gbreynoo updated this revision to Diff 439802.Jun 24 2022, 9:45 AM

Updated with use of --match-full-lines.

This revision was landed with ongoing or failed builds.Jun 27 2022, 9:11 AM
This revision was automatically updated to reflect the committed changes.