This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
output file setup
- To: gcc-patches at gcc dot gnu dot org
- Subject: output file setup
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 07 May 2001 08:55:30 -0700
Some of the changes in the C++ front-end in the mainline sources cause
the compiler to call assemble_variable/assemble_external during
init_decl_processing.
On the PA (and possibly other targets), assemble_external actually has to
write stuff to the output file. Unfortunately, "asm_output_file" hasn't
been initialized at the time we call init_decl_processing. Segfault. Oops.
Anyway, this patch moves setting up the output file to an earlier point in
compile_file which solves the problem.
I'm installing this on the mainline sources.
* toplev.c (compile_file): Set up the output file before we call
the various initializers for the compiler.
Index: toplev.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/toplev.c,v
retrieving revision 1.437
diff -c -3 -p -r1.437 toplev.c
*** toplev.c 2001/04/30 22:37:17 1.437
--- toplev.c 2001/05/07 15:47:27
*************** compile_file (name)
*** 2263,2268 ****
--- 2263,2289 ----
init_timevar ();
timevar_start (TV_TOTAL);
+ if (! name_specified && asm_file_name == 0)
+ asm_out_file = stdout;
+ else
+ {
+ if (asm_file_name == 0)
+ {
+ int len = strlen (dump_base_name);
+ char *dumpname = (char *) xmalloc (len + 6);
+ memcpy (dumpname, dump_base_name, len + 1);
+ strip_off_ending (dumpname, len);
+ strcat (dumpname, ".s");
+ asm_file_name = dumpname;
+ }
+ if (!strcmp (asm_file_name, "-"))
+ asm_out_file = stdout;
+ else
+ asm_out_file = fopen (asm_file_name, "w");
+ if (asm_out_file == 0)
+ fatal_io_error ("can't open %s for writing", asm_file_name);
+ }
+
/* Initialize data in various passes. */
init_obstacks ();
*************** compile_file (name)
*** 2322,2348 ****
/* Open assembler code output file. Do this even if -fsyntax-only is on,
because then the driver will have provided the name of a temporary
file or bit bucket for us. */
-
- if (! name_specified && asm_file_name == 0)
- asm_out_file = stdout;
- else
- {
- if (asm_file_name == 0)
- {
- int len = strlen (dump_base_name);
- char *dumpname = (char *) xmalloc (len + 6);
- memcpy (dumpname, dump_base_name, len + 1);
- strip_off_ending (dumpname, len);
- strcat (dumpname, ".s");
- asm_file_name = dumpname;
- }
- if (!strcmp (asm_file_name, "-"))
- asm_out_file = stdout;
- else
- asm_out_file = fopen (asm_file_name, "w");
- if (asm_out_file == 0)
- fatal_io_error ("can't open %s for writing", asm_file_name);
- }
#ifdef IO_BUFFER_SIZE
setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
--- 2343,2348 ----