[llvm] r301586 - [asan] Put ctor/dtor in comdat.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 02:42:24 PDT 2017


On Thu, Apr 27, 2017 at 1:40 PM Evgeniy Stepanov via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: eugenis
> Date: Thu Apr 27 15:27:23 2017
> New Revision: 301586
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301586&view=rev
> Log:
> [asan] Put ctor/dtor in comdat.
>
> When possible, put ASan ctor/dtor in comdat.
>
> The only reason not to is global registration, which can be
> TU-specific. This is not the case when there are no instrumented
> globals. This is also limited to ELF targets, because MachO does
> not have comdat, and COFF linkers may GC comdat constructors.
>
> The benefit of this is a lot less __asan_init() calls: one per DSO
> instead of one per TU. It's also necessary for the upcoming
> gc-sections-for-globals change on Linux, where multiple references to
> section start symbols trigger quadratic behaviour in gold linker.
>
> This is a second re-land of r298756. This time with a flag to disable
> the whole thing to avoid a bug in the gold linker:
>   https://sourceware.org/bugzilla/show_bug.cgi?id=19002


Evgeniy, I strongly disagree with the default here.

This bug in gold is likely to be encountered by anyone using a Linux distro
with binutils before v2.27 and using gold. Given how slow the BFD linker is
compared to gold, that's likely a *lot* of users of LLVM *if* their version
of binutils in that old.

Unfortunately, both LTS versions of Ubuntu (and every version including
Xenial and older) have too old of a version of gold. Debian stable has too
old of a version. Fedora 25 and older, OpenSuSE 42 and earlier, all have
too old of versions of gold.

I think that this feature needs to be defaulted off. If you want to detect
LLD (which is likely to be installed *with* LLVM at least) or detect
versions to enable this, great. But I think defaulting this on is really
the wrong thing for our users. We're essentially leaving a usability
landmine in ASan, with no advertisement, and just letting users figure out
why and how to update their linker. That doesn't seem right.

Anyways, that's my 2 cents.
-Chandler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170504/79688653/attachment.html>


More information about the llvm-commits mailing list