mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Thejakiran katikala <katikalathejakiran@elear.solutions>
Cc: musl@lists.openwall.com, ashish <ashish@elear.solutions>,
	manav <manav@elear.solutions>
Subject: Re: [musl] How to deliver a portable shared object using musl
Date: Tue, 18 Jan 2022 10:11:33 -0500	[thread overview]
Message-ID: <20220118151131.GF7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <649a02c95992ea76251370ceeaa3a1cb@elear.solutions>

On Tue, Jan 18, 2022 at 03:28:54PM +0530, Thejakiran katikala wrote:
> Hi Team,
> 
> I know that using musl-libc I can deliver a portable executable.
> Extending this concept, I am trying to deliver a portable shared
> object across various linux distros and architectures. I essentially
> want to reduce the number of combinations I currently have to deal
> with, e.g.:
> 
> Mylib.so linked against glibC across ARM and x86 architectures
> 
> Mylib.so linked against musl-libc across ARM and x86 architectures
> 
> Mylib.so linked against uClibC across ARM and x86 architectures
> 
> To reduce the number of deliverables, I wanted to squash musl-libC
> into Mylib.so and suppress all the conflicting symbols with
> glibc/uClibC, etc..
> 
> So conceptually MyLib.so carries a copy of musl-libC such that I
> don't have any external dependencies on the system where a 3rd party
> developer could write his application on top of my library.
> 
> For e.g. he could create an executable by compiling and linking on
> Ubuntu x64_64: main.c + MyLib.so.x86_64 + glibC.so.x86_64
> 
> Is the above possible? Can MyLib.so.x86_64 with musl-libc squashed
> into it with all symbols suppressed to avoid linker conflicts, work
> in a program that also links to glibC? Can musl-libc co-exist with
> glibC OR would there be some run-time conflicts around
> threads/malloc, etc.?

That is not possible. You can't have multiple libcs living in the same
process. Even if you could get rid of the symbol clashes, in general
these functions may depend on global state that won't be initialized
-- or process state managed by the kernel such as the thread pointer,
exit futex addresses, etc. -- that will not match what the other libc
setup.

If you just need "pure library code" like string.h functions, math
functions, etc. then this code can in theory be extracted out of musl
and used independently. Basically, if you can compile it using only
the public musl headers it's safe to use, but if it requires any
internal headers to build, you'd have to check and clean that up. In
particular, anything using syscalls or thread-local storage (including
access to errno) can't be used this way without some adaptation.

A derivative work of musl aimed at the usage case you're talking about
(working safely alongside a host libc, with functionality constrained
by that requirement) would be an interesting project, but outside the
scope of what's being maintained as musl.

Rich

      reply	other threads:[~2022-01-18 15:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  9:58 Thejakiran katikala
2022-01-18 15:11 ` Rich Felker [this message]

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=20220118151131.GF7074@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=ashish@elear.solutions \
    --cc=katikalathejakiran@elear.solutions \
    --cc=manav@elear.solutions \
    --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).