From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2428 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: static linking and dlopen Date: Sat, 8 Dec 2012 18:23:01 -0500 Message-ID: <20121208232301.GW20323@brightrain.aerifal.cx> References: <20121208225237.GV20323@brightrain.aerifal.cx> <50C3CA75.8000504@comcast.net> 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 1355009005 26001 80.91.229.3 (8 Dec 2012 23:23:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Dec 2012 23:23:25 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2429-gllmg-musl=m.gmane.org@lists.openwall.com Sun Dec 09 00:23:38 2012 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 1ThTk8-0002iR-2Z for gllmg-musl@plane.gmane.org; Sun, 09 Dec 2012 00:23:36 +0100 Original-Received: (qmail 28330 invoked by uid 550); 8 Dec 2012 23:23:23 -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 28322 invoked from network); 8 Dec 2012 23:23:23 -0000 Content-Disposition: inline In-Reply-To: <50C3CA75.8000504@comcast.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2428 Archived-At: On Sat, Dec 08, 2012 at 03:17:09PM -0800, Charlie Kester wrote: > I wonder if most of what people want to do with dlopen couldn't be > done just as well (or better) with good old fork() and exec(), along > with some suitable interprocess communication. I think it depends a lot on what you're using dlopen for. A lot of programs these days use it as a ridiculous part of the development model rather than for any real purpose; in my book, this is among the highest levels of Considered Harmful. There's really no reason for any code that's internal to an application (developed in the same tree, by the same authors, and built at the same time) to be dynamically linked at all, much less dynamically loaded. All this accomplishes is making the program a lot slower and more bloated. On the flip side, the main legitimate uses for dynamic linking and loading are (1) sharing code that's used by a wide range of applications and allowing it to be upgraded system-wide all at once, and (2) facilitating the extension of an application with third-party code. Usage 1 applies mostly to dynamic linking; 2 mostly to dynamic loading (dlopen). As for your suggestion that dlopen could largely be replaced by running an external program, that's definitely an alternate way to accomplish extensions/plug-ins (see GIMP, for example). How well it works probably depends on the performance requirements (it's hard to get good performance if the plugin is dealing with high volumes of data unless you develop complex IPC methods using shared memory, so there's a complexity trade-off too) and whether your extensions need to survive across fork (which does not duplicate a process's child process trees; this could very well matter for extension modules used by language interpreters/runtimes like Python, Perl, etc.). Rich