<div dir="ltr">It's actually a bit weirder than you might think.  The CommandLine parser will happily eat as many dashes as you care to write, e.g., `----sections` is the same as `-sections`.<div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 16, 2019 at 2:11 AM James Henderson via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>As I think I said elsewhere, I find it weird that LLVM tools accept long arguments with a single dash, and I'd be happy for the binary utilities at least to move away from this approach, if it improves compatibility/reduces gotchas etc. One of the points from the BoF on the LLVM binutils at the recent Euro LLVM developers' meeting was that if we are going to break compatibility with previous versions of LLVM, we're better off doing it now, rather than leaving it a long time. The longer it gets left, the more users, and therefore the more likely somebody has come to rely on it in a non-trivial-to-fix way.</div><div><br></div><div>If we are particularly concerned with llvm-readobj, we could (if it is practical) try handling it differently to llvm-readelf. An approach as suggested by Michael Spencer at the BoF could be to migrate away from using cl::opt and follow the same route as llvm-objcopy. That would allow us to have different option sets for the two versions of that tool, if we wanted.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 16 Apr 2019 at 08:44, Jordan Rupprecht <<a href="mailto:rupprecht@google.com" target="_blank">rupprecht@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>For binutil compatibility, and in general for any new tools, this sounds reasonable to me. But I'd worry that things like llvm-readobj have existed for a long time and people are used to flags like "-sections", and it may be complicated to change that now. (I guess this RFC is a check to see if this is true for anyone on the mailing list).</div><div><br></div><div>What happens if you make this change and someone does use "-sections" -- will the command line parser suggest "--sections", or will it just fail because one of -s, -e, -c, etc. is not a valid option?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 16, 2019 at 9:00 AM Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail-m_6553266173914687944gmail-m_7880104980596409941cremed" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">That change makes sense to me. I'd like to note that the policy should be set per-command basis, as some commands are required to accept both `--` and `-` for long option names. lld is such command.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 16, 2019 at 3:41 PM Fāng-ruì Sòng via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail-m_6553266173914687944gmail-m_7880104980596409941m_-3108253928272866619cremed gmail-m_6553266173914687944gmail-m_7880104980596409941cremed" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div>Many llvm utilities use cl::ParseCommandLineOptions() (include/Support/CommandLine.h) to parse command line options. The cl library accepts both -long-option and --long-option forms, with the single dash form (-long-option) being more popular.</div><div><br></div><div>We also have many binary utilities (llvm-objcopy llvm-objdump llvm-readobj llvm-size ...) whose names reflect what they imitate. For compatibility with GNU binutils (and some Unix utilities transitively), these utilities accept many short options. People who use llvm utilities as replacement of GNU binutils may use the grouped option syntax (POSIX Utility Conventions), e.g. -Sx => -S -x, -Wd => -W -d, -sj.text => -s -j.text</div><div><br></div><div>The problem is, grouped short options don't play well with -long-option. Sometimes there can be ambiguity. The issue is more prominent if the short option accepts an argument.</div><div><br></div><div>An approach to prevent the ambiguity is to just disallow -long-option.</div><div>In D60439, I plan to make llvm-objcopy accept --long-option but not -long-option.</div><div>It will make its command line option parsing behave more like GNU objcopy and less like a regular llvm utility. What do people think of the divergence?</div><div><br></div><div>Further, can we make similar changes to other llvm binary utilities (their names give people the expectation), especially those with many short options such as llvm-objdump and llvm-readobj? llvm-readobj behaves like GNU readelf if you name it "llvm-readelf". (I don't suggest disallowing -long-option for utilities other than binutils)</div><div><br></div><div>(Note, llvm-objcopy is a new member of the family and it uses tablegen based include/llvm/Option/Opton.h, instead of cl:: as other utilities do.)</div></div><div><br></div><div><br></div><div><br></div>-- <br><div dir="ltr" class="gmail-m_6553266173914687944gmail-m_7880104980596409941m_-3108253928272866619gmail-m_8121242520967251612gmail-m_8199849493038759144gmail_signature"><div dir="ltr">宋方睿</div></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail-m_6553266173914687944gmail-m_7880104980596409941m_-3108253928272866619cremed gmail-m_6553266173914687944gmail-m_7880104980596409941cremed" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail-m_6553266173914687944gmail-m_7880104980596409941m_-3108253928272866619cremed gmail-m_6553266173914687944gmail-m_7880104980596409941cremed" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail-m_6553266173914687944gmail-m_7880104980596409941m_-3108253928272866619cremed gmail-m_6553266173914687944gmail-m_7880104980596409941cremed" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail-m_6553266173914687944gmail-m_7880104980596409941m_-3108253928272866619cremed gmail-m_6553266173914687944gmail-m_7880104980596409941cremed" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>