Index: cgraph.h
===================================================================
--- cgraph.h	(revision 188182)
+++ cgraph.h	(working copy)
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "plugin-api.h"
 #include "vec.h"
 #include "tree.h"
+#include "pretty-print.h"
 #include "basic-block.h"
 #include "function.h"
 #include "ipa-ref.h"
@@ -589,6 +590,8 @@ bool cgraph_propagate_frequency (struct cgraph_nod
 
 /* In cgraphunit.c  */
 struct asm_node *add_asm_node (tree);
+struct asm_node *add_asm_printf (const char *, ...) ATTRIBUTE_GCC_PPDIAG(1,2);
+struct asm_node *add_asm_vprintf (const char *, va_list);
 extern FILE *cgraph_dump_file;
 void cgraph_finalize_function (tree, bool);
 void finalize_compilation_unit (void);
Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 188182)
+++ cgraphunit.c	(working copy)
@@ -40,6 +40,8 @@ along with GCC; see the file COPYING3.  If not see
       variables.
 
     - add_asm_node
+    - add_asm_printf
+    - add_asm_vprintf
 
       Insert new toplevel ASM statement
 
@@ -563,6 +565,40 @@ add_asm_node (tree asm_str)
   return node;
 }
 
+/* Pretty-vprint a string to a top-level asm.  */
+
+struct asm_node *
+add_asm_vprintf (const char *p, va_list ap)
+{
+  pretty_printer pp;
+  const char *asm_string;
+  tree t;
+
+  pp_construct (&pp, NULL, 0);
+  pp_vprintf (&pp, p, ap);
+  asm_string = pp_formatted_text (&pp);
+  t = build_string (strlen (asm_string), asm_string);
+
+  /* FIXME: We have to free PP, but is there a more elegant way than this?  */
+  pp_clear_output_area (&pp);
+  free (pp.buffer);
+
+  return add_asm_node (t);
+}
+
+/* Pretty-printf a string to a top-level asm.  */
+
+struct asm_node *
+add_asm_printf (const char *p, ...)
+{
+  struct asm_node *ret;
+  va_list ap;
+  va_start (ap, p);
+  ret = add_asm_vprintf (p, ap);
+  va_end (ap);
+  return ret;
+}
+
 /* Output all asm statements we have stored up to be output.  */
 
 static void
Index: targhooks.h
===================================================================
--- targhooks.h	(revision 188182)
+++ targhooks.h	(working copy)
@@ -178,3 +178,6 @@ extern enum machine_mode default_get_reg_raw_mode(
 
 extern void *default_get_pch_validity (size_t *);
 extern const char *default_pch_valid_p (const void *, size_t);
+
+extern void default_asm_output_ident_directive (const char*);
+
Index: java/class.c
===================================================================
--- java/class.c	(revision 188182)
+++ java/class.c	(working copy)
@@ -34,7 +34,6 @@ The Free Software Foundation is independent of Sun
 #include "obstack.h"
 #include "diagnostic-core.h"
 #include "toplev.h"
-#include "output.h" /* for switch_to_section and get_section */
 #include "parse.h"
 #include "function.h"
 #include "ggc.h"
@@ -988,10 +987,7 @@ build_utf8_ref (tree name)
       if (flag_merge_constants && decl_size < 256)
 	{
 	  char buf[32];
-	  int flags = (SECTION_OVERRIDE
-		       | SECTION_MERGE | (SECTION_ENTSIZE & decl_size));
 	  sprintf (buf, ".rodata.jutf8.%d", decl_size);
-	  switch_to_section (get_section (buf, flags, NULL));
 	  DECL_SECTION_NAME (decl) = build_string (strlen (buf), buf);
 	}
     }
Index: toplev.c
===================================================================
--- toplev.c	(revision 188182)
+++ toplev.c	(working copy)
@@ -107,6 +107,9 @@ static void compile_file (void);
 /* True if we don't need a backend (e.g. preprocessing only).  */
 static bool no_backend;
 
+/* True if the GCC .ident should not be printed.  This is only used by CRIS.  */
+bool flag_no_gcc_ident = false;
+
 /* Length of line when printing switch values.  */
 #define MAX_LINE 75
 
@@ -650,17 +653,17 @@ compile_file (void)
   /* Attach a special .ident directive to the end of the file to identify
      the version of GCC which compiled this code.  The format of the .ident
      string is patterned after the ones produced by native SVR4 compilers.  */
-#ifdef IDENT_ASM_OP
-  if (!flag_no_ident)
+  if (!flag_no_gcc_ident)
     {
       const char *pkg_version = "(GNU) ";
+      char *ident_str;
 
       if (strcmp ("(GCC) ", pkgversion_string))
 	pkg_version = pkgversion_string;
-      fprintf (asm_out_file, "%s\"GCC: %s%s\"\n",
-	       IDENT_ASM_OP, pkg_version, version_string);
+
+      ident_str = ACONCAT (("GCC: ", pkg_version, version_string, NULL));
+      targetm.asm_out.output_ident (ident_str);
     }
-#endif
 
   /* Invoke registered plugin callbacks.  */
   invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 188182)
+++ doc/tm.texi	(working copy)
@@ -5847,6 +5847,10 @@ value is 0.
 @end deftypevr
 
 @deftypefn {Target Hook} void TARGET_ASM_OUTPUT_ANCHOR (rtx @var{x})
+
+@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_IDENT (const char *@var{name})
+Generate a string based on @var{name}, suitable for the @samp{#ident}  directive, or the equivalent directive or pragma in non-C-family languages.  If this hook is not defined, nothing is output for the @samp{#ident}  directive.
+@end deftypefn
 Write the assembly code to define section anchor @var{x}, which is a
 @code{SYMBOL_REF} for which @samp{SYMBOL_REF_ANCHOR_P (@var{x})} is true.
 The hook is called with the assembly output position set to the beginning
@@ -7398,12 +7402,6 @@ the assembler source.  So you can use it to canoni
 of the filename using this macro.
 @end defmac
 
-@defmac ASM_OUTPUT_IDENT (@var{stream}, @var{string})
-A C statement to output something to the assembler file to handle a
-@samp{#ident} directive containing the text @var{string}.  If this
-macro is not defined, nothing is output for a @samp{#ident} directive.
-@end defmac
-
 @deftypefn {Target Hook} void TARGET_ASM_NAMED_SECTION (const char *@var{name}, unsigned int @var{flags}, tree @var{decl})
 Output assembly directives to switch to section @var{name}.  The section
 should have attributes as specified by @var{flags}, which is a bit mask
Index: doc/tm.texi.in
===================================================================
--- doc/tm.texi.in	(revision 188182)
+++ doc/tm.texi.in	(working copy)
@@ -7308,12 +7308,6 @@ the assembler source.  So you can use it to canoni
 of the filename using this macro.
 @end defmac
 
-@defmac ASM_OUTPUT_IDENT (@var{stream}, @var{string})
-A C statement to output something to the assembler file to handle a
-@samp{#ident} directive containing the text @var{string}.  If this
-macro is not defined, nothing is output for a @samp{#ident} directive.
-@end defmac
-
 @hook TARGET_ASM_NAMED_SECTION
 Output assembly directives to switch to section @var{name}.  The section
 should have attributes as specified by @var{flags}, which is a bit mask
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 188182)
+++ doc/invoke.texi	(working copy)
@@ -182,7 +182,7 @@ in the following sections.
 @item C++ Language Options
 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
 @gccoptlist{-fabi-version=@var{n}  -fno-access-control  -fcheck-new @gol
--fconserve-space  -fconstexpr-depth=@var{n}  -ffriend-injection @gol
+-fconstexpr-depth=@var{n}  -ffriend-injection @gol
 -fno-elide-constructors @gol
 -fno-enforce-eh-specs @gol
 -ffor-scope  -fno-for-scope  -fno-gnu-keywords @gol
@@ -1947,18 +1947,6 @@ return value even without this option.  In all oth
 exhaustion is signalled by throwing @code{std::bad_alloc}.  See also
 @samp{new (nothrow)}.
 
-@item -fconserve-space
-@opindex fconserve-space
-Put uninitialized or run-time-initialized global variables into the
-common segment, as C does.  This saves space in the executable at the
-cost of not diagnosing duplicate definitions.  If you compile with this
-flag and your program mysteriously crashes after @code{main()} has
-completed, you may have an object that is being destroyed twice because
-two definitions are merged.
-
-This option is no longer useful on most targets, now that support has
-been added for putting variables into BSS without making them common.
-
 @item -fconstexpr-depth=@var{n}
 @opindex fconstexpr-depth
 Set the maximum nested evaluation depth for C++11 constexpr functions
Index: config/arm/aout.h
===================================================================
--- config/arm/aout.h	(revision 188182)
+++ config/arm/aout.h	(working copy)
@@ -366,12 +366,6 @@
   asm_output_aligned_bss (STREAM, DECL, NAME, SIZE, ALIGN)
 #endif
 
-/* Output a #ident directive.  */
-#ifndef ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(STREAM,STRING)  \
-  asm_fprintf (STREAM, "%@ - - - ident %s\n", STRING)
-#endif
-     
 #ifndef ASM_COMMENT_START
 #define ASM_COMMENT_START 	"@"
 #endif
Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c	(revision 188182)
+++ config/mips/mips.c	(working copy)
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "target-globals.h"
 #include "opts.h"
+#include "cgraph.h"
 
 /* True if X is an UNSPEC wrapper around a SYMBOL_REF or LABEL_REF.  */
 #define UNSPEC_ADDRESS_P(X)					\
@@ -3098,6 +3099,22 @@ mips_legitimize_move (enum machine_mode mode, rtx
   return false;
 }
 
+/* Output #ident as a string in the read-only data section.  */
+static void
+mips_asm_output_ident (const char *string)
+{
+  if (cgraph_state == CGRAPH_STATE_PARSING)
+    add_asm_printf ("%s\n\t.ascii \"%s\"\n",
+		    READONLY_DATA_SECTION_ASM_OP, string);
+  else
+    {
+      int size = strlen (string) + 1;
+      switch_to_section (readonly_data_section);
+      assemble_string (string, size);
+    }
+}
+
+
 /* Return true if value X in context CONTEXT is a small-data address
    that can be rewritten as a LO_SUM.  */
 
Index: config/mips/mips.h
===================================================================
--- config/mips/mips.h	(revision 188182)
+++ config/mips/mips.h	(working copy)
@@ -2675,14 +2675,9 @@ do {									\
 #define ASM_OUTPUT_ASCII mips_output_ascii
 
 /* Output #ident as a in the read-only data section.  */
-#undef  ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(FILE, STRING)					\
-{									\
-  const char *p = STRING;						\
-  int size = strlen (p) + 1;						\
-  switch_to_section (readonly_data_section);				\
-  assemble_string (p, size);						\
-}
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT mips_asm_output_ident
+
 
 /* Default to -G 8 */
 #ifndef MIPS_DEFAULT_GVALUE
Index: config/mips/sde.h
===================================================================
--- config/mips/sde.h	(revision 188182)
+++ config/mips/sde.h	(working copy)
@@ -97,16 +97,10 @@ along with GCC; see the file COPYING3.  If not see
 /* Use periods rather than dollar signs in special g++ assembler names.  */
 #define NO_DOLLAR_IN_LABEL
 
-/* Attach a special .ident directive to the end of the file to identify
-   the version of GCC which compiled this code.  */
-#undef IDENT_ASM_OP
-#define IDENT_ASM_OP "\t.ident\t"
-
 /* Output #ident string into the ELF .comment section, so it doesn't
    form part of the load image, and so that it can be stripped.  */
-#undef ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(STREAM, STRING) \
-  fprintf (STREAM, "%s\"%s\"\n", IDENT_ASM_OP, STRING);
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* Currently we don't support 128bit long doubles, so for now we force
    n32 to be 64bit.  */
Index: config/mips/mips-protos.h
===================================================================
--- config/mips/mips-protos.h	(revision 188182)
+++ config/mips/mips-protos.h	(working copy)
@@ -264,6 +264,8 @@ extern void mips_declare_object (FILE *, const cha
 extern void mips_declare_object_name (FILE *, const char *, tree);
 extern void mips_finish_declare_object (FILE *, tree, int, int);
 
+extern void mips_asm_output_ident (const char *);
+
 extern bool mips_small_data_pattern_p (rtx);
 extern rtx mips_rewrite_small_data (rtx);
 extern HOST_WIDE_INT mips_initial_elimination_offset (int, int);
Index: config/rx/rx.h
===================================================================
--- config/rx/rx.h	(revision 188182)
+++ config/rx/rx.h	(working copy)
@@ -602,6 +602,7 @@ typedef unsigned int CUMULATIVE_ARGS;
     }							\
   while (0)
 
+/* ??? This is broken for #ident with AS100 syntax.  */
 #undef  IDENT_ASM_OP
 #define IDENT_ASM_OP  (TARGET_AS100_SYNTAX \
 		       ? "\t.END\t; Built by: ": "\t.ident\t")
Index: config/microblaze/microblaze.h
===================================================================
--- config/microblaze/microblaze.h	(revision 188182)
+++ config/microblaze/microblaze.h	(working copy)
@@ -696,8 +696,8 @@ do {									\
 #define ASCII_DATA_ASM_OP		"\t.ascii\t"
 #define STRING_ASM_OP			"\t.asciz\t"
 
-#define ASM_OUTPUT_IDENT(FILE, STRING)					\
-  microblaze_asm_output_ident (FILE, STRING)
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT microblaze_asm_output_ident
 
 /* Default to -G 8 */
 #ifndef MICROBLAZE_DEFAULT_GVALUE
Index: config/microblaze/microblaze-protos.h
===================================================================
--- config/microblaze/microblaze-protos.h	(revision 188182)
+++ config/microblaze/microblaze-protos.h	(working copy)
@@ -48,7 +48,7 @@ extern int microblaze_regno_ok_for_base_p (int, in
 extern HOST_WIDE_INT microblaze_initial_elimination_offset (int, int);
 extern void microblaze_declare_object (FILE *, const char *, const char *,
    const char *, int);
-extern void microblaze_asm_output_ident (FILE *, const char *);
+extern void microblaze_asm_output_ident (const char *);
 #endif  /* RTX_CODE */
 
 /* Declare functions in microblaze-c.c.  */
Index: config/microblaze/microblaze.c
===================================================================
--- config/microblaze/microblaze.c	(revision 188182)
+++ config/microblaze/microblaze.c	(working copy)
@@ -47,6 +47,7 @@
 #include "df.h"
 #include "optabs.h"
 #include "diagnostic-core.h"
+#include "cgraph.h"
 
 #define MICROBLAZE_VERSION_COMPARE(VA,VB) strcasecmp (VA, VB)
 
@@ -2737,15 +2738,35 @@ microblaze_return_addr (int count, rtx frame ATTRI
 }
 
 /* Put string into .sdata2 if below threashold.  */
+/* ??? Is this really worth supporting?  The most common use of
+   .ident is for the GCC version string, which is typically much
+   longer than MICROBLASE_SECTION_THRESHOLD.  Likewise for user
+   .ident strings.  Oh well...  */
 void 
-microblaze_asm_output_ident (FILE *file ATTRIBUTE_UNUSED, const char *string)
+microblaze_asm_output_ident (const char *string)
 {
+  const char *section_asm_op;
+  section *sec;
+
   int size = strlen (string) + 1;
   if (size <= microblaze_section_threshold)
-    switch_to_section (sdata2_section);
+    {
+      sec = sdata2_section;
+      section_asm_op = SDATA2_SECTION_ASM_OP;
+    }
   else
-    switch_to_section (readonly_data_section);
-  assemble_string (string, size);
+    {
+      sec = readonly_data_section;
+      section_asm_op = READONLY_DATA_SECTION_ASM_OP;
+    }
+
+  if (cgraph_state == CGRAPH_STATE_PARSING)
+    add_asm_printf ("%s\n\t.ascii \"%s\"\n", section_asm_op, string);
+  else
+    {
+      switch_to_section (sec);
+      assemble_string (string, size);
+    }
 }
 
 static void
Index: config/i386/djgpp.h
===================================================================
--- config/i386/djgpp.h	(revision 188182)
+++ config/i386/djgpp.h	(working copy)
@@ -31,10 +31,6 @@ along with GCC; see the file COPYING3.  If not see
 #undef DATA_SECTION_ASM_OP
 #define DATA_SECTION_ASM_OP "\t.section .data"
 
-/* Define the name of the .ident op.  */
-#undef IDENT_ASM_OP
-#define IDENT_ASM_OP "\t.ident\t"
-
 /* Enable alias attribute support.  */
 #ifndef SET_ASM_OP
 #define SET_ASM_OP "\t.set\t"
Index: config/i386/gas.h
===================================================================
--- config/i386/gas.h	(revision 188182)
+++ config/i386/gas.h	(working copy)
@@ -47,7 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Output #ident as a .ident.  */
 
-#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME);
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* In the past there was confusion as to what the argument to .align was
    in GAS.  For the last several years the rule has been this: for a.out
Index: config/picochip/picochip.h
===================================================================
--- config/picochip/picochip.h	(revision 188182)
+++ config/picochip/picochip.h	(working copy)
@@ -488,7 +488,8 @@ do {
 #define ASM_APP_ON "// High-level ASM start\n"
 #define ASM_APP_OFF "// High-level ASM end\n"
 
-#define ASM_OUTPUT_IDENT(STREAM,STRING) fprintf(STREAM, ".ident %s\n", STRING)
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* Output of Data  */
 
Index: config/sparc/sparc.h
===================================================================
--- config/sparc/sparc.h	(revision 188182)
+++ config/sparc/sparc.h	(working copy)
@@ -1709,12 +1709,10 @@ do {									\
     ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN);		\
   } while (0)
 
-#define IDENT_ASM_OP "\t.ident\t"
-
 /* Output #ident as a .ident.  */
 
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
-  fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
 /* Prettify the assembly.  */
 
Index: config/elfos.h
===================================================================
--- config/elfos.h	(revision 188182)
+++ config/elfos.h	(working copy)
@@ -83,11 +83,9 @@ see the files COPYING3 and COPYING.RUNTIME respect
 
 /* Output #ident as a .ident.  */
 
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
-  fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
+#undef TARGET_ASM_OUTPUT_IDENT
+#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
-#define IDENT_ASM_OP "\t.ident\t"
-
 #undef  SET_ASM_OP
 #define SET_ASM_OP	"\t.set\t"
 
Index: config/cris/cris.h
===================================================================
--- config/cris/cris.h	(revision 188182)
+++ config/cris/cris.h	(working copy)
@@ -851,14 +851,6 @@ enum cris_pic_symbol_type
 
 /* Node: File Framework */
 
-/* We don't want an .ident for gcc.  To avoid that but still support
-   #ident, we override ASM_OUTPUT_IDENT and, since the gcc .ident is its
-   only use besides ASM_OUTPUT_IDENT, undef IDENT_ASM_OP from elfos.h.  */
-#undef IDENT_ASM_OP
-#undef ASM_OUTPUT_IDENT
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
-  fprintf (FILE, "%s\"%s\"\n", "\t.ident\t", NAME);
-
 #define ASM_APP_ON "#APP\n"
 
 #define ASM_APP_OFF "#NO_APP\n"
Index: config/cris/cris.c
===================================================================
--- config/cris/cris.c	(revision 188182)
+++ config/cris/cris.c	(working copy)
@@ -2530,6 +2530,10 @@ cris_asm_output_case_end (FILE *stream, int num, r
 static void
 cris_option_override (void)
 {
+  /* We don't want an .ident for gcc.
+     It isn't really clear anymore why not.  */
+  flag_no_gcc_ident = true;
+
   if (cris_max_stackframe_str)
     {
       cris_max_stackframe = atoi (cris_max_stackframe_str);
Index: target.def
===================================================================
--- target.def	(revision 188182)
+++ target.def	(working copy)
@@ -427,6 +427,15 @@ DEFHOOK
  void, (rtx x),
  default_asm_output_anchor)
 
+DEFHOOK
+(output_ident,
+ "Generate a string based on @var{name}, suitable for the @samp{#ident} \
+ directive, or the equivalent directive or pragma in non-C-family languages. \
+ If this hook is not defined, nothing is output for the @samp{#ident} \
+ directive.",
+ void, (const char *name),
+ hook_void_constcharptr)
+
 /* Output a DTP-relative reference to a TLS symbol.  */
 DEFHOOK
 (output_dwarf_dtprel,
Index: pretty-print.c
===================================================================
--- pretty-print.c	(revision 188182)
+++ pretty-print.c	(working copy)
@@ -718,20 +718,27 @@ pp_base_remaining_character_count_for_line (pretty
 }
 
 
-/* Format a message into BUFFER a la printf.  */
+/* Format a message into BUFFER a la vprintf.  */
 void
-pp_printf (pretty_printer *pp, const char *msg, ...)
+pp_vprintf (pretty_printer *pp, const char *msg, va_list ap)
 {
   text_info text;
-  va_list ap;
-
-  va_start (ap, msg);
   text.err_no = errno;
   text.args_ptr = &ap;
   text.format_spec = msg;
   text.locus = NULL;
   pp_format (pp, &text);
   pp_output_formatted_text (pp);
+}
+
+
+/* Format a message into BUFFER a la printf.  */
+void
+pp_printf (pretty_printer *pp, const char *msg, ...)
+{
+  va_list ap;
+  va_start (ap, msg);
+  pp_vprintf (pp, msg, ap);
   va_end (ap);
 }
 
Index: pretty-print.h
===================================================================
--- pretty-print.h	(revision 188182)
+++ pretty-print.h	(working copy)
@@ -325,6 +325,7 @@ extern void pp_base_append_text (pretty_printer *,
 #endif
 extern void pp_printf (pretty_printer *, const char *, ...)
      ATTRIBUTE_GCC_PPDIAG(2,3);
+extern void pp_vprintf (pretty_printer *, const char *, va_list);
 
 extern void pp_verbatim (pretty_printer *, const char *, ...)
      ATTRIBUTE_GCC_PPDIAG(2,3);
Index: varasm.c
===================================================================
--- varasm.c	(revision 188182)
+++ varasm.c	(working copy)
@@ -7411,4 +7411,24 @@ default_elf_fini_array_asm_out_destructor (rtx sym
   assemble_addr_to_section (symbol, sec);
 }
 
+/* Default TARGET_ASM_OUTPUT_IDENT hook.
+
+   This is a bit of a cheat.  The real default is a no-op, but this
+   hook is the default for all targets with a .ident directive.  */
+
+void
+default_asm_output_ident_directive (const char *ident_str)
+{
+  const char *ident_asm_op = "\t.ident\t";
+
+  /* If we are still in the front end, do not write out the string
+     to asm_out_file.  Instead, add a fake top-level asm statement.
+     This allows the front ends to use this hook without actually
+     writing to asm_out_file, to handle #ident or Pragma Ident.  */
+  if (cgraph_state == CGRAPH_STATE_PARSING)
+    add_asm_printf ("%s\"%s\"\n", ident_asm_op, ident_str);
+  else
+    fprintf (asm_out_file, "%s\"%s\"\n", ident_asm_op, ident_str);
+}
+
 #include "gt-varasm.h"
Index: output.h
===================================================================
--- output.h	(revision 188182)
+++ output.h	(working copy)
@@ -641,4 +641,8 @@ extern int default_address_cost (rtx, bool);
 /* Output stack usage information.  */
 extern void output_stack_usage (void);
 
+/* In toplev.c:  */
+/* True if the GCC .ident should not be printed.  This is only used by CRIS.  */
+extern bool flag_no_gcc_ident;
+
 #endif /* ! GCC_OUTPUT_H */
Index: ada/gcc-interface/trans.c
===================================================================
--- ada/gcc-interface/trans.c	(revision 188182)
+++ ada/gcc-interface/trans.c	(working copy)
@@ -647,12 +647,9 @@ gigi (Node_Id gnat_root, int max_gnat_node, int nu
   VEC_safe_push (tree, gc, gnu_program_error_label_stack, NULL_TREE);
 
   /* Process any Pragma Ident for the main unit.  */
-#ifdef ASM_OUTPUT_IDENT
   if (Present (Ident_String (Main_Unit)))
-    ASM_OUTPUT_IDENT
-      (asm_out_file,
-       TREE_STRING_POINTER (gnat_to_gnu (Ident_String (Main_Unit))));
-#endif
+    targetm.asm_out.output_ident
+      (TREE_STRING_POINTER (gnat_to_gnu (Ident_String (Main_Unit))));
 
   /* If we are using the GCC exception mechanism, let GCC know.  */
   if (Exception_Mechanism == Back_End_Exceptions)
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 188182)
+++ cp/decl.c	(working copy)
@@ -39,7 +39,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-inline.h"
 #include "decl.h"
 #include "intl.h"
-#include "output.h" /* for have_global_bss_p */
 #include "toplev.h"
 #include "hashtab.h"
 #include "tm_p.h"
@@ -4528,18 +4527,6 @@ start_decl (const cp_declarator *declarator,
   if (decl == error_mark_node)
     return error_mark_node;
 
-  /* Tell the back end to use or not use .common as appropriate.  If we say
-     -fconserve-space, we want this to save .data space, at the expense of
-     wrong semantics.  If we say -fno-conserve-space, we want this to
-     produce errors about redefs; to do this we force variables into the
-     data segment.  */
-  if (flag_conserve_space
-      && TREE_CODE (decl) == VAR_DECL
-      && TREE_PUBLIC (decl)
-      && !DECL_THREAD_LOCAL_P (decl)
-      && !have_global_bss_p ())
-    DECL_COMMON (decl) = 1;
-
   if (TREE_CODE (decl) == VAR_DECL
       && DECL_NAMESPACE_SCOPE_P (decl) && !TREE_PUBLIC (decl) && !was_public
       && !DECL_THIS_STATIC (decl) && !DECL_ARTIFICIAL (decl))
Index: testsuite/gcc.dg/pch/ident-1.hs
===================================================================
--- testsuite/gcc.dg/pch/ident-1.hs	(revision 0)
+++ testsuite/gcc.dg/pch/ident-1.hs	(revision 0)
@@ -0,0 +1 @@
+#ident "My true identity will never be revealed!"
Index: testsuite/gcc.dg/pch/ident-1.c
===================================================================
--- testsuite/gcc.dg/pch/ident-1.c	(revision 0)
+++ testsuite/gcc.dg/pch/ident-1.c	(revision 0)
@@ -0,0 +1,2 @@
+#include "ident-1.h"
+
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 188182)
+++ Makefile.in	(working copy)
@@ -902,7 +902,8 @@ CFGLOOP_H = cfgloop.h $(BASIC_BLOCK_H) $(RTL_H) ve
 IPA_UTILS_H = ipa-utils.h $(TREE_H) $(CGRAPH_H)
 IPA_REFERENCE_H = ipa-reference.h $(BITMAP_H) $(TREE_H)
 CGRAPH_H = cgraph.h $(VEC_H) $(TREE_H) $(BASIC_BLOCK_H) $(FUNCTION_H) \
-	cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H)
+	cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H) \
+	$(PRETTY_PRINT_H)
 DF_H = df.h $(BITMAP_H) $(REGSET_H) sbitmap.h $(BASIC_BLOCK_H) \
 	alloc-pool.h $(TIMEVAR_H)
 RESOURCE_H = resource.h hard-reg-set.h $(DF_H)
Index: c-family/c-pch.c
===================================================================
--- c-family/c-pch.c	(revision 188182)
+++ c-family/c-pch.c	(working copy)
@@ -26,7 +26,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "flags.h"
 #include "c-common.h"
-#include "output.h" /* for asm_out_file */
 #include "debug.h"
 #include "c-pragma.h"
 #include "ggc.h"
@@ -36,6 +35,24 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "timevar.h"
 
+/* PCH was introduced before unit-at-a-time became the only supported
+   compilation mode.  To exactly replay the content parsed at PCH generate
+   time, anything written to asm_out_file was read back in and stored in
+   the PCH, and written back out to asm_out_file while reading a PCH.
+
+   Nowadays, ideally no action by a front end should never result in output
+   to asm_out_file, and front-end files should not include output.h.  For
+   now assert that nothing is written to asm_out_file while a PCH is being
+   generated.  Before GCC 4.8 is released, this code should be removed.
+   FIXME.  */
+#define CHECK_NO_ASM_OUT_DURING_PCH
+#ifdef CHECK_NO_ASM_OUT_DURING_PCH
+extern FILE *asm_out_file;
+
+/* The position in the assembler output file when pch_init was called.  */
+static long asm_file_startpos;
+#endif
+
 /* This is a list of flag variables that must match exactly, and their
    names for the error message.  The possible values for *flag_var must
    fit in a 'signed char'.  */
@@ -69,19 +86,11 @@ struct c_pch_validity
   size_t target_data_length;
 };
 
-struct c_pch_header
-{
-  unsigned long asm_size;
-};
-
 #define IDENT_LENGTH 8
 
 /* The file we'll be writing the PCH to.  */
 static FILE *pch_outfile;
 
-/* The position in the assembler output file when pch_init was called.  */
-static long asm_file_startpos;
-
 static const char *get_ident (void);
 
 /* Compute an appropriate 8-byte magic number for the PCH file, so that
@@ -93,7 +102,7 @@ static const char *
 get_ident (void)
 {
   static char result[IDENT_LENGTH];
-  static const char templ[] = "gpch.013";
+  static const char templ[] = "gpch.014";
   static const char c_language_chars[] = "Co+O";
 
   memcpy (result, templ, IDENT_LENGTH);
@@ -115,15 +124,6 @@ pch_init (void)
   void *target_validity;
   static const char partial_pch[] = "gpcWrite";
 
-#ifdef ASM_COMMENT_START
-  if (flag_verbose_asm)
-    {
-      fprintf (asm_out_file, "%s ", ASM_COMMENT_START);
-      c_common_print_pch_checksum (asm_out_file);
-      fputc ('\n', asm_out_file);
-    }
-#endif
-
   if (!pch_file)
     return;
 
@@ -153,13 +153,9 @@ pch_init (void)
       || fwrite (target_validity, v.target_data_length, 1, f) != 1)
     fatal_error ("can%'t write to %s: %m", pch_file);
 
-  /* We need to be able to re-read the output.  */
-  /* The driver always provides a valid -o option.  */
-  if (asm_file_name == NULL
-      || strcmp (asm_file_name, "-") == 0)
-    fatal_error ("%qs is not a valid output file", asm_file_name);
-
+#ifdef CHECK_NO_ASM_OUT_DURING_PCH
   asm_file_startpos = ftell (asm_out_file);
+#endif
 
   /* Let the debugging format deal with the PCHness.  */
   (*debug_hooks->handle_pch) (0);
@@ -173,11 +169,6 @@ pch_init (void)
 void
 c_common_write_pch (void)
 {
-  char *buf;
-  long asm_file_end;
-  long written;
-  struct c_pch_header h;
-
   timevar_push (TV_PCH_SAVE);
 
   targetm.prepare_pch_save ();
@@ -186,34 +177,10 @@ c_common_write_pch (void)
 
   cpp_write_pch_deps (parse_in, pch_outfile);
 
-  asm_file_end = ftell (asm_out_file);
-  h.asm_size = asm_file_end - asm_file_startpos;
+#ifdef CHECK_NO_ASM_OUT_DURING_PCH
+  gcc_assert (ftell (asm_out_file) - asm_file_startpos == 0);
+#endif
 
-  if (fwrite (&h, sizeof (h), 1, pch_outfile) != 1)
-    fatal_error ("can%'t write %s: %m", pch_file);
-
-  buf = XNEWVEC (char, 16384);
-
-  if (fseek (asm_out_file, asm_file_startpos, SEEK_SET) != 0)
-    fatal_error ("can%'t seek in %s: %m", asm_file_name);
-
-  for (written = asm_file_startpos; written < asm_file_end; )
-    {
-      long size = asm_file_end - written;
-      if (size > 16384)
-	size = 16384;
-      if (fread (buf, size, 1, asm_out_file) != 1)
-	fatal_error ("can%'t read %s: %m", asm_file_name);
-      if (fwrite (buf, size, 1, pch_outfile) != 1)
-	fatal_error ("can%'t write %s: %m", pch_file);
-      written += size;
-    }
-  free (buf);
-  /* asm_out_file can be written afterwards, so fseek to clear
-     _IOREAD flag.  */
-  if (fseek (asm_out_file, 0, SEEK_END) != 0)
-    fatal_error ("can%'t seek in %s: %m", asm_file_name);
-
   gt_pch_save (pch_outfile);
 
   timevar_push (TV_PCH_CPP_SAVE);
@@ -375,7 +342,6 @@ c_common_read_pch (cpp_reader *pfile, const char *
 		   int fd, const char *orig_name ATTRIBUTE_UNUSED)
 {
   FILE *f;
-  struct c_pch_header h;
   struct save_macro_data *smd;
   expanded_location saved_loc;
   bool saved_trace_includes;
@@ -392,38 +358,6 @@ c_common_read_pch (cpp_reader *pfile, const char *
 
   cpp_get_callbacks (parse_in)->valid_pch = NULL;
 
-  if (fread (&h, sizeof (h), 1, f) != 1)
-    {
-      cpp_errno (pfile, CPP_DL_ERROR, "reading");
-      fclose (f);
-      goto end;
-    }
-
-  if (!flag_preprocess_only)
-    {
-      unsigned long written;
-      char * buf = XNEWVEC (char, 16384);
-
-      for (written = 0; written < h.asm_size; )
-	{
-	  long size = h.asm_size - written;
-	  if (size > 16384)
-	    size = 16384;
-	  if (fread (buf, size, 1, f) != 1
-	      || fwrite (buf, size, 1, asm_out_file) != 1)
-	    cpp_errno (pfile, CPP_DL_ERROR, "reading");
-	  written += size;
-	}
-      free (buf);
-    }
-  else
-    {
-      /* If we're preprocessing, don't write to a NULL
-	 asm_out_file.  */
-      if (fseek (f, h.asm_size, SEEK_CUR) != 0)
-	cpp_errno (pfile, CPP_DL_ERROR, "seeking");
-    }
-
   /* Save the location and then restore it after reading the PCH.  */
   saved_loc = expand_location (line_table->highest_line);
   saved_trace_includes = line_table->trace_includes;
@@ -501,14 +435,3 @@ c_common_pch_pragma (cpp_reader *pfile, const char
   close (fd);
 }
 
-/* Print out executable_checksum[].  */
-
-void
-c_common_print_pch_checksum (FILE *f)
-{
-  int i;
-  fputs ("Compiler executable checksum: ", f);
-  for (i = 0; i < 16; i++)
-    fprintf (f, "%02x", executable_checksum[i]);
-  putc ('\n', f);
-}
Index: c-family/c.opt
===================================================================
--- c-family/c.opt	(revision 188182)
+++ c-family/c.opt	(working copy)
@@ -762,7 +762,7 @@ Allow the arguments of the '?' operator to have di
 
 fconserve-space
 C++ ObjC++ Var(flag_conserve_space)
-Reduce the size of object files
+Does nothing.  Preserved for backward compatibility.
 
 fconstant-string-class=
 ObjC ObjC++ Joined MissingArgError(no class name specified with %qs)
Index: c-family/c-opts.c
===================================================================
--- c-family/c-opts.c	(revision 188182)
+++ c-family/c-opts.c	(working copy)
@@ -1100,7 +1100,13 @@ c_common_init (void)
   cpp_init_iconv (parse_in);
 
   if (version_flag)
-    c_common_print_pch_checksum (stderr);
+    {
+      int i;
+      fputs ("Compiler executable checksum: ", stderr);
+      for (i = 0; i < 16; i++)
+	fprintf (stderr, "%02x", executable_checksum[i]);
+      putc ('\n', stderr);
+    }
 
   /* Has to wait until now so that cpplib has its hash table.  */
   init_pragma ();
Index: c-family/c-lex.c
===================================================================
--- c-family/c-lex.c	(revision 188182)
+++ c-family/c-lex.c	(working copy)
@@ -26,7 +26,6 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "tree.h"
 #include "input.h"
-#include "output.h" /* for asm_out_file */
 #include "c-common.h"
 #include "flags.h"
 #include "timevar.h"
@@ -165,18 +164,16 @@ cb_ident (cpp_reader * ARG_UNUSED (pfile),
 	  unsigned int ARG_UNUSED (line),
 	  const cpp_string * ARG_UNUSED (str))
 {
-#ifdef ASM_OUTPUT_IDENT
   if (!flag_no_ident)
     {
       /* Convert escapes in the string.  */
       cpp_string cstr = { 0, 0 };
       if (cpp_interpret_string (pfile, str, 1, &cstr, CPP_STRING))
 	{
-	  ASM_OUTPUT_IDENT (asm_out_file, (const char *) cstr.text);
+	  targetm.asm_out.output_ident ((const char *) cstr.text);
 	  free (CONST_CAST (unsigned char *, cstr.text));
 	}
     }
-#endif
 }
 
 /* Called at the start of every non-empty line.  TOKEN is the first
Index: c-family/c-common.h
===================================================================
--- c-family/c-common.h	(revision 188182)
+++ c-family/c-common.h	(working copy)
@@ -1019,7 +1019,6 @@ extern void c_common_read_pch (cpp_reader *pfile,
 extern void c_common_write_pch (void);
 extern void c_common_no_more_pch (void);
 extern void c_common_pch_pragma (cpp_reader *pfile, const char *);
-extern void c_common_print_pch_checksum (FILE *f);
 
 /* In *-checksum.c */
 extern const unsigned char executable_checksum[16];
