Date: Thu, 19 Feb 2015 11:23:55 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Bryan Drewery <bdrewery@freebsd.org> Subject: Re: svn commit: r278889 - head/lib/libc/include Message-ID: <20150219092355.GE34251@kib.kiev.ua> In-Reply-To: <20150219113226.K2984@besplex.bde.org> References: <201502170854.t1H8s4TL085174@svn.freebsd.org> <54E52019.8080009@FreeBSD.org> <20150219113226.K2984@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Feb 19, 2015 at 11:58:48AM +1100, Bruce Evans wrote: > On Wed, 18 Feb 2015, Bryan Drewery wrote: > > > On 2/17/2015 2:54 AM, Konstantin Belousov wrote: > >> ... > >> Log: > >> Restore the extern qualifier on __cleanup. > >> ... > >> Modified: head/lib/libc/include/libc_private.h > >> ============================================================================== > >> --- head/lib/libc/include/libc_private.h Tue Feb 17 08:50:26 2015 (r278888) > >> +++ head/lib/libc/include/libc_private.h Tue Feb 17 08:54:03 2015 (r278889) > >> @@ -271,7 +271,7 @@ void _malloc_first_thread(void); > >> /* > >> * Function to clean up streams, called from abort() and exit(). > >> */ > >> -void (*__cleanup)(void) __hidden; > >> +extern void (*__cleanup)(void) __hidden; > >> > >> /* > >> * Get kern.osreldate to detect ABI revisions. Explicitly > >> > > > > Is this a NOP? > > No, since this is a data declaration. It would be a style bug on a > prototype. > > BTW, the reason for existence of __cleanup() has been broken by malloc() > and other bloatware. It is to avoid linking anything in stdio when > only exit() is used. But crtso now links to malloc() and malloc() > links to stdio and much more. When correctly (that is, statically) > linked, this bloats the size of a minimal C program from to 440K + 80K > symbols on amd64 and to 390K + 60K symbols on i386. In FreeBSD-4 and > in my version of FreeBSD-5, __cleanup still works and the minimal C > program has size 2K + 1.5K symbols. In FreeBSD-5, malloc() is > relatively unbloated, so crtso's linking to it costs only 9K + 9K > symbols instead of 400+K. The same program written in asm takes about > 10 bytes in all versions of FreeBSD-x86. When dynamically linked, > __cleanup() has little effect. I briefly looked at the possibility of removing __cleanup (*). Besides ensuring that all stdio FILEs are flushed at exit(3), it also ensures that stdio finalization is performed as the last action, after the whole chain of atexit(3) handlers was called. To repeat this behaviour, the flush handler must be registered very early, which would just mirror special behaviour of __cleanup, but at the startup. * Bruce, I do understand that your response is that we should fix malloc to not depend on stdio instead.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150219092355.GE34251>