public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Sandoe <developer@sandoe-acoustics.co.uk>
To: Richard Guenther <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, "Joseph S. Myers" <joseph@codesourcery.com>
Subject: Re: [PATCH] Fix PR50999, serialize frontend specific flags (-fexceptions)
Date: Mon, 07 Nov 2011 12:49:00 -0000	[thread overview]
Message-ID: <D3E274F5-74DE-47E1-A1D1-01CB70E570A5@sandoe-acoustics.co.uk> (raw)
In-Reply-To: <alpine.LNX.2.00.1111071311130.4527@zhemvz.fhfr.qr>


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  <rguenther@suse.de>
>
> 	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 *);

  parent reply	other threads:[~2011-11-07 12:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 12:40 Richard Guenther
2011-11-07 12:49 ` Eric Botcazou
2011-11-07 13:08   ` Richard Guenther
2011-11-07 14:11     ` Richard Guenther
2011-11-08  0:30     ` Joseph S. Myers
2011-11-07 12:49 ` Iain Sandoe [this message]
2011-11-07 12:50   ` Richard Guenther
2011-11-07 12:51     ` Iain Sandoe
2011-11-07 13:15       ` Richard Guenther
2011-11-08  0:30       ` Joseph S. Myers
2011-11-08 14:51         ` Iain Sandoe
2011-11-08 14:53           ` Richard Guenther
2011-11-08  0:27 ` Joseph S. Myers
2011-11-08 14:00   ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D3E274F5-74DE-47E1-A1D1-01CB70E570A5@sandoe-acoustics.co.uk \
    --to=developer@sandoe-acoustics.co.uk \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).