diff mbox

Move flag_stack_check and flag_compare_debug to gcc_options structure

Message ID Pine.LNX.4.64.1011241733120.1678@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers Nov. 24, 2010, 5:34 p.m. UTC
flag_compare_debug and flag_stack_check had been left as global
variables when opts.c otherwise moved to using the gcc_options
structure because those variables are referenced directly from Ada
code so cannot so readily be replaced by macros.

This patch moves these variables to the gcc_options structure using
the same trick as for "optimize" and "optimize_size" which are also
accessed from Ada code: defining variables with those names in
ada/gcc-interface/misc.c which are then set in gnat_post_options from
the global_options fields.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
commit?

2010-11-24  Joseph Myers  <joseph@codesourcery.com>

	* common.opt (flag_stack_check): New Variable entry.
	(fcompare-debug-second): Use Var.
	* flags.h (flag_compare_debug, flag_stack_check): Remove.
	* opts.c (flag_compare_debug): Remove.
	(common_handle_option): Don't handle OPT_fcompare_debug_second.
	Set opts->x_flag_stack_check for OPT_fstack_check_.
	* toplev.c (flag_stack_check): Remove.

ada:
2010-11-24  Joseph Myers  <joseph@codesourcery.com>

	* gcc-interface/misc.c (flag_compare_debug, flag_stack_check):
	Undefine as macros then define as variables.
	(gnat_post_options): Set variables from global_options.

Comments

Joseph Myers Dec. 1, 2010, 1:50 p.m. UTC | #1
Ping.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02483.html> is pending 
review.
Arnaud Charlet Dec. 1, 2010, 1:53 p.m. UTC | #2
> Ping.  This patch 
> <http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02483.html> is
> pending review.

Patch is fine.

Note that the use of flag_compare_debug in the Ada front-end
introduced with -fcompare-debug itself is an annoying kludge (I don't even
remember seeing it officially submitted to Ada maintainers).

Any idea on how to get rid of it?

Arno
Eric Botcazou Dec. 1, 2010, 2 p.m. UTC | #3
> Note that the use of flag_compare_debug in the Ada front-end
> introduced with -fcompare-debug itself is an annoying kludge (I don't even
> remember seeing it officially submitted to Ada maintainers).

I agree. :-)

> Any idea on how to get rid of it?

I presume we would need a compilation mode that doesn't write the ALI file but 
does everything else as usual.  Or do we already have such a thing?
Arnaud Charlet Dec. 1, 2010, 2:04 p.m. UTC | #4
> > Any idea on how to get rid of it?
> 
> I presume we would need a compilation mode that doesn't write the ALI file but
> does everything else as usual.  Or do we already have such a thing?

I don't think we have that. Any hope in modifying the driver that uses
-fcompare-debug to ignore these files?

If needed, by using a shell wrapper that would call gcc and then remove the
.ali file.

Arno
Eric Botcazou Dec. 1, 2010, 2:13 p.m. UTC | #5
> I don't think we have that. Any hope in modifying the driver that uses
> -fcompare-debug to ignore these files?
>
> If needed, by using a shell wrapper that would call gcc and then remove the
> .ali file.

Alexandre is the resident expert here but, in any case, having such a mode 
would IMO be nice for its own sake.  When you play with gnat1 directly, it 
attempts to write the ALI file in seemingly random directories, including the 
source directories which will cause gnatbind to issue weird errors later.
Alexandre Oliva Dec. 3, 2010, 6:42 a.m. UTC | #6
On Dec  1, 2010, Arnaud Charlet <charlet@adacore.com> wrote:

>> > Any idea on how to get rid of it?
>> 
>> I presume we would need a compilation mode that doesn't write the ALI file but
>> does everything else as usual.  Or do we already have such a thing?

> I don't think we have that. Any hope in modifying the driver that uses
> -fcompare-debug to ignore these files?

The concern IIRC is that we would overwrite the .ali files generated by
the non-debug compilation.  If compare succeeds, this shouldn't be much
of a problem, but if it fails, the file might be different, and it might
then affect other compilations.

I support the idea of adding another command-line flag that disables
writing of .ali files, and have it passed to gnat during the second
-fcompare-debug compilation (-fcompare-debug-second).
diff mbox

Patch

Index: gcc/flags.h
===================================================================
--- gcc/flags.h	(revision 167113)
+++ gcc/flags.h	(working copy)
@@ -34,11 +34,6 @@  extern const char *const debug_type_name
 extern void strip_off_ending (char *, int);
 extern int base_of_path (const char *path, const char **base_out);
 
