This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Introduce multiclass Eq helper for Options.td
ClosedPublic

Authored by grimar on Jul 19 2017, 5:56 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Jul 19 2017, 5:56 AM
ruiu added inline comments.Jul 19 2017, 2:19 PM
ELF/Driver.cpp
808 ↗(On Diff #107291)

Rebase and remove this line.

ELF/Options.td
10 ↗(On Diff #107291)

Is JSEq short for Joined-Separate-EQual? That doesn't make much sense. I'd name this just Eq.

11 ↗(On Diff #107291)

Remove space before :.

Use the extended version as we don't need to save characters here.

def "": Separate<["--", "-"], name>;
def _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(name)>;
12 ↗(On Diff #107291)

NAME -> name

30 ↗(On Diff #107291)

I think it is better to remove help from JSEq and keep HelpText for each option.

grimar updated this revision to Diff 107450.Jul 20 2017, 12:24 AM
grimar retitled this revision from [ELF] - Introduce multiclass JSEq helper for Options.td to [ELF] - Introduce multiclass Eq helper for Options.td.
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
ELF/Driver.cpp
808 ↗(On Diff #107291)

Done.

ELF/Options.td
10 ↗(On Diff #107291)

Done.

11 ↗(On Diff #107291)

Done.

12 ↗(On Diff #107291)

'name' will not work here.
Because name is a variable passed, which is option name used
for rendering, for example library-path.
But NAME would be library_path, because NAME is the special entry,
it is a name of def record itself.

See:
"Each def record has a special entry called “NAME”. This is the name of the record (“ADD32rr” above). In the general case def names can be formed from various kinds of string processing expressions and NAME resolves to the final value obtained after resolving all of those expressions. The user may refer to NAME anywhere she desires to use the ultimate name of the def. NAME should not be defined anywhere else in user code to avoid conflicts."
http://llvm.org/docs/TableGen/index.html

30 ↗(On Diff #107291)

I would not do that because of next reasons:

  • It breaks our help output. Because libOption implementation renders all options which has help text. If I do that change, we will end up with duplicated options with the same help text.
  • It is inconsistent - we do not apply help text for other aliases. So we will have situations where we have option with text and alias with text vs option with help text and alias without.
  • It does not make sence to have help text set for alias. I mean practical sence, this information will be always probably be unused.
ruiu added inline comments.Jul 20 2017, 5:16 AM
ELF/Options.td
30 ↗(On Diff #107291)

I think showing both non-alias and alias options in the --help message is fine, and that's actually we want. I want everything to show up in the --help message as long as the linker accepts it.

grimar added inline comments.Jul 20 2017, 5:23 AM
ELF/Options.td
30 ↗(On Diff #107291)

What I mean that we probably may want:
-library-path <value>, -library-path=<value> Some help text here
Single line with list of options and one help text. That requires D35476 change.

But if we assign HelpText for both option and its alias, like you suggest,
our output currently will be multilined and duplicated:
-library-path <value> Some help text here
-library-path=<value> Some help text here

That does not look as desired result, no ?

ruiu added inline comments.Jul 20 2017, 5:25 AM
ELF/Options.td
30 ↗(On Diff #107291)

I think that is fine.

grimar added inline comments.Jul 20 2017, 6:11 AM
ELF/Options.td
30 ↗(On Diff #107291)

What about options that have other aliases ? For example if I would do this change
for entry option, its declaration should be:

defm entry: Eq<"entry">, HelpText<"Name of entry point symbol">, MetaVarName<"<entry>">;
def alias_entry_e: JoinedOrSeparate<["-"], "e">, HelpText<"Name of entry point symbol">, Alias<entry>;

To produce output that you want:

--entry  <entry>   Name of entry point symbol
--entry= <entry>  Name of entry point symbol
-e <entry>            Name of entry point symbol

Do you want to define HelpText for aliases like alias_entry_e too ?

ruiu added inline comments.Jul 20 2017, 7:39 AM
ELF/Options.td
30 ↗(On Diff #107291)

I don't care about that that much. It at least doesn't look bad to me, it is easy to understand and easy to parse. Even if we want something else, I don't like to do everything at once.

grimar updated this revision to Diff 107513.Jul 20 2017, 7:57 AM
  • Addressed review comments (move HelpText out of multiclass helper).
ruiu edited edge metadata.Jul 20 2017, 8:01 AM

Please keep Options.td in 80 columns.

grimar updated this revision to Diff 107531.Jul 20 2017, 8:42 AM
  • Reformated to 80 characters per line

(where possible, for lines changed by patch only).

ruiu added inline comments.Jul 20 2017, 8:51 AM
ELF/Options.td
203 ↗(On Diff #107531)

I don't think this is correct. If you pass --output=foo, it should be interpreted as -o utput=foo.

grimar added inline comments.Jul 20 2017, 9:04 AM
ELF/Options.td
203 ↗(On Diff #107531)

Both bfd and gold disagree with that:

umb@umb-virtual-machine:~/tests/502_optionsalias$ ld.bfd -v
GNU ld (GNU Binutils for Ubuntu) 2.26.1
umb@umb-virtual-machine:~/tests/502_optionsalias$ ld.gold -v
GNU gold (GNU Binutils for Ubuntu 2.26.1) 1.11
umb@umb-virtual-machine:~/tests/502_optionsalias$ ls
test.o
umb@umb-virtual-machine:~/tests/502_optionsalias$ ld.gold -shared test.o --output=foo1
umb@umb-virtual-machine:~/tests/502_optionsalias$ ld.bfd -shared test.o --output=foo2
umb@umb-virtual-machine:~/tests/502_optionsalias$ ls
foo1 foo2 test.o

ruiu added inline comments.Jul 20 2017, 9:09 AM
ELF/Options.td
203 ↗(On Diff #107531)

Sorry, I meant -output=foo.

grimar added inline comments.Jul 20 2017, 9:38 AM
ELF/Options.td
203 ↗(On Diff #107531)

ld.gold and ld.bfd disagree for -output=foo:

umb@umb-virtual-machine:~/tests/502_optionsalias$ ls
test.o
umb@umb-virtual-machine:~/tests/502_optionsalias$ ld.gold -shared test.o -output=foo1
umb@umb-virtual-machine:~/tests/502_optionsalias$ ld.bfd -shared test.o -output=foo2
umb@umb-virtual-machine:~/tests/502_optionsalias$ ls
foo1 test.o utput=foo2
umb@umb-virtual-machine:~/tests/502_optionsalias$

I think we can choose any behavior. As I mentioned in description, I changed that for
--output because it makes declaration simpler and consistent with gold at the same time.

Do you prefer with bfd behavior ? gold one allows be a bit more consistent in this patch.

ruiu added inline comments.Jul 20 2017, 9:42 AM
ELF/Options.td
308 ↗(On Diff #107531)

Sort

ruiu added a comment.Jul 20 2017, 9:45 AM

If that's the case, that's a bug in gold, if they aim compatibility with ld.bfd. The manual page for ld.bfd clearly states that -o<something> should be interpreted as -o <something>

grimar updated this revision to Diff 107641.Jul 21 2017, 1:48 AM
  • Addressed comments, restored -o behavior, cosmetic changes.
ruiu accepted this revision.Jul 21 2017, 8:22 AM

LGTM

This revision is now accepted and ready to land.Jul 21 2017, 8:22 AM
grimar edited the summary of this revision. (Show Details)Jul 21 2017, 9:27 AM
This revision was automatically updated to reflect the committed changes.
In D35619#817302, @ruiu wrote:

LGTM

Thanks !

Looks now we want to add HelpText for all others aliases we have so
they show up in help among regular options and _eq aliases ?