[PATCH] D114186: [lld][CMake] Add LLD_DEFAULT_NOSTART_STOP_GC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 14:13:19 PST 2021


MaskRay added a comment.

In D114186#3168048 <https://reviews.llvm.org/D114186#3168048>, @jrtc27 wrote:

> In D114186#3168029 <https://reviews.llvm.org/D114186#3168029>, @dim wrote:
>
>> In D114186#3167979 <https://reviews.llvm.org/D114186#3167979>, @jrtc27 wrote:
>>
>>> I've tried to stay out of this for my own sanity, but my objection has not been about the end state which, in a world where SHF_GNU_RETAIN can be relied upon to work, is a more sensible state than historically (I would've preferred that uses that wanted the new GC behaviour use a new way of doing things rather than repurposing something that didn't do the right thing and then forcing their needs on it, breaking existing uses, but I can see and appreciate the technical reasons for doing it this way, and ignoring compatibility issues it does make more sense). My objection has been that SHF_GNU_RETAIN is not ubiquitous enough, both in terms of support and use, for the default start-stop-gc behaviour to have been changed.
>>
>> I agree that that is the main reason for making start-stop-gc not the default *yet*. But what is the criterion for having "enough" `SHF_GNU_RETAIN` support? In the llvm/clang world you typically upgrade the compiler and linker at the same time, so as long as clang supports `SHF_GNU_RETAIN` *now* it should be okay for that part.
>>
>> But what about third parties like gcc, dlang, etc? When will we consider them to be sufficiently up-to-date with regards to retain attributes?
>
> For this kind of change, where some software will end up having to bump its minimum dependency versions (like ldc, so it can either use a libLLVM that supports SHF_GNU_RETAIN or pass -z nostart-stop-gc to lld), I would normally say two years since the features needed for software to continue working were landed, as that's the usual release cycle cadence for major Linux distributions (or LTS versions if they have interim releases), since otherwise there won't be a(n LTS) release of a given distro that is able to satisfy the updated dependency requirements. If all the issues with flipping the default get resolved before then in ways that don't require bumping dependencies (though I don't currently see how the latter can be true) then great, it can be shorter.

A toolchain release may contain bugfixes which can cause software to break if they happen to rely on the buggy behavior.
We fix many bugs without introducing a mechanism to go back to the original state. (See below, it's all about the potentially affected packages.)
In this case it is probably unfair to say software relying on the `__start_` GC behavior has a bug because the ELF world for a long term does not provide good facility (no good != not-exist) for marking sections.
But it is fair to say they are not written with `-Wl,--gc-sections` in mind.

Using `-Wl,--gc-sections` for the unprepared software started to work with GNU ld>2015-10. I'll say that is by accident.
 `-Wl,--gc-sections` is uncommon (no distro enabled it by default), so historically there is no problem.
(The addition of `retain` will make this more reliable, but it is no mandatory.)

Whether the default can flip and how soon it can flip, depend on the number of software relying on the accidental behavior, how they can cover from the regression.
>From Debian Code Search, I'll say the number is small.
With `-z nostart-stop-gc`, I'll say it is easy for them to recover from the regression.
With the introduction of a diagnostic and a new documentation page, I'll say it is straightforward for a developer/user to catch the problem.

With these, I think keeping `-z start-stop-gc` for 13.0.1 is still fine.
Some people tend to be more conservative and don't agree with me, but on the other hand cannot show more evidence.
With other points (e.g. at this point, flipping the behavior back and forth can probably just lead to confusion since people may not remember why 13.0.0/13.0.1/main are different. 13.0.0 cannot be changed now.)

https://lld.llvm.org/ELF/start-stop-gc is available now. We can flesh out the content if needed. (The diagnostic line has a typo of the URI, for example.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114186



More information about the llvm-commits mailing list