This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Enforce one-dash form for long options
ClosedPublic

Authored by MaskRay on Jan 10 2022, 2:58 PM.

Details

Summary

binutils ar does not support one-dash long options (they conflict with
operation code and modifier flags).

% ar -help
ar: invalid option -- 'e'
...
% ar -version
ar: invalid option -- 'e'
...

% ar x --plugin=xx x.a  # ok
% ar x -plugin=xx x.a
ar: two different operation options specified
% ar -plugin=/usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so x x.a
ar: x: No such file or directory

Drop one-dash long options to simplify code and match the usual practice for
command line utilities.

Diff Detail

Event Timeline

MaskRay created this revision.Jan 10 2022, 2:58 PM
MaskRay requested review of this revision.Jan 10 2022, 2:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2022, 2:58 PM

I'm mostly fine with this.

llvm/test/tools/llvm-ar/plugin.test
1

Seems tangential to this patch? Test is fine, but probably should be committed separately.

Any particular reason you don't test the single-dash version here, but you do in the --format and --version options?

MaskRay added inline comments.Jan 11 2022, 8:34 AM
llvm/test/tools/llvm-ar/plugin.test
1

Yes, I plan to commit this separately.

Any particular reason you don't test the single-dash version here, but you do in the --format and --version options?

Just thought it seems excessive to test every long option. --format and --version have good coverage.

LGTM but I will hold of accepting this revision until James has seen the responses.

This revision is now accepted and ready to land.Jan 12 2022, 1:46 AM
MaskRay added inline comments.Jan 12 2022, 11:33 AM
llvm/test/tools/llvm-ar/plugin.test
1
This revision was automatically updated to reflect the committed changes.

If there is a justifiable issue, we can temporarily add -version, otherwise we don't need to take more defensive stance.