This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implement --orphan-handling option.
ClosedPublic

Authored by grimar on Oct 17 2017, 6:19 AM.

Details

Summary

We have PR34946 about that LLD does not support this option.

Spec (http://man7.org/linux/man-pages/man1/ld.1.html) tells about --orphan-handling=MODE,
option where MODE can be one of four: "place", "discard", "warn", "error".
Currently we already report orphans when -verbose given, what becomes excessive with option implemented.

Given above I think reasonable behavior is to stop reporting orphans when -versbose is given,
and support "place", "warn" and "error" modes. I am not sure about usefulness of "discard"
and its a bit scary, so I suggest to not implement it. Patch demonstrate the change I am suggesting.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Oct 17 2017, 6:19 AM

Ping. Are we going to support this ?

ruiu added inline comments.Oct 24 2017, 11:30 AM
ELF/LinkerScript.cpp
459–460 ↗(On Diff #119304)

You don't need this if you use else if instead of else.

grimar updated this revision to Diff 120230.Oct 25 2017, 4:44 AM
  • Addressed review comments.
ruiu accepted this revision.Oct 25 2017, 7:29 AM

LGTM

ELF/LinkerScript.cpp
461–464 ↗(On Diff #120230)

nit: it is more natural if you swap the positions of warn and error.

test/ELF/linkerscript/orphan-report.s
46–48 ↗(On Diff #120230)

In general, when you give a bogus value, you should give a value that is obviously bogus, because it conveys your meaning better. Instead of "discard", pass "foo", for example. This comment applies to other patches.

This revision is now accepted and ready to land.Oct 25 2017, 7:29 AM
grimar added inline comments.Oct 25 2017, 7:33 AM
test/ELF/linkerscript/orphan-report.s
46–48 ↗(On Diff #120230)

I passed "discard" here intentionally to document that we do not support this mode explicitly.
I can change to "foo" case as well, but I supposed "discard" case is useful itself.

ruiu added inline comments.Oct 25 2017, 7:55 AM
test/ELF/linkerscript/orphan-report.s
46–48 ↗(On Diff #120230)

I don't think I agree. Testing that something is not supported seems a bit odd... Unit tests are to make sure that all your existing features are still working fine, but this test doesn't work for that purpose. We can, for example, add tests to make sure that some Solaris linker options are not supported in lld, but do we want to add such tests? I think the answer is no, because, it doesn't make sense as tests.

grimar added inline comments.Oct 25 2017, 8:11 AM
test/ELF/linkerscript/orphan-report.s
46–48 ↗(On Diff #120230)

May be you are right. I have no strong opinion it seems, both positions seems reasonable for me.
My concern is that there is some difference between "feature is not supported" and "feature explicitly not supported".
If we choose the second then I think we take responsibility that it should not have unexpected behavior, like
we probably do not want "discard" be just ignored by mistake, what can require test.

I'll change to "foo" before commit though as I have no strong opinion on that point.

This revision was automatically updated to reflect the committed changes.