This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Add --output to specify output directory
ClosedPublic

Authored by MaskRay on Jun 27 2022, 1:40 AM.

Details

Summary

From binutils 2.34 onwards, ar supports --output to specify a directory
where archive members should be extracted to. Port this feature.

Diff Detail

Event Timeline

MaskRay created this revision.Jun 27 2022, 1:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 1:40 AM
MaskRay requested review of this revision.Jun 27 2022, 1:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2022, 1:40 AM

I'm uncertain, but should we have a test case where the output directory doesn't exist?

llvm/docs/CommandGuide/llvm-ar.rst
279
llvm/test/tools/llvm-ar/extract.test
38
44

I'm not sure what "after the operation" here means?

gbreynoo added inline comments.Jun 27 2022, 2:40 AM
llvm/test/tools/llvm-ar/extract.test
51

I think it would be worth adding a test case for if the given output location does not exist.

llvm/tools/llvm-ar/llvm-ar.cpp
95

--output needs adding to the help text.

MaskRay updated this revision to Diff 440303.Jun 27 2022, 10:32 AM
MaskRay marked 5 inline comments as done.

address comments

jhenderson added inline comments.Jun 28 2022, 12:18 AM
llvm/test/tools/llvm-ar/extract.test
38

I think it helps to be explicit here.

llvm/tools/llvm-ar/llvm-ar.cpp
568

Probably need a test case that the potential error is handled correctly. This should be easy to create by simply having a file where a directory is expected.

MaskRay updated this revision to Diff 440518.Jun 28 2022, 1:16 AM
MaskRay marked 2 inline comments as done.

test %errc_ENOTDIR

MaskRay added inline comments.Jun 28 2022, 1:17 AM
llvm/test/tools/llvm-ar/extract.test
51

I just reuse the --output=dir case.

MaskRay updated this revision to Diff 440521.Jun 28 2022, 1:19 AM

update comment in llvm/utils/lit/lit/llvm/config.py

MaskRay updated this revision to Diff 440537.Jun 28 2022, 1:59 AM

use is_directory

jhenderson accepted this revision.Jun 29 2022, 1:13 AM

LGTM, with one suggestion.

llvm/tools/llvm-ar/llvm-ar.cpp
473

OutputDir probably should be quoted in case there are any spaces in the path.

This revision is now accepted and ready to land.Jun 29 2022, 1:13 AM
MaskRay updated this revision to Diff 441062.Jun 29 2022, 9:59 AM
MaskRay marked an inline comment as done.

quote OutputDir in the diagnostic

MaskRay edited the summary of this revision. (Show Details)Jun 29 2022, 10:00 AM
This revision was landed with ongoing or failed builds.Jun 29 2022, 10:00 AM
This revision was automatically updated to reflect the committed changes.