runtime linker on 9.x/i386: clang vs. gcc

Dimitry Andric dim at FreeBSD.org
Mon Oct 14 20:47:41 UTC 2013


On Oct 14, 2013, at 22:42, "Mikhail T." <mi+thun at aldan.algebra.com> wrote:
> 10/14/13 4:31 PM, Dimitry Andric написав(ла):
>> There is a problem when clang does tail-call optimization on i386 with
>> PIC in effect, and it emits GOT relocations for the tail-called
>> functions, instead of PLT relocations.  In some scenarios, such as with
>> the way X.org does lazy dynamic linking, this can cause problems.  See
>> also 
>> http://llvm.org/PR15086
>>  (which I unfortunately did not get much
>> response on).
>> 
> Ouch... That seems like a show-stopper for clang-adoption... At least, on i386.

Well, the scenario is very difficult to reproduce, at least when I tried
it.  You must have a very specific way of dynamically loading objects,
and you must load them in the "wrong" order, or the problem will not
occur.  Normally linked .so's do not have this problem at all.  So
hardly a showstopper, 10.0 is being released with clang as we speak. :-)


>> For now, a workaround is to recompile the affected .so files with
>> -fno-optimize-sibling-calls (if you are optimizing).
>> 
> Maybe, our clang (both src/ and ports/) should be compiled with that being in effect by default on i386?

For the specific cases where it occurs (as far as I knew until know,
only certain X.org drivers) it might be enough to just use
-fno-optimize-sibling-calls.  If this problem occurs more often, I will
see if I can make it the default for i386-with-PIC.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20131014/19318cd4/attachment.sig>


More information about the freebsd-stable mailing list