From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23787 invoked by alias); 7 Nov 2011 12:30:37 -0000 Received: (qmail 23753 invoked by uid 22791); 7 Nov 2011 12:30:30 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from c2beaomr07.btconnect.com (HELO mail.btconnect.com) (213.123.26.185) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Nov 2011 12:30:15 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2beaomr07.btconnect.com with ESMTP id FBD77198; Mon, 07 Nov 2011 12:30:12 +0000 (GMT) Cc: gcc-patches@gcc.gnu.org, "Joseph S. Myers" Message-Id: From: Iain Sandoe To: Richard Guenther In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: [PATCH] Fix PR50999, serialize frontend specific flags (-fexceptions) Date: Mon, 07 Nov 2011 12:49:00 -0000 References: X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0301.4EB7CF53.00C2, actions=tag X-Junkmail-Premium-Raw: score=7/50, refid=2.7.2:2011.11.7.102415:17:7.944, ip=81.138.1.83, rules=__MULTIPLE_RCPTS_CC_X2, __HAS_MSGID, __SANE_MSGID, __MSGID_APPLEMAIL, __TO_MALFORMED_2, __CT, __CT_TEXT_PLAIN, __CTE, __MIME_VERSION, __MIME_VERSION_APPLEMAIL, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __HAS_X_MAILER, __X_MAILER_APPLEMAIL, __ANY_URI, __URI_NO_WWW, __URI_NO_PATH, BODY_SIZE_6000_6999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, RDNS_SUSP_GENERIC, __USER_AGENT_APPLEMAIL, RDNS_SUSP, BODY_SIZE_7000_LESS, MULTIPLE_RCPTS X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B020A.4EB7CF55.0120,ss=1,fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=multiengine X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg00927.txt.bz2 On 7 Nov 2011, at 12:17, Richard Guenther wrote: > > This tries to find a way to prepend explicitly set command-line > options > by those implicitly set by the frontend (-fexceptions in this case). > Unfortunately we don't seem to have a good way to extract this > information > easily, so for -fexceptions I hope all frontends set that during > init_options_struct. It would also be nice to preserve the Objective-C flavor (GNU/NeXT), since we have to make a guess for this in darwin.c when in lto. > > Another nice flag to preserve would be the complex eval method, as > LTO currently has > > static void > lto_init_options_struct (struct gcc_options *opts) > { > /* By default, C99-like requirements for complex multiply and divide. > ??? Until the complex method is encoded in the IL this is the > only > safe choice. This will pessimize Fortran code with LTO unless > people specify a complex method manually or use -ffast-math. */ > opts->x_flag_complex_method = 2; > } > > But we have multiple flags that influence it(?) and none(!?) seems > to be set by Fortran frontend specific code ... (and Fortran sets > most options during post_options). > > Joseph, do you have any advise on how to address frontend specific > options in a more general way? I'm trying to re-construct a > command-line that when processed frontend agnostic would produce > the same end-result in global_options as if going through the > frontend. > Is that even possible (do you have option examples that would show > this is impossible?) > > Bootstrap/regtest running on x86_64-unknown-linux-gnu. > > Thanks, > Richard. > > 2011-11-07 Richard Guenther > > PR lto/50999 > * lto-opts.c (append_to_collect_gcc_options): Split out from... > (lto_write_options): ... here. Prepend frontend specific flags. > > Index: gcc/lto-opts.c > =================================================================== > *** gcc/lto-opts.c (revision 181080) > --- gcc/lto-opts.c (working copy) > *************** along with GCC; see the file COPYING3. > *** 34,60 **** > #include "diagnostic.h" > #include "lto-streamer.h" > #include "toplev.h" > > /* Write currently held options to an LTO IL section. */ > > void > lto_write_options (void) > { > struct lto_output_stream stream; > char *section_name; > struct obstack temporary_obstack; > unsigned int i, j; > char *args; > > section_name = lto_get_section_name (LTO_section_opts, NULL, NULL); > lto_begin_section (section_name, false); > memset (&stream, 0, sizeof (stream)); > > obstack_init (&temporary_obstack); > for (i = 1; i < save_decoded_options_count; ++i) > { > struct cl_decoded_option *option = &save_decoded_options[i]; > - const char *q, *p; > > /* Skip frontend and driver specific options here. */ > if (!(cl_options[option->opt_index].flags & (CL_COMMON| > CL_TARGET|CL_LTO))) > --- 34,97 ---- > #include "diagnostic.h" > #include "lto-streamer.h" > #include "toplev.h" > + #include "langhooks.h" > + > + /* Append the option piece OPT to the COLLECT_GCC_OPTIONS string > + set up by OB, appropriately quoted and separated by spaces > + (if !*FIRST_P). */ > + > + static void > + append_to_collect_gcc_options (struct obstack *ob, > + bool *first_p, const char *opt) > + { > + const char *p, *q = opt; > + if (!first_p) > + obstack_grow (ob, " ", 1); > + obstack_grow (ob, "'", 1); > + while ((p = strchr (q, '\''))) > + { > + obstack_grow (ob, q, p - q); > + obstack_grow (ob, "'\\''", 4); > + q = ++p; > + } > + obstack_grow (ob, q, strlen (q)); > + obstack_grow (ob, "'", 1); > + *first_p = false; > + } > > /* Write currently held options to an LTO IL section. */ > > void > lto_write_options (void) > { > + struct gcc_options lang_opts; > struct lto_output_stream stream; > char *section_name; > struct obstack temporary_obstack; > unsigned int i, j; > char *args; > + bool first_p = true; > > section_name = lto_get_section_name (LTO_section_opts, NULL, NULL); > lto_begin_section (section_name, false); > memset (&stream, 0, sizeof (stream)); > > obstack_init (&temporary_obstack); > + > + /* Output options enabled by the frontend explicitely. The C > family > + frontends do that in the init_options_struct langhook. > Eventually > + we should add a langhook that returns a cl_options array that > + is processed before the user options. */ > + memset (&lang_opts, 0, sizeof (lang_opts)); > + lang_hooks.init_options_struct (&lang_opts); > + if (lang_opts.x_flag_exceptions) > + append_to_collect_gcc_options (&temporary_obstack, &first_p, > + "-fexceptions"); > + > + /* Output explicitely passed options. */ > for (i = 1; i < save_decoded_options_count; ++i) > { > struct cl_decoded_option *option = &save_decoded_options[i]; > > /* Skip frontend and driver specific options here. */ > if (!(cl_options[option->opt_index].flags & (CL_COMMON| > CL_TARGET|CL_LTO))) > *************** lto_write_options (void) > *** 82,113 **** > break; > } > > ! if (i != 1) > ! obstack_grow (&temporary_obstack, " ", 1); > ! obstack_grow (&temporary_obstack, "'", 1); > ! q = option->canonical_option[0]; > ! while ((p = strchr (q, '\''))) > ! { > ! obstack_grow (&temporary_obstack, q, p - q); > ! obstack_grow (&temporary_obstack, "'\\''", 4); > ! q = ++p; > ! } > ! obstack_grow (&temporary_obstack, q, strlen (q)); > ! obstack_grow (&temporary_obstack, "'", 1); > ! > ! for (j = 1; j < option->canonical_option_num_elements; ++j) > ! { > ! obstack_grow (&temporary_obstack, " '", 2); > ! q = option->canonical_option[j]; > ! while ((p = strchr (q, '\''))) > ! { > ! obstack_grow (&temporary_obstack, q, p - q); > ! obstack_grow (&temporary_obstack, "'\\''", 4); > ! q = ++p; > ! } > ! obstack_grow (&temporary_obstack, q, strlen (q)); > ! obstack_grow (&temporary_obstack, "'", 1); > ! } > } > obstack_grow (&temporary_obstack, "\0", 1); > args = XOBFINISH (&temporary_obstack, char *); > --- 119,127 ---- > break; > } > > ! for (j = 0; j < option->canonical_option_num_elements; ++j) > ! append_to_collect_gcc_options (&temporary_obstack, &first_p, > ! option->canonical_option[j]); > } > obstack_grow (&temporary_obstack, "\0", 1); > args = XOBFINISH (&temporary_obstack, char *);