This is an archive of the discontinued LLVM Phabricator instance.

Print out "Alias for -foo" instead of repeating the same help message for -foo.
ClosedPublic

Authored by ruiu on May 31 2018, 6:58 AM.

Details

Summary

Since aliases don't actually need name, so I removed it from Options.td
to keep the definitions concise.

Before:

-(                      Ignored for compatibility with GNU unless you pass --warn-backrefs
-)                      Ignored for compatibility with GNU unless you pass --warn-backrefs
--allow-multiple-definition Allow multiple definitions
--apply-dynamic-relocs  Apply dynamic relocations to place
--as-needed             Only set DT_NEEDED for shared libraries if used
--auxiliary=<value>     Set DT_AUXILIARY field to the specified name
--Bdynamic              Link against shared libraries
--Bshareable            Build a shared object
...

After:

-(                      Alias for --start-group
-)                      Alias for --end-group
--allow-multiple-definition Allow multiple definitions
--apply-dynamic-relocs  Apply dynamic relocations to place
--as-needed             Only set DT_NEEDED for shared libraries if used
--auxiliary=<value>     Set DT_AUXILIARY field to the specified name
--Bdynamic              Link against shared libraries (default)
--Bshareable            Alias for --shared
...

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.May 31 2018, 6:58 AM
pcc accepted this revision.May 31 2018, 11:40 AM

LGTM

This revision is now accepted and ready to land.May 31 2018, 11:40 AM
This revision was automatically updated to reflect the committed changes.

Hi Rui,

I made a mistake when writing out the help text for one of our aliased options (local to our downstream port of lld) whilst merging in this change. It would be nice if we didn't have to write out the help text for aliased options.

I suggest:

  • We change OptTable::PrintHelp[lvm\lib\Option\OptTable.cpp] to take an additional parameter that specifies the behaviour when no help text has been specified for an aliased option:
    1. Copy the help text from the aliased option
    2. Print "Alias for " + Alias.getPrefixedName ()
  • We remove help text for all aliased options in lld and specify behaviour 2. above when creating our options parser.

What do you think?

ruiu added a comment.Jun 5 2018, 8:39 AM

I would probably prefer this dumb but simple change over making a change to OptTable.cpp so that it synthesizes "Alias for ..." strings for alias options. If we have hundreds of lines of aliases, that might help, but for this 30+ options, maybe it's a bit too much?