This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: using -static
Marco Trudel writes:
> David Daney wrote:
> > Andrew Haley wrote:
>
> > As time passes, libgcj is doing more and more dynamic linking. A static
> > libc does not work well with dynamic linking. Static linking against
> > libc really only makes sense in the situation where there is only a
> > single executable image running in the entire system (ala busybox).
> > Unless you are working on small embedded systems, it is almost always
> > the wrong thing to do.
>
> I'm not very familiar with this topic, so I don't understand everything
> you and Andrew told me. So I would summarize like this:
>
> I shouldn't use "-static", because it does some nasty dynamic/static
> linking stuff. I could use -static-libgcj, that does more or less the
> same as using a --disable-shared built gcj?!
You shouldn't use -static because it statically links against libc.
This is a horrible thing to do, because libc is really part of the
operating system and its environment. The libc that is installed on a
computer is configured for the kernel and the environment in which the
computer is being used. The installed libc gets regular bug fixes and
enhancements. If the libc you statically linked against has a
security flaw, that's too bad: it'll never be fixed. In addition to
that, there are, er, issues with loading shared libraries against a
static libc.
It is never appropriate for an application to carry around its own
version of libc with it.
Andrew.