This is the mail archive of the
mailing list for the GCC project.
[PATCH] Fix GCC driver ICE on invalid abuse of specs (PR driver/30460)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 12 Nov 2007 07:17:50 -0500
- Subject: [PATCH] Fix GCC driver ICE on invalid abuse of specs (PR driver/30460)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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 <email@example.com>
* 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)
- /* 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 + strlen (argv);
while (p != argv && !IS_DIR_SEPARATOR (p[-1]))