public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFA]: Slight toplev.c initialization rearrangement
@ 2002-08-13 13:35 Neil Booth
  2002-08-13 19:48 ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Neil Booth @ 2002-08-13 13:35 UTC (permalink / raw)
  To: gcc-patches

Current initialization is a bit awkward.  This is due to our
delaying debug initialization until reading the first line
of a file for the C family front ends, so that we can get
the true original name if it is preprocessed.  However,
we need debug initialized before processing -D, -imacros etc.
on the command line.

To have any hope of moving the -D, -U, -A and imacros out of
cpplib to the front end in a clean way, this needs to change,
and debug info needs to be initialized earlier.  This in turn
means that the first line of the file needs to be read in
earlier; namely in the post_options hook.

As a step towards doing this, I need to rearrange things in
toplev.c a bit.  It makes initialization a little clearer,
IMO.

I'm bootstrapping this; OK to apply on success?

Neil.

	* toplev.c (parse_options_and_default_flags): Don't call
	post_options here.
	(general_init): Initialize GC, pools and tree hash here,
	instead of lang_independent_init.
	(lang_independent_init): Rename backend_init.
	(do_compile): Call post_options hook; exit early if there
	have been errors after switch processing.
	(toplev_main): Update.

Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.667
diff -u -p -r1.667 toplev.c
--- toplev.c	4 Aug 2002 22:45:20 -0000	1.667
+++ toplev.c	13 Aug 2002 20:13:07 -0000
@@ -97,10 +97,10 @@ extern tree last_assemble_variable_decl;
 extern void reg_alloc PARAMS ((void));
 
 static void general_init PARAMS ((char *));
-static bool parse_options_and_default_flags PARAMS ((int, char **));
-static void do_compile PARAMS ((int));
+static void parse_options_and_default_flags PARAMS ((int, char **));
+static void do_compile PARAMS ((void));
 static void process_options PARAMS ((void));
-static void lang_independent_init PARAMS ((int));
+static void backend_init PARAMS ((void));
 static int lang_dependent_init PARAMS ((const char *));
 static void init_asm_output PARAMS ((const char *));
 static void finalize PARAMS ((void));
@@ -4723,6 +4723,12 @@ general_init (argv0)
   /* Initialize the diagnostics reporting machinery, so option parsing
      can give warnings and errors.  */
   diagnostic_initialize (global_dc);
+
+  /* Initialize the garbage-collector, string pools and tree type hash
+     table.  */
+  init_ggc ();
+  init_stringpool ();
+  init_ttree ();
 }
 \f
 /* Parse command line options and set default flag values, called
@@ -4731,7 +4737,7 @@ general_init (argv0)
    and identifier hashtables etc. are not initialized yet.
 
    Return non-zero to suppress compiler back end initialization.  */
-static bool
+static void
 parse_options_and_default_flags (argc, argv)
      int argc;
      char **argv;
@@ -4968,10 +4974,6 @@ parse_options_and_default_flags (argc, a
 
   if (flag_really_no_inline == 2)
     flag_really_no_inline = flag_no_inline;
-
-  /* All command line options have been parsed; allow the front end to
-     perform consistency checks, etc.  */
-  return (*lang_hooks.post_options) ();
 }
 \f
 /* Process the options that have been parsed.  */
@@ -5151,21 +5153,10 @@ process_options ()
       flag_trapping_math = 1;
 }
 \f
-/* Language-independent initialization, before language-dependent
-   initialization.  */
+/* Initialize the compiler back end.  */
 static void
-lang_independent_init (no_backend)
-     int no_backend;
+backend_init ()
 {
-  /* Initialize the garbage-collector, and string pools.  */
-  init_ggc ();
-
-  init_stringpool ();
-  init_ttree ();
-
-  if (no_backend)
-    return;
-
   /* init_emit_once uses reg_raw_mode and therefore must be called
      after init_regs which initialized reg_raw_mode.  */
   init_regs ();
@@ -5305,12 +5296,19 @@ finalize ()
 \f
 /* Initialize the compiler, and compile the input file.  */
 static void
-do_compile (no_backend)
-     int no_backend;
+do_compile ()
 {
+  /* All command line options have been parsed; allow the front end to
+     perform consistency checks, etc.  */
+  bool no_backend = (*lang_hooks.post_options) ();
+
   /* The bulk of command line switch processing.  */
   process_options ();
 
+  /* If an error has already occurred, give up.  */
+  if (errorcount)
+    return;
+
   if (aux_base_name)
     /*NOP*/;
   else if (filename)
@@ -5320,7 +5318,6 @@ do_compile (no_backend)
       aux_base_name = name;
       strip_off_ending (name, strlen (name));
     }
-  
   else
     aux_base_name = "gccaux";
 
@@ -5329,9 +5326,9 @@ do_compile (no_backend)
   init_timevar ();
   timevar_start (TV_TOTAL);
 
-  /* Language-independent initialization.  Also sets up GC, identifier
-     hashes etc., and the back-end if requested.  */
-  lang_independent_init (no_backend);
+  /* Set up the back-end if requested.  */
+  if (!no_backend)
+    backend_init ();
 
   /* Language-dependent initialization.  Returns true on success.  */
   if (lang_dependent_init (filename))
@@ -5356,18 +5353,16 @@ toplev_main (argc, argv)
      int argc;
      char **argv;
 {
-  bool no_backend;
-
   /* Initialization of GCC's environment, and diagnostics.  */
   general_init (argv[0]);
 
   /* Parse the options and do minimal processing; basically just
      enough to default flags appropriately.  */
-  no_backend = parse_options_and_default_flags (argc, argv);
+  parse_options_and_default_flags (argc, argv);
 
   /* Exit early if we can (e.g. -help).  */
-  if (!errorcount && !exit_after_options)
-    do_compile (no_backend);
+  if (!exit_after_options)
+    do_compile ();
 
   if (errorcount || sorrycount)
     return (FATAL_EXIT_CODE);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Slight toplev.c initialization rearrangement
  2002-08-13 13:35 [RFA]: Slight toplev.c initialization rearrangement Neil Booth
@ 2002-08-13 19:48 ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2002-08-13 19:48 UTC (permalink / raw)
  To: Neil Booth; +Cc: gcc-patches

On Tue, Aug 13, 2002 at 09:35:15PM +0100, Neil Booth wrote:
> 	* toplev.c (parse_options_and_default_flags): Don't call
> 	post_options here.
> 	(general_init): Initialize GC, pools and tree hash here,
> 	instead of lang_independent_init.
> 	(lang_independent_init): Rename backend_init.
> 	(do_compile): Call post_options hook; exit early if there
> 	have been errors after switch processing.
> 	(toplev_main): Update.

Ok.


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Slight toplev.c initialization rearrangement
@ 2002-08-14 12:32 Ulrich Weigand
  0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Weigand @ 2002-08-14 12:32 UTC (permalink / raw)
  To: Neil Booth; +Cc: rth, gcc-patches


Neil Booth wrote:

>-  if (cpp_opts->deps.style != DEPS_NONE)
>+  if (cpp_opts->deps.style == DEPS_NONE)

Yes, that fixed it.  Thanks!


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Slight toplev.c initialization rearrangement
  2002-08-14  8:06 Ulrich Weigand
@ 2002-08-14 10:19 ` Neil Booth
  0 siblings, 0 replies; 6+ messages in thread
From: Neil Booth @ 2002-08-14 10:19 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: rth, gcc-patches

Ulrich Weigand wrote:-

> Sorry, I got the symptom right but the patch wrong.
> Further testing confirmed that glibc was in fact broken by
> the patch "Move -M* out of cpplib.":
>  http://gcc.gnu.org/ml/gcc-patches/2002-08/msg00816.html

Yes, off by one byte 8-)  I've applied this.

Neil.

	* c-opts.c (c_common_post_options): Correct test.

Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.12
diff -u -p -r1.12 c-opts.c
--- c-opts.c	14 Aug 2002 03:09:14 -0000	1.12
+++ c-opts.c	14 Aug 2002 17:18:12 -0000
@@ -1330,7 +1330,7 @@ c_common_post_options ()
   if (out_fname == NULL || !strcmp (out_fname, "-"))
     out_fname = "";
 
-  if (cpp_opts->deps.style != DEPS_NONE)
+  if (cpp_opts->deps.style == DEPS_NONE)
     check_deps_environment_vars ();
 
   handle_deferred_opts ();

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Slight toplev.c initialization rearrangement
@ 2002-08-14  8:06 Ulrich Weigand
  2002-08-14 10:19 ` Neil Booth
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Weigand @ 2002-08-14  8:06 UTC (permalink / raw)
  To: neil, rth; +Cc: gcc-patches

I wrote:

>It looks like this patch breaks glibc, which uses the
>SUNPRO_DEPENDENCIES environment variable.  With the current
>head of CVS, this variable appears to be completely ignored ...

Sorry, I got the symptom right but the patch wrong.
Further testing confirmed that glibc was in fact broken by
the patch "Move -M* out of cpplib.":
 http://gcc.gnu.org/ml/gcc-patches/2002-08/msg00816.html


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA]: Slight toplev.c initialization rearrangement
@ 2002-08-14  7:25 Ulrich Weigand
  0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Weigand @ 2002-08-14  7:25 UTC (permalink / raw)
  To: neil, rth; +Cc: gcc-patches

On Tue, Aug 13, 2002 at 09:35:15PM +0100, Neil Booth wrote:
>       * toplev.c (parse_options_and_default_flags): Don't call
>       post_options here.
>       (general_init): Initialize GC, pools and tree hash here,
>       instead of lang_independent_init.
>       (lang_independent_init): Rename backend_init.
>       (do_compile): Call post_options hook; exit early if there
>       have been errors after switch processing.
>       (toplev_main): Update.

It looks like this patch breaks glibc, which uses the
SUNPRO_DEPENDENCIES environment variable.  With the current
head of CVS, this variable appears to be completely ignored ...

The failing command looks like this:

echo '#include "../posix/bits/posix1_lim.h"' |          \
SUNPRO_DEPENDENCIES='/home/weigand/current/glibc-build/bits/stdio_lim.dT /home/weigand/current/glibc-build/bits/stdio_lim.st'  \
/home/weigand/fsf/gcc-head-install/bin/gcc [various -I options] -E -dM -xc - -o /home/weigand/current/glibc-build/bits/stdio_lim.hT

This should create a stdio_lim.dT file, which the head of CVS
does not do any more.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-08-14 19:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-13 13:35 [RFA]: Slight toplev.c initialization rearrangement Neil Booth
2002-08-13 19:48 ` Richard Henderson
2002-08-14  7:25 Ulrich Weigand
2002-08-14  8:06 Ulrich Weigand
2002-08-14 10:19 ` Neil Booth
2002-08-14 12:32 Ulrich Weigand

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).