mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: [PATCH 0/5] reorganize the use of weak symbols
Date: Sat, 16 Feb 2013 00:59:37 -0500	[thread overview]
Message-ID: <20130216055937.GC20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <cover.1360968989.git.Jens.Gustedt@inria.fr>

On Sat, Feb 16, 2013 at 12:22:03AM +0100, Jens Gustedt wrote:
> Weak symbols are used for several uses that are in fact quite distinct.

First some general comments -- I think this patchset might be arising
as a result of a clash of style/philosophy. As an analogy, "int" can
be be used for several things that are distinct. If there's a
possibility that int could be the wrong type on some systems or
configurations, it makes sense to use a typedef and a distinct type
name. But if int were already the correct type in all cases, using a
typedef just creates a barrier to reading comprehension in the code --
the reader has to go lookup what the type is defined as, only to find
that it's unconditionally "int". A great example of this kind of
obfuscation is glib.

In my view, what's going on here is in some ways similar. Weak aliases
are the right mechanism in all cases, but if you hide that with
different usage-specific macros, you create a barrier to reading where
the reader might think there's something more complicated going on
behind all the different macros.

As for weak functions rather than aliases, it was a conscious choice
early on to use a minimum number of gcc- or gnu-linker-specific
features. Unlike other weak symbol related features, weak aliases are
universally available on all unix-like toolchains; they were even part
of SVID, which specifies #pragma weak to define them; a C99 compiler
following this practice would necessarily need to support _Pragma
weak, which could be used to define the weak_alias macro in a
"portable" way. Whether there's any practical value now to minimizing
the use of non-essential gcc features is open to question, but I see
no need to gratuitously increase the number used.

With that said, one thing I highly agree with in your patchset is
documenting the different weak alias tricks used in musl --
specifically, commenting on which weak aliases are expected to be
replaced by strong definitions, and under what conditions those strong
definitions come into place.

I also can see some use for having common dummy functions, but I'd
have to review how you're proposing to do it because I remember
looking into this before and finding that it didn't work as I
expected. However, the savings are likely to be very small, since
dummy functions are typically just 1-2 bytes on x86 (depending on the
-mtune mode) and 4 bytes on risc archs.

I'll give a more detailed review of individual patches later; I just
wanted to get this email off so you have ideas early on where you're
probably going to run into differences of opinion.

Rich


  parent reply	other threads:[~2013-02-16  5:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-15 23:22 Jens Gustedt
2013-02-15 23:23 ` [PATCH 1/5] Clearly identify the readonly replacement symbols that serve as 'dummies' that could (or could not) be provided by other compilation units Jens Gustedt
2013-02-15 23:23 ` [PATCH 2/5] Clarify the implementation of the dummy alias used for pthread_self Jens Gustedt
2013-02-15 23:24 ` [PATCH 3/5] identify the weak function symbols that provide a real default action Jens Gustedt
2013-02-15 23:24 ` [PATCH 4/5] add three macros for empty dummy functions that do nothing Jens Gustedt
2013-02-15 23:25 ` [PATCH 5/5] Use the weak functions that do nothing as aliases for the default actions Jens Gustedt
2013-02-16  5:59 ` Rich Felker [this message]
2013-02-16  8:16   ` [PATCH 0/5] reorganize the use of weak symbols Jens Gustedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130216055937.GC20323@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).