-/* Run the second compilation of -fcompare-debug.  Not defined using
-   Var in common.opt because this is used in Ada code and so must be
-   an actual variable not a macro.  */
-extern int flag_compare_debug;
-
 /* True if this is the LTO front end (lto1).  This is used to disable
    gimple generation and lowering passes that are normally run on the
    output of a front end.  These passes must be bypassed for lto since
@@ -120,8 +115,6 @@  extern struct target_flag_state *this_ta
 /* Nonzero if we dump in VCG format, not plain text.  */
 extern int dump_for_graph;
 
-extern enum stack_check_type flag_stack_check;
-
 /* Returns TRUE if generated code should match ABI version N or
    greater is in use.  */
 
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 167113)
+++ gcc/toplev.c	(working copy)
@@ -187,9 +187,6 @@  int flag_permissive = 0;
    the support provided depends on the backend.  */
 rtx stack_limit_rtx;
 
-/* Type of stack check.  */
-enum stack_check_type flag_stack_check = NO_STACK_CHECK;
-
 /* True if the user has tagged the function with the 'section'
    attribute.  */
 
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 167113)
+++ gcc/opts.c	(working copy)
@@ -42,11 +42,6 @@  along with GCC; see the file COPYING3.  
 #include "insn-attr.h"		/* For INSN_SCHEDULING and DELAY_SLOTS.  */
 #include "target.h"
 
-/* Run the second compilation of -fcompare-debug.  Not defined using
-   Var in common.opt because this is used in Ada code and so must be
-   an actual variable not a macro.  */
-int flag_compare_debug;
-
 /* Parse the -femit-struct-debug-detailed option value
    and set the flag variables. */
 
@@ -1400,10 +1395,6 @@  common_handle_option (struct gcc_options
       /* Deferred.  */
       break;
 
-    case OPT_fcompare_debug_second:
-      flag_compare_debug = value;
-      break;
-
     case OPT_fdbg_cnt_:
     case OPT_fdbg_cnt_list:
       /* Deferred.  */
@@ -1597,15 +1588,15 @@  common_handle_option (struct gcc_options
 
     case OPT_fstack_check_:
       if (!strcmp (arg, "no"))
-	flag_stack_check = NO_STACK_CHECK;
+	opts->x_flag_stack_check = NO_STACK_CHECK;
       else if (!strcmp (arg, "generic"))
 	/* This is the old stack checking method.  */
-	flag_stack_check = STACK_CHECK_BUILTIN
+	opts->x_flag_stack_check = STACK_CHECK_BUILTIN
 			   ? FULL_BUILTIN_STACK_CHECK
 			   : GENERIC_STACK_CHECK;
       else if (!strcmp (arg, "specific"))
 	/* This is the new stack checking method.  */
-	flag_stack_check = STACK_CHECK_BUILTIN
+	opts->x_flag_stack_check = STACK_CHECK_BUILTIN
 			   ? FULL_BUILTIN_STACK_CHECK
 			   : STACK_CHECK_STATIC_BUILTIN
 			     ? STATIC_BUILTIN_STACK_CHECK
Index: gcc/ada/gcc-interface/misc.c
===================================================================
--- gcc/ada/gcc-interface/misc.c	(revision 167113)
+++ gcc/ada/gcc-interface/misc.c	(working copy)
@@ -221,8 +221,12 @@  gnat_init_options (unsigned int decoded_
    of the global_options structure.  */
 #undef optimize
 #undef optimize_size
+#undef flag_compare_debug
+#undef flag_stack_check
 int optimize;
 int optimize_size;
+int flag_compare_debug;
+enum stack_check_type flag_stack_check = NO_STACK_CHECK;
 
 /* Post-switch processing.  */
 
@@ -252,6 +256,8 @@  gnat_post_options (const char **pfilenam
 
   optimize = global_options.x_optimize;
   optimize_size = global_options.x_optimize_size;
+  flag_compare_debug = global_options.x_flag_compare_debug;
+  flag_stack_check = global_options.x_flag_stack_check;
 
   return false;
 }
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 167113)
+++ gcc/common.opt	(working copy)
@@ -155,6 +155,10 @@  unsigned int initial_max_fld_align = TAR
 Variable
 enum vect_verbosity_levels user_vect_verbosity_level = MAX_VERBOSITY_LEVEL
 
+; Type of stack check.
+Variable
+enum stack_check_type flag_stack_check = NO_STACK_CHECK
+
 ; -dA causes debug commentary information to be produced in
 ; the generated assembly code (to make it more readable).  This option
 ; is generally only of use to those who actually need to read the
@@ -835,7 +839,7 @@  Common Driver JoinedOrMissing RejectNega
 -fcompare-debug[=<opts>]	Compile with and without e.g. -gtoggle, and compare the final-insns dump
 
 fcompare-debug-second
-Common Driver RejectNegative
+Common Driver RejectNegative Var(flag_compare_debug)
 Run only the second compilation of -fcompare-debug
 
 fconserve-stack