tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] error: Unknown relocation type for got: 23 with -stat


From: Christian Jullien
Subject: Re: [Tinycc-devel] error: Unknown relocation type for got: 23 with -static
Date: Thu, 4 Jun 2020 06:31:32 +0200

Hi Michael,

> do you happen to know which ones are the case for you?  (E.g. register 
> reduction due to position independend code on i386; or function call overhead 
> for do-mostly-nothing functions; or something else?)

Lisp interpreter calls zillion of small functions, overhead is clearly the 
culprit where the penalty is around 5%-10%. It is less obvious with compiled 
code where most common accessors are inlined by the compiler.
I also designed several ultra fast optimized C++ libraries used in by automatic 
low latency trading applications where each nanosecond matters (code is 
compiled by PGO and many other optimization technics). Shared lib is close to 
10% slower compared to static one.
Needless to say that we don't advice customers to use dynamic libs but they 
generally know that and all their code is also static.

C.

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On 
Behalf Of Michael Matz
Sent: Wednesday, June 03, 2020 17:16
To: jullien@eligis.com; tinycc-devel@nongnu.org
Cc: John Scott
Subject: Re: [Tinycc-devel] error: Unknown relocation type for got: 23 with 
-static

Hello,

On Sun, 31 May 2020, Christian Jullien wrote:

> I confirm! I tested this sample with mod on Debian RPi 4 armv7l and had a
> similar error:
>
> $ tcc -static foo.c
> tcc: error: Unknown relocation type for got: 107

This, as well as Scotts problem, are relocations for thread local storage. 
Several facilities of glibc (and other libc's) are implemented as thread 
local variables (e.g. 'errno' is thread local, as well as some management 
structures for the malloc implementation) and when linking statically all 
of these are exposed to TCC.

TCC doesn't implement thread local storage, so that's why there's the 
error.  As long as that's the case static linking against glibc (or any 
other library containing such variables) isn't going to work.

I have a patch somewhere that implements TLS at least for x86-64, maybe I 
find time to dust it off over the next days.  Until then: missing feature 
in TCC with not workaround except not linking statically.

> $ tcc foo.c
>
> -hh help says:
>  -static                       link to static libraries (not recommended)
>
> Why is it not recommended? Because it is not well supported or just because
> shared lib, by ideology, is generally preferred?

I think the comment is indeed about the general recommendation to not link 
statically.  But it should be noted that linking statically against glibc 
specifically is even more discouraged.  I.e. even if you link most of an 
executable statically glibc should stay as shared library dependency.

> My OpenLisp comes in two flavors with gcc: static and shared. When speed
> matters, I recommend the static one which is significantly faster.

A significant performance difference should only happen in fairly special 
circumstances.  Out of couriosity: do you happen to know which ones are 
the case for you?  (E.g. register reduction due to position independend 
code on i386; or function call overhead for do-mostly-nothing functions; 
or something else?)


Ciao,
Michael.

>
> C.
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org]
> On Behalf Of John Scott
> Sent: Saturday, May 30, 2020 16:55
> To: tinycc-devel@nongnu.org
> Subject: [Tinycc-devel] error: Unknown relocation type for got: 23 with
> -static
>
> Hi,
>
> I was trying to do a build of Tor statically but ran into this issue with
> current master and 0.9.27 package in Debian. I can reproduce with this:
> #include <stdlib.h>
> int main(){ char *p = NULL; free(p); }
>
> and tcc -static gives the error. Is this a bug in tcc or elsewhere?
>
> Sincerely,
> John Scott
>
>
> _______________________________________________
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]