From owner-freebsd-current@FreeBSD.ORG Tue Sep 17 21:45:20 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C23CB8AE; Tue, 17 Sep 2013 21:45:20 +0000 (UTC) (envelope-from edschouten@gmail.com) Received: from mail-vc0-x232.google.com (mail-vc0-x232.google.com [IPv6:2607:f8b0:400c:c03::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6EF9425D2; Tue, 17 Sep 2013 21:45:20 +0000 (UTC) Received: by mail-vc0-f178.google.com with SMTP id ha12so4556051vcb.37 for ; Tue, 17 Sep 2013 14:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=7nEjoARvGooAKjB3kjO8qrSeRoD9RMvB66/L/f15VBs=; b=w83Qx3WmsgBT07VZFY0dCOKQyDLHUp5NIDogoFwq+oSW2024vLVnz+D2qwdGjI59kz ytWQSBYxCAprC9aBuSFOIjVaT4N9JgKkVfL0HsRrh0uB7A7YImZQz+0C1+lnFCCGM6cQ xO/qtMBcoyT/tuly+5DFm1Lv4Ep/eGc6nPeyspoyGiXejiTaPzcSpWJ+aR6NjBh3X34m DsENCike6LQVzpMYSrljxGvlHUyGYof1fhOlaJ3XMIUUpQ+fWF2NHVXy1M0VWU6v8Fzd hkvE2ryB8vAmQW9USgwQsSGBNw+QQJxgjaaV5LhFLqFWCzYkaVKYPuYwgOCTpSDD9JfV mAuQ== MIME-Version: 1.0 X-Received: by 10.52.170.232 with SMTP id ap8mr147814vdc.40.1379454319557; Tue, 17 Sep 2013 14:45:19 -0700 (PDT) Sender: edschouten@gmail.com Received: by 10.220.115.206 with HTTP; Tue, 17 Sep 2013 14:45:19 -0700 (PDT) In-Reply-To: References: Date: Tue, 17 Sep 2013 23:45:19 +0200 X-Google-Sender-Auth: KqzJCrjTQrAvY4OgaT1T3tyWmRk Message-ID: Subject: Re: -ffunction-sections, -fdata-sections and -Wl,--gc-sections From: Ed Schouten To: Matthew Fleming Content-Type: text/plain; charset=UTF-8 Cc: 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: Tue, 17 Sep 2013 21:45:20 -0000 Hi Matthew, 2013/9/16 Matthew Fleming : > Would it be possible to enable this only for devd, init, and clang binaries? > Or is it a matter of enabling it for library builds that are linked > statically with the mentioned binaries? For it to have effect, it has to be enabled for both the libraries and the binaries. The libraries need to be built with -f{data,function}-sections. The binaries can also be built with those flags, but it is actually more important to link with --gc-sections. > Could init/devd be made smaller by > finding out which functions they do/don't use and separating those into > separate .c files? Also trying to answer Tim and Adrian's questions at the same time. I've just taken a look at init and devd to see why the difference in size is so big: init seems to pull in the following things: - Sun RPC, - XDR, - YP, - res_*, - All of the jemalloc profiling/stats code, - Some widechar functions, - malloc-related utility functions that are not used (posix_memalign, aligned_alloc), - Some stdio bloat, - All sorts of termios tc* functions. devd seems to pull in these: - A very big pile of C++ symbols, as libc++ places many functions in a single file. - jemalloc profiling/stats again, - A big pile of pthread, - Maybe *_l() functions, which are of course rarely used. Honestly, I think we can assume we'll never reach the point where all the components listed above will properly have all functions partitioned over separate compilation units. I suspect that it would make a lot of sense to at least enable these build flags for our core libraries (libc, libc++, libpthread, libcompiler_rt, libcxxrt, etc). We could also enable it on INTERNALLIBs (libraries that are not installed into /usr/lib), as for these libraries, it would of course not come at any cost. Would that sound okay? -- Ed Schouten