From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5934 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: static build and dlopen Date: Wed, 27 Aug 2014 12:43:09 -0400 Message-ID: <20140827164309.GO12888@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1409157809 12169 80.91.229.3 (27 Aug 2014 16:43:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Aug 2014 16:43:29 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5941-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 27 18:43:22 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XMgJe-0001jL-Dl for gllmg-musl@plane.gmane.org; Wed, 27 Aug 2014 18:43:22 +0200 Original-Received: (qmail 1697 invoked by uid 550); 27 Aug 2014 16:43:21 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1683 invoked from network); 27 Aug 2014 16:43:21 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:5934 Archived-At: 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