Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 20 Apr 2014 16:31:40 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: static musl-based gdb and -fPIC

On Sun, Apr 20, 2014 at 01:03:12PM -0400, writeonce@...ipix.org wrote:
> Greetings,
> 
> While building a statically linked musl-based gdb, ld asked that
> libc.a be recompiled with -fPIC.

This is a bug in the gdb build process. Despite your request for a
static gdb, it's trying to build a shared library for something.
There's a way to disable it (IIRC --disable-gdbserver is a big hammer
that can do it, and there might be a more fine-grained approach) but
the real issue is that the build process is broken and doing something
that can't work.

> After recompiling musl with the
> above flag, gdb built successfully.  The reason I wanted to have a
> static gdb (other than the trivial ones) was to be able to debug a
> musl-based python.  The distribution's gdb has a dynamic dependency
> on a glibc-based libpython, and the two friends don't play well
> together.
> 
> Now that the static gdb is up and running, my questions are:
> 
> 1) is there any reason not to "always" compile musl with -fPIC, at
> least on x86_64?

Compare the .lo and .o files. I think you'll find the .lo files are a
considerably more bloated and slower -- not as bad as on 32-bit x86,
but still undesirable.

Some users will want to use -fPIC even for static linking to be able
to produce static PIE binaries, but this is not a mainstream usage
(there's not even any official toolchain support for it, just a local
hack I posted to the list a year or two back) and not something we
would want to impose on everyone.

> 2) is there any reason to revert to the old build of libc.so?
> Although I rebuilt musl because of libc.a, it turns out that the
> -fPIC flag also helped libc.so become much smaller: 699299 bytes,
> instead of 2767910 bytes (musl v1.0.0, binutils v2.24).  Any other
> factors to consider?

You must have done something else like disabling debugging info at the
same time.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.