From patchwork Thu Sep 30 17:36:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 66185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8A4AEB6EF2 for ; Fri, 1 Oct 2010 03:36:20 +1000 (EST) Received: (qmail 15236 invoked by alias); 30 Sep 2010 17:36:17 -0000 Received: (qmail 15123 invoked by uid 22791); 30 Sep 2010 17:36:15 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Sep 2010 17:36:09 +0000 Received: (qmail 24307 invoked from network); 30 Sep 2010 17:36:07 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 30 Sep 2010 17:36:07 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.69) (envelope-from ) id 1P1N38-00045f-Co; Thu, 30 Sep 2010 17:36:06 +0000 Date: Thu, 30 Sep 2010 17:36:06 +0000 (UTC) From: "Joseph S. Myers" To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org, bosch@gnat.com, dewar@gnat.com, charlet@act-europe.fr Subject: Re: More use of structures in option processing In-Reply-To: <20100930160716.GH10599@tyan-ft48-01.lab.bos.redhat.com> Message-ID: References: <20100930160716.GH10599@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Thu, 30 Sep 2010, Jakub Jelinek wrote: > On Thu, Sep 30, 2010 at 12:48:27PM +0000, Joseph S. Myers wrote: > > * The optimize and optimize_size variables move into the gcc_options > > structure (so requiring the changes to files that redeclare them or > > that have function parameters with those names). > > This change broke Ada bootstrap it seems, ada/opts.ads has > Optimization_Level : Int; > pragma Import (C, Optimization_Level, "optimize"); > -- Constant reflecting the optimization level (0,1,2,3 for -O0,-O1,-O2,-O3) > -- See jmissing.c and aamissing.c for definitions for dotnet/jgnat and > -- GNAAMP back ends. > > Optimize_Size : Int; > pragma Import (C, Optimize_Size, "optimize_size"); > -- Constant reflecting setting of -Os (optimize for size). Set to nonzero > -- in -Os mode and set to zero otherwise. See jmissing.c and aamissing.c > -- for definitions of "optimize_size" for dotnet/jgnat and GNAAMP backends > > No idea whether it is possible just to change the "optimize" string to > "global_options.x_optimize" or whether some other change is needed. The following is a minimal fix to define these variables for Ada. It at least allows Ada-enabled stage 1 to build; OK to commit? (Ada doesn't appear to have any equivalent of the "optimize" attribute that would allow these variable settings to change after the post_options hook is called so setting variables in that hook should be sufficient.) In general it would be best for Ada to avoid accessing variables and functions from core GCC directly like this from Ada code, as such uses will break when something becomes a macro, or fail to break in an obvious way if the type of a function or variable changes incompatibly. Thus I'd advise the Ada maintainers to consider making the code use gnat_optimize and gnat_optimize_size or similar variables here (so avoiding the #undef), and similarly using Ada-specific copies (set in the gnat_post_options hook) of flag_stack_check and flag_compare_debug. This seems in accordance with the Ada-language code trying to avoid being too closely tied to the GCC back end except via the gcc-interface code. (I don't see any actual *use* of the imported Optimize_Size, so maybe everything related to that variable could simply go away. But Optimization_Level is used.) 2010-09-30 Joseph Myers * gcc-interface/misc.c (optimize, optimize_size): Undefine as macros and define as variables. (gnat_post_options): Set optimize and optimize_size variables. Index: gcc-interface/misc.c =================================================================== --- gcc-interface/misc.c (revision 164751) +++ gcc-interface/misc.c (working copy) @@ -303,6 +303,13 @@ gnat_init_options (unsigned int decoded_ flag_zero_initialized_in_bss = 0; } +/* Ada code requires variables for these settings rather than elements + of the global_options structure. */ +#undef optimize +#undef optimize_size +int optimize; +int optimize_size; + /* Post-switch processing. */ static bool @@ -334,6 +341,9 @@ gnat_post_options (const char **pfilenam if (write_symbols == DWARF2_DEBUG) use_gnu_debug_info_extensions = gnat_dwarf_extensions > 0; + optimize = global_options.x_optimize; + optimize_size = global_options.x_optimize_size; + return false; }