[PATCH] D88877: [ELF] Drop -whole-archive before processing dependent libraries.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 23:14:32 PDT 2020


ikudrin added a comment.

In D88877#2331416 <https://reviews.llvm.org/D88877#2331416>, @bd1976llvm wrote:

> Firstly, is this a real problem?

The problem is real. We have a report from our customer, so the issue is already observed in the wild.

> In the RFC thread http://lists.llvm.org/pipermail/llvm-dev/2019-March/131105.html Rui said:
>
>> Then they can specify --no-whole-archive on the end of the command line, no?

Unfortunately, sometimes that is not that simple as it sounds. In our case, the users who need autolinking are different from a unit that provides tools to adjust command lines. There is no option to add anything at the very end.

> I think we want to be sure that users can't simply adjust their linker command line before we complicate autolinking. Given that autolinking is a new feature on ELF it doesn't seem unfair that users should understand the feature and consider adjusting their linker command lines. Maybe we could add some diagnostics to help them.. e.g. lld could advise users that "--whole-archive was active" if a duplicate symbol error arises during auto-linking?



> As to --whole-archive not being compatible with autolinking.. maybe the set of autolinked inputs should be deduplicated. This was discussed in the original RFC thread and would also solve https://bugs.llvm.org/show_bug.cgi?id=42460.

Duplicate symbols are one part of the issue, the most noticeable because it prevents linking. Another, hidden part is that if the library is referenced only once, the linker fetches unneeded unreferenced members. It would be fair if the linker works in an expected way.

As I understand the idea of the `--whole-archive` switch, it meant to instruct a linker which libraries should be included as a whole, not how you prefer the output to be linked. In the latter case that would be simple a global switch that would affects all input libraries.

You know how they say, explicitly is better than implicitly. What can be less explicit than a switch in the command line which affects linking a library referenced far away from it, in a source file header? If there will ever be a use case for autolinking in a `--whole-archive` way, it will be much better to add an explicit option in the pragma itself or provide a distinct linker switch, something like `--whole-autolink-library`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88877/new/

https://reviews.llvm.org/D88877



More information about the llvm-commits mailing list