mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Feature request: building musl in a portable way
Date: Thu, 21 Dec 2017 16:38:22 -0500	[thread overview]
Message-ID: <20171221213822.GY1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <CA+fZqCW0tc0_9XnLZE6x6g1dLA6_61uZsXNQaT1k9hqWbJmMVw@mail.gmail.com>

On Thu, Dec 21, 2017 at 05:25:31PM +0100, ardi wrote:
> Hi,
> 
> Related (and as an alternative) to a previous post I made asking about
> a way of isolating direct syscalls, I'm thinking about the possibility
> of building musl in a way where functions that need to perform
> syscalls aren't compiled, so this special compiled version of musl
> would have only the functions that don't make syscalls from
> themselves.
> 
> The purpose is being able to run code in system other than Linux,
> replacing such functions by calls to the related functions of the
> system host (provided that functions follow POSIX requirements, of
> course).
> 
> Obviously, I can get this feature by modifying musl, but I'd prefer
> not to modify it, because I'd like to be able to update musl to the
> last version easily, and if I use a modified/customized musl version,
> updating it would require merging, and possibly hard work.
> 
> If there was some way of having a switch in the build system so that
> all functions that make syscalls are not compiled, I could use musl
> without modifying it. Maybe the most elegant way of doing this would
> be by tagging such functions with an special tag, like
> "__function_makes_syscall__" or whatever. But I'm not sure.
> 
> Cheers, and thanks a lot,

I'm not clear what you want to do. A program that doesn't make
syscalls has no input except argv[] and environ[], does not terminate,
and has no output. So such a build of musl is certainly not useful as
a libc. Even if it were, configurable builds that exclude
functionality are intentionally outside the scope of musl; instead,
the project provides fine-grained linking so that you just get what
you need; ports to systems where some underlying functionality is not
possible simply need to make the relevant syscalls fail with ENOSYS.

With that said, my guess is that you're really asking for a way to
take the "pure" code out of musl and make it a library that you can
use on an existing C/POSIX (or non-POSIX C) implementation. This is
interesting, but currently outside the scope of musl, and probably
covers less interesting code than you might expect -- mainly:

- charset conversion (iconv, esp. utf-8 encoder and decoder)
- strstr
- qsort
- tsearch
- math (including complex, except complex isn't very good anyway yet)
- strtod family
- snprintf (but not usable independently of musl's stdio framework)
- mo file (gettext) lookup core (but frontend is not at all pure)

The rest of the pure code is almost entirely uninteresting, I think
(unlikely to provide any advantage over what's almost certainly
already present).

For now, the only way to use this code outside of musl is to copy it
(and possibly rename the identifiers if you need to avoid clashing
with the standard library on an existing system). Roughly half of the
above list are easy to do this with (no reserved-namespace
identifiers, single files or a few isolated related files, etc.) while
the rest have issues that make them invalid in application code
without nontrivial changes. Making it easier to use them outside musl
is an interesting problem but I'm afraid not one I have resources to
devote to at present..

Rich


  reply	other threads:[~2017-12-21 21:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21 16:25 ardi
2017-12-21 21:38 ` Rich Felker [this message]
2017-12-22 16:09   ` ardi
2017-12-22 16:43     ` Rich Felker
2017-12-22 19:04       ` ardi
2017-12-23  8:18         ` Markus Wichmann
2017-12-23 20:57           ` ardi
2017-12-22 17:10     ` Nicholas Wilson
2017-12-22 17:49       ` Rich Felker
2017-12-22 18:01         ` Nicholas Wilson
2017-12-22 18:08           ` Rich Felker
2017-12-22 19:06             ` Nicholas Wilson
2017-12-22 19:27       ` ardi

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=20171221213822.GY1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).