static linking of libgcc on linux ?
Erik Trimble
erik.trimble at oracle.com
Tue Sep 21 13:03:43 UTC 2010
I'll need to examine this again. <sigh>
Andrew is correct - the primary reason is to deliver a binary that works
across large swaths of the Linux ecosystem, which, is notorious for
versioning issues with key major libraries.
That said, I think this needs more exploration. We use gcc-3.2.2 (x64)
and gcc-3.2.1 (x86) for the JDK5 & 6 series, and gcc-4.3.0 for JDK7.
So, there should not be any real need to include gcc-2.95 stuff, as that
compiler will almost certainly break when attempting to build JDK5 or 6,
and *will* break trying to do JDK7. The code simply is too advanced for
that old series of compilers (or, more properly, that old series of GCC
is too buggy).
-Erik
On 9/21/2010 3: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.
>
> I wonder if it's worth disabling such linking on distributions. Would
> it lead to a significant reduction in footprint?
>
>> Martin
>>
>> On Sun, Sep 19, 2010 at 23:02, David Holmes<David.Holmes at oracle.com> wrote:
>>> In the j2se/jdk repo make/common/Defs-linux.gmk contains this old code:
>>>
>>> #
>>> # -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
>>> # statically link libgcc but will print a warning with the flag. We don't
>>> # want the warning, so check gcc version first.
>>> #
>>> CC_VER_MAJOR := $(shell $(CC) -dumpversion | $(SED) 's/egcs-//' | $(CUT)
>>> -d'.' -f1)
>>> ifeq ("$(CC_VER_MAJOR)", "3")
>>> OTHER_LDFLAGS += -static-libgcc
>>> endif
>>>
>>> Now we build with gcc 4 we actually don't set -static-libgcc. Can someone
>>> comment on the correctness of this - should we instead be checking for
>>> "ifneq ("$(CC_VER_MAJOR)", "2") ?
>>>
>>> Thanks,
>>> David Holmes
>>>
>
>
--
Erik Trimble
Java System Support
Mailstop: usca22-123
Phone: x17195
Santa Clara, CA
More information about the build-dev
mailing list