From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12224 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] split __libc_start_main.c into two files (Wasm) Date: Thu, 7 Dec 2017 12:03:56 -0500 Message-ID: <20171207170356.GX1627@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1512666251 5378 195.159.176.226 (7 Dec 2017 17:04:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 7 Dec 2017 17:04:11 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12240-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 07 18:04:06 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eMzaf-0001Ef-Qi for gllmg-musl@m.gmane.org; Thu, 07 Dec 2017 18:04:05 +0100 Original-Received: (qmail 21683 invoked by uid 550); 7 Dec 2017 17:04:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 21665 invoked from network); 7 Dec 2017 17:04:09 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12224 Archived-At: On Thu, Dec 07, 2017 at 02:51:31PM +0000, Nicholas Wilson wrote: > Hi, > > I've got some more patches to try and get in for Wasm support. > > Here's one that should be fairly straightforward? In Musl, most > (non-static) functions are in a file of their own, which is good > from a linkage point of view. > > I'd like to have __libc_start_main.c split into two files, because > for Wasm I'd like to be able to call __libc_start_init (from within > the CRT directory) but without having to link in exit(), since many > Wasm applications will never call exit() and won't necessarily use > main. > > There's no pollution of the codebase, it's purely splitting a file. > > Patch below. __libc_start_init is intentionally not a public interface but part of musl internals. There is no reason to assume it will continue to exist with the same name or interface in future versions of musl. The public interface for the entry point is __libc_start_main. exit() is literally 9 instructions on x86_64, and likely comparably small elsewhere. I don't see how trying to optimize it out makes sense. The bulk of the code that runs at exit() when there's nontrivial work to do at exit time is linked through dependencies from other sources like stdio and atexit, and would be linked even if you succeeded in optimizing exit out. Rich