Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Oct 2013 22:47:22 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        "Mikhail T." <mi+thun@aldan.algebra.com>
Cc:        stable@FreeBSD.org
Subject:   Re: runtime linker on 9.x/i386: clang vs. gcc
Message-ID:  <AB9F5870-34C1-4D0B-B8FC-F0BFFB156E73@FreeBSD.org>
In-Reply-To: <525C5731.7020809@aldan.algebra.com>
References:  <525C1A5C.2030605@aldan.algebra.com> <B4BCF2B5-5B37-47E1-BCB7-A0159E249E10@FreeBSD.org> <525C5731.7020809@aldan.algebra.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_10AC041B-0784-4787-8E05-DE1A5ECB5445
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

On Oct 14, 2013, at 22:42, "Mikhail T." <mi+thun@aldan.algebra.com> =
wrote:
> 10/14/13 4:31 PM, Dimitry Andric =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=
=B2(=D0=BB=D0=B0):
>> 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=20
>> http://llvm.org/PR15086
>>  (which I unfortunately did not get much
>> response on).
>>=20
> 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).
>>=20
> 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


--Apple-Mail=_10AC041B-0784-4787-8E05-DE1A5ECB5445
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)

iEYEARECAAYFAlJcWF4ACgkQsF6jCi4glqOpbwCfU+Sd5bC5/GbqKHt605hORMJm
AlgAoNbzsYI4BjaksRawA4cwjy9PgQzk
=CoBq
-----END PGP SIGNATURE-----

--Apple-Mail=_10AC041B-0784-4787-8E05-DE1A5ECB5445--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AB9F5870-34C1-4D0B-B8FC-F0BFFB156E73>