public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix GCC driver ICE on invalid abuse of specs (PR driver/30460)
@ 2007-11-12 14:33 Jakub Jelinek
  2007-11-15 22:19 ` Diego Novillo
  2007-11-16  7:08 ` Jim Wilson
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2007-11-12 14:33 UTC (permalink / raw)
  To: gcc-patches

Hi!

asm_debug variable isn't initialized to ASM_DEBUG_SPEC unlike all the other
static specs to work around some Irix cc bug and so is assigned only at
runtime.  But it is done only in init_spec and in the case where some -B xxx/
subdir contains an invalid hand-crafted specs (the default spec should be
always created from -dumpspecs and editing it, or better yet just using an
overriding -specs=xxx.spec) asm_debug is therefore uninitialized.
The PR submitter argues that init_spec should be called always, but that
would be a behavior change and for correctly created default specs even
unnecessary wasting of driver cycles.
This patch fixes this segfault instead by just initializing it always as
soon as possible (i.e. in main rather than init_spec).  If we wouldn't work
around Irix cc bugs, it would be already initialized by the time we reach
main through static initializer.

Tested on x86_64-linux, ok for trunk?

2007-11-12  Jakub Jelinek  <jakub@redhat.com>

	PR driver/30460
	* gcc.c (init_spec): Don't initialize asm_debug here...
	(main): ... but here.

--- gcc/gcc.c.jj	2007-11-01 20:48:57.000000000 +0100
+++ gcc/gcc.c	2007-11-12 12:21:49.000000000 +0100
@@ -1719,10 +1719,6 @@ init_spec (void)
     }
 #endif
 
-  /* Initialize here, not in definition.  The IRIX 6 O32 cc sometimes chokes
-     on ?: in file-scope variable initializations.  */
-  asm_debug = ASM_DEBUG_SPEC;
-
   for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
     {
       sl = &static_specs[i];
@@ -6134,6 +6130,10 @@ main (int argc, char **argv)
   struct user_specs *uptr;
   char **old_argv = argv;
 
+  /* Initialize here, not in definition.  The IRIX 6 O32 cc sometimes chokes
+     on ?: in file-scope variable initializations.  */
+  asm_debug = ASM_DEBUG_SPEC;
+
   p = argv[0] + strlen (argv[0]);
   while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
     --p;

	Jakub

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

end of thread, other threads:[~2007-11-16  0:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-12 14:33 [PATCH] Fix GCC driver ICE on invalid abuse of specs (PR driver/30460) Jakub Jelinek
2007-11-15 22:19 ` Diego Novillo
2007-11-16  7:08 ` Jim Wilson

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