This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - exit on --version call
ClosedPublic

Authored by grimar on Nov 18 2016, 11:25 AM.

Details

Summary

Sorry for posting such a minor one
, but just found I am not sure this is
expected behaviour though it seems so according to
https://llvm.org/bugs/show_bug.cgi?id=31057.

So do we want that one right ?

Diff Detail

Event Timeline

grimar updated this revision to Diff 78560.Nov 18 2016, 11:25 AM
grimar retitled this revision from to [ELF] - exit on --version call.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
davide added a subscriber: davide.Nov 18 2016, 12:12 PM

The patch is correct, but please add a testcase.

grimar updated this revision to Diff 78571.Nov 18 2016, 12:47 PM
  • Updated test.

The patch is correct, but please add a testcase.

I missed I need to update test as well, thanks !

emaste added a subscriber: emaste.Nov 18 2016, 1:09 PM

Seems it's a difference in behaviour between -v and --version. AFAICT for -v both ld.bfd and ld.gold print a one-line version number and carry on with the link if there are args (or exit with 0 if not). For --version they print a multi-line version & This program is free software info, and do not link.

ruiu added a comment.Nov 18 2016, 1:10 PM

So we probably should stop handling --version as an alias to -v and make --verbose behave differently than -v.

In D26865#600168, @ruiu wrote:

Hmm, I really forgot about this one. Confusing.

In D26865#600186, @ruiu wrote:

So we probably should stop handling --version as an alias to -v and make --verbose behave differently than -v.

I can do that tomorrow. (if nobody needs to fix it faster).

grimar updated this revision to Diff 78635.Nov 19 2016, 10:15 AM
grimar edited edge metadata.
  • Updated.

Behavior of ld.bfd and ld.gold is inconsistent. I checked the next combinations:
ld -v + <normal files>. Result: link OK.
gold -v + <normal files>. Result: link OK.
ld -v <no files>. Result: exit with code 0.
gold -v <no files>. Result: exit with code 0.
ld -version <no files>. Result: exit with code 0.
gold -version <no files>. Result: exit with code 0.

Until here behavior was equal. But the last case has different result:
ld -version <normal files>. Result: no link happens, exit with 0.
gold -version <normal file>. Result: link OK.

That is what Rui mentioned on bug page, I did not realized it at first.

So looks we can live with just a minor change like this patch do to fix
PR31057, thoughts ?

ruiu accepted this revision.Nov 19 2016, 10:20 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 19 2016, 10:20 AM
This revision was automatically updated to reflect the committed changes.