From owner-freebsd-current@FreeBSD.ORG Mon Sep 16 06:52:18 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D1CB7F9C; Mon, 16 Sep 2013 06:52:18 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8FA872184; Mon, 16 Sep 2013 06:52:18 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::4d45:b112:cc4e:67ea] (unknown [IPv6:2001:7b8:3a7:0:4d45:b112:cc4e:67ea]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id B15B85C44; Mon, 16 Sep 2013 08:52:14 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_10F05718-9A22-4127-B9A0-89053E7BB6B3"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: -ffunction-sections, -fdata-sections and -Wl,--gc-sections From: Dimitry Andric In-Reply-To: Date: Mon, 16 Sep 2013 08:52:01 +0200 Message-Id: References: To: Adrian Chadd X-Mailer: Apple Mail (2.1510) Cc: Ed Schouten , FreeBSD Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Sep 2013 06:52:18 -0000 --Apple-Mail=_10F05718-9A22-4127-B9A0-89053E7BB6B3 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On Sep 16, 2013, at 03:08, Adrian Chadd wrote: >> The results are interesting. On amd64: >> >> - devd suddenly becomes 500 KB in size, instead of a megabyte, >> - init's size drops from 900 KB to 600 KB, >> - clang becomes a megabyte smaller. >> > > .. so, I'd like to know specific information as to why these three are now > smaller. So what's going on? This is simply unreferenced code and data being eliminated. It is quite normal for libraries (libc, the LLVM libs, etc) to contain functions that aren't called by the program you are linking. However, any .o file with multiple functions in it will be linked in as a whole, even if just one of the functions is called. I really think functions and data should always be separately "packaged" in object files, but for some reason this has never been the default for GNU tools, and everybody has apparently copied the behavior. :-) -Dimitry --Apple-Mail=_10F05718-9A22-4127-B9A0-89053E7BB6B3 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.20 (Darwin) iEYEARECAAYFAlI2qp0ACgkQsF6jCi4glqNK2QCgxv0f/dTe+zYeVvpnz0kZfu80 N98AoNrFoJIo0eKO4vL8cRE5i2tL/r9k =MnYI -----END PGP SIGNATURE----- --Apple-Mail=_10F05718-9A22-4127-B9A0-89053E7BB6B3--