mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: static build and dlopen
Date: Wed, 27 Aug 2014 12:43:09 -0400	[thread overview]
Message-ID: <20140827164309.GO12888@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAKfGGh16bu6Lhc+EF0d1EiNzhs4V0LxShA3iiw-z50NwbfNQPw@mail.gmail.com>

On Wed, Aug 27, 2014 at 04:14:07PM +0200, piranna@gmail.com wrote:
> So I ask, does the dlopen() stub really makes sense (the linker is
> intelligent enought to remove unused code on static builds...)? Is
> there any alternative I can do? Is there a flag to allow to use the
> real dlopen() function on static builds, or could it be possible to
> add it? If not, could I be able to use an external dlopen library (and
> could I be able to integrate it easily)?

As nsz explained, it's not that simple. At some point we want to have
a solution for usage cases like what you want, but it's actually quite
difficult to make it work correctly, and rather than using static
linking directly, it might actually be preferable, for supporting your
usage case, to have a tool which merges the main program, dynamic
linker/libc, and any .so's you want to include statically into one big
file. But this is not entirely trivial either.

As for a possible workaround, you can link your program dynamically
(possibly including most of the libraries that your modules _won't_
need to reference as static-linked in the main program binary) and
include a wrapper script, or wrapper static-linked-binary, to exec
your program explicitly via the dynamic linker, as in:

    /path/to/ld-musl-i386.so.1 -- /path/to/your/node "$@"

or similar. This avoids the need to have musl "installed" on the
target system; everything can be in a self-contained directory. I know
some users are already doing something like this for deployments;
maybe at some point we'll think about making some official tools to
make it easier.

Rich


  parent reply	other threads:[~2014-08-27 16:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 14:14 piranna
2014-08-27 15:27 ` Szabolcs Nagy
2014-08-27 17:01   ` piranna
2014-08-27 17:20     ` Justin Cormack
2014-08-27 20:07       ` piranna
2014-08-27 16:43 ` Rich Felker [this message]
2014-08-27 17:10   ` piranna
2014-08-27 18:48     ` Laurent Bercot
2014-08-27 20:19       ` piranna
2014-08-27 20:51         ` Rich Felker
2014-08-27 20:59         ` Laurent Bercot
2014-08-27 21:04           ` Rich Felker
2014-08-27 22:54           ` Kurt H Maier
2014-08-27 23:24             ` Laurent Bercot
2014-08-27 23:36               ` Brent Cook
2014-09-01 23:38                 ` piranna
2014-09-02  0:38                   ` Rich Felker
2014-09-02  0:49                     ` piranna

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=20140827164309.GO12888@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).