From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTP id 6419D3944422 for ; Wed, 18 Mar 2020 21:24:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6419D3944422 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEgAa-0006Oo-48 for gcc-help@gcc.gnu.org; Wed, 18 Mar 2020 17:24:09 -0400 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 Received: from gate.crashing.org ([63.228.1.57]:52544) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEgAZ-0006OX-U2 for gcc-help@gcc.gnu.org; Wed, 18 Mar 2020 17:24:08 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 02ILO4Nx012708; Wed, 18 Mar 2020 16:24:05 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 02ILO4Fm012707; Wed, 18 Mar 2020 16:24:04 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 18 Mar 2020 16:24:04 -0500 From: Segher Boessenkool To: mark_at_yahoo Cc: gcc-help@gcc.gnu.org Subject: Re: question about knowing when optimization options are used Message-ID: <20200318212404.GM22482@gate.crashing.org> References: <20200316233406.GE22482@gate.crashing.org> <120d7b44-50b6-1868-18e5-27cedd12439a@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <120d7b44-50b6-1868-18e5-27cedd12439a@yahoo.com> User-Agent: Mutt/1.4.2.3i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 21:24:10 -0000 On Wed, Mar 18, 2020 at 10:44:09AM -0700, mark_at_yahoo via Gcc-help wrote: > On 3/16/20 4:34 PM, Segher Boessenkool wrote: > >You can enable the *flags*, sure, but with -O0 those flags do not do > >anything. Exactly as the text above says? The "even if" part. > Sorry to question this, but my experience has been otherwise. >From the manual again: Most optimizations are completely disabled at '-O0' or if an '-O' level is not set on the command line, even if individual optimization flags are specified. Similarly, '-Og' suppresses many optimization passes. > I haven't > tried it in a while (probably last did on an older release) but at least > with gcc-arm, doing: > > -O0 \ > -fbranch-count-reg \ > -fcombine-stack-adjustments \ > -fcompare-elim \ > -fcprop-registers \ > > > *did* do something different than just "-O0". It might be interesting to see which compiler flag(s) you see any differences with. > 2) My code includes header files with literally thousands (no > exaggeration) of "static const int ..."s > 3) The code (intentionally) uses only a handful of the consts > 4) If compiled "-O1", no memory is allocated for the thousands of consts > (not even the few that are used) > 5) If compiled "-O0" memory is allocated for each const -- far more > memory than is available > 6) "-O0" executables are much easier to debug at the machine instruction > level (sometimes necessary on microcontrollers) > > Can anyone suggest a minimal set of "-f"s to add to -O0 which > will do what I want, i.e. no code optimizations, but also no memory > allocated for the consts? Try -Og instead? It is mostly like -O1, but almost all debugging should work fine with it (as the option name itself suggests :-) ) Segher