static linking of libgcc on linux ?

Andrew Haley aph at redhat.com
Mon Sep 27 10:06:20 UTC 2010


On 09/21/2010 11:32 AM, Dr Andrew John Hughes wrote:
> On 21 September 2010 07:33, Martin Buchholz <martinrb at google.com> wrote:

>> This appears to be another case where the hotspot and jdk repo
>> makefiles differ.
>>
>> hotspot does:
>>
>> # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
>> ifneq ("${CC_VER_MAJOR}", "2")
>> STATIC_LIBGCC += -static-libgcc
>> endif
>>
>> making it look like the jdk repo makefile is in error.
>>
>> I continue to be surprised that with all the strange fiddling with
>> linker flags (use of -static-libgcc is not encouraged), that jdk
>> binaries have such a high degree of binary compatibility.
> 
> I would imagine this static linking is to aid binary compatibility,
> allowing Oracle to ship binaries which work with different versions
> of gcc and glibc (which I believe is also statically linked) than
> that it is built against.

In practice, it's often the other way round: static linking with
libgcc on GNU/Linux causes more problems than it solves.  If we're not
linking statically with libgcc now, it would be risky to start doing
so again.

> I wonder if it's worth disabling such linking on distributions.  Would
> it lead to a significant reduction in footprint?

libgcc is a small library.

Andrew.



More information about the build-dev mailing list