public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Alejandro Colomar <alx.manpages@gmail.com>
Cc: "Cristian Rodríguez" <crrodriguez@opensuse.org>,
	"G. Branden Robinson" <g.branden.robinson@gmail.com>,
	"Jonny Grant" <jg@jguk.org>,
	"Florian Weimer" <fweimer@redhat.com>,
	"Michael Kerrisk" <mtk.manpages@gmail.com>,
	linux-man <linux-man@vger.kernel.org>,
	"GNU C Library" <libc-alpha@sourceware.org>
Subject: Re: Internal organization of "the implementation" (was: [PATCH] Add example to rand.3)
Date: Fri, 30 Dec 2022 21:50:16 +0000	[thread overview]
Message-ID: <b754dc-d68c-6a66-50a7-4153ca6537f1@codesourcery.com> (raw)
In-Reply-To: <49e90587-8f1a-111e-8937-40afbbf55106@gmail.com>

On Fri, 30 Dec 2022, Alejandro Colomar via Libc-alpha wrote:

> Why is this duplication of responsibility for libc functions?  Why isn't there

There isn't duplication.  Each function is the responsibility of exactly 
one of the compiler and the libc; GCC's documentation, once updated for 
C2x, will reflect which parts it expects to provide and which it expects a 
corresponding libc to provide.

> a smaller say libmem that provides a unique implementation for these memcpy(),
> memmove(), memset() functions, and both gcc and glibc (and even the kernel
> could, with static linking) depend on it?

The design follows from the traditional structure of libc on Unix systems 
(containing both functions closely related to the OS and functions that 
only depend on the CPU architecture and not the OS) and GCC's early role 
as an alternative to the system compiler there.  It's possible to 
structure libraries in lots of different ways (I don't know if BSD systems 
actually share parts of libc with the kernel, but they certainly tend to 
have closer integration of code across the whole system, for example).  
Non-C-family languages are probably a better place for exploring the 
design space of different divisions among compilers and libraries, than C 
libraries that are expected to fit with existing tooling, build systems 
and operating systems (and certainly the extreme case of a very large 
number of separately maintained tiny libraries in some such language 
environments shows up its own problems with dependency management).

In practice, while there's sometimes sharing at the level of a third-party 
source code repository providing code that can be used in multiple places 
(see Arm's optimized routines, for example), including code in shared 
libraries and using features such as IFUNC, along with e.g. some objects 
having multiple entry points and other libc-internal symbol handling 
requiring close coordination among the build of all linked objects, makes 
it hard to share at the object code level.  And we've tended lately to 
move *away* from separate small shared libraries - rather, integrating 
formerly separate libraries such as libpthread into the single shared 
libc.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2022-12-30 21:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <105835f5-359c-2646-f609-e73459ee2d3b@jguk.org>
2022-12-26 22:29 ` [PATCH] Add example to rand.3 Alejandro Colomar
2022-12-27 13:07   ` Cristian Rodríguez
2022-12-27 23:33     ` Alejandro Colomar
2022-12-28  0:00       ` G. Branden Robinson
2022-12-28  0:41         ` Alejandro Colomar
2022-12-28 12:21           ` Cristian Rodríguez
2022-12-30 18:15             ` Joseph Myers
2022-12-30 18:20               ` Alejandro Colomar
2022-12-30 18:50                 ` Joseph Myers
2022-12-30 18:58                   ` Alejandro Colomar
2022-12-30 19:11               ` Cristian Rodríguez
2022-12-30 21:08                 ` Joseph Myers
2022-12-30 21:15                   ` Internal organization of "the implementation" (was: [PATCH] Add example to rand.3) Alejandro Colomar
2022-12-30 21:50                     ` Joseph Myers [this message]
2022-12-27 21:37   ` [PATCH] Add example to rand.3 Jonny Grant
2022-12-27 23:11     ` Alejandro Colomar
2022-12-28 20:51       ` Jonny Grant
2022-12-28 20:56         ` Alejandro Colomar
2022-12-28 21:03           ` Alejandro Colomar
2022-12-28 21:04             ` Alejandro Colomar
2022-12-28 21:25               ` Jonny Grant
2022-12-28 21:32                 ` Alejandro Colomar
2022-12-28 21:04           ` Cristian Rodríguez
2022-12-28 21:11             ` Alejandro Colomar
2022-12-28 21:19               ` Jonny Grant
2022-12-28 21:18             ` Alejandro Colomar

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=b754dc-d68c-6a66-50a7-4153ca6537f1@codesourcery.com \
    --to=joseph@codesourcery.com \
    --cc=alx.manpages@gmail.com \
    --cc=crrodriguez@opensuse.org \
    --cc=fweimer@redhat.com \
    --cc=g.branden.robinson@gmail.com \
    --cc=jg@jguk.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).