From owner-svn-src-all@freebsd.org Thu Mar 30 07:37:18 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD9E8D25F98; Thu, 30 Mar 2017 07:37:18 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 7BFD768F; Thu, 30 Mar 2017 07:37:17 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id F116A1041BC1; Thu, 30 Mar 2017 18:37:09 +1100 (AEDT) Date: Thu, 30 Mar 2017 18:37:08 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Warner Losh cc: Bruce Evans , Poul-Henning Kamp , John Baldwin , Ngie Cooper , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r316132 - head/sys/boot/i386/boot2 In-Reply-To: Message-ID: <20170330180304.O1655@besplex.bde.org> References: <201703290930.v2T9U3x9087583@repo.freebsd.org> <7448826.asYms2TLO2@ralph.baldwin.cx> <46812.1490823365@critter.freebsd.dk> <20170330165329.L1061@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=AYLBJzfG c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=wo_gB0BMNUXkYWCB1KEA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Mar 2017 07:37:18 -0000 On Thu, 30 Mar 2017, Warner Losh wrote: > On Thu, Mar 30, 2017 at 12:23 AM, Bruce Evans wrote: >> I doubt that gcc-6.3 is very broken. Did its CFLAGS even have -Os? > > Yes. boot2 doesn't use the kernel CFLAGS. I know. I even understand most of the magic. My point was that with all the ifdef obfuscations, the flags might not even have -Os. The bug report didn't say. It showed a large set of CFLAGS with -O2 for an unrelated part of the build. >> Kernel CFLAGS are still broken even for gcc-4.2, by sprinkling inline >> parameter magic that was more needed for gcc-3.3. The magic isn't >> really right for gcc-4.2, and breaks -Os for kernels. > > There is different magic for boot2. I know that even better. boot2 is better tuned to save space since this is necessary and possible, but to tune it has to use even more specific flags which are more likely to break. >> The magic might >> be wronger for gcc-6.3, though it would be a compiler bug to not >> just ignore it if it is nonsense. clang doesn't provide any control >> over inlining AFAIK, but ignores gcc directive to limit it and does >> too much. > > Yes. It does. Hence my glowing review of 6.3 :) But you are right. I'm > likely being overly harsh without commanding enough facts to get past > my preconceived notions... I don't know if this is a simple compiler > bug, lack of proper options, or a need to do things differently. > Latter day versions of gcc have many more knobs to turn here. I don't > know yet if turning any of them will be helpful. I'm looking to But -Os should just work to save maximal space. For inlining, this usually means not doing it. But always inline if the result is smaller. boot2 has some manual inlining (static inline...) which might be a (small) problem. It is meant to save space, but might do the opposite. > automate the knob turning so that we can at least see which optimizer > options have an effect on the size. I doubt more than half a dozen > have any useful effect on the size, and finding the right combination > likely will suffice. Or we wait for gcc 7 and hope for the best... I tried changing all of -fomit-frame-pointer, -mrtd and -mregparam a few years ago. They all help a little. -mrtd and -mregparam are then main things that boot2 uses that biosboot did't. I still use biosboot, updated for elf and EDD and with many fixes. The only special CFLAGS that it needs are -Os -fomit-frame-pointer. This works for both gcc-3.3 and gcc-4.2.1, with the latter producing a result 16 bytes smaller. Bruce