File suse-record-gcc-opts.diff of Package gcc43

Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c.orig	2009-01-12 11:01:05.000000000 +0100
+++ gcc/varasm.c	2009-11-20 13:50:12.000000000 +0100
@@ -6332,6 +6332,35 @@ file_end_indicate_exec_stack (void)
   switch_to_section (get_section (".note.GNU-stack", flags, NULL));
 }
 
+/* This is a generic routine emitting a SUSE specific section for
+   QA check marks. */
+
+void
+suse_file_end_indicate_optflags (void)
+{
+  unsigned int flags = SECTION_DEBUG | SECTION_STRINGS | SECTION_MERGE | (SECTION_ENTSIZE & 1);
+
+  /*
+     o/O: optimize was off/on
+     s/S: size optimisation was off/on
+     p/P: stack-protector was off/on
+     w/W: warnings were off/on
+     g/G: debug was off/on
+     */
+
+  char opts_buffer[6];
+
+  opts_buffer[0] = (optimize >= 2) ? 'O' : 'o';
+  opts_buffer[1] = (optimize >= 1 && optimize_size) ? 'S' : 's';
+  opts_buffer[2] = (flag_stack_protect >= 1) ? 'P' : 'p';
+  opts_buffer[3] = (warn_uninitialized >= 1 && warn_sequence_point >= 1) ? 'W' : 'w';
+  opts_buffer[4] = (debug_info_level > DINFO_LEVEL_NONE) ? 'G' : 'g';
+  opts_buffer[5] = '\0';
+
+  switch_to_section (get_section (".comment.SUSE.OPTs", flags, NULL));
+  ASM_OUTPUT_ASCII (asm_out_file, opts_buffer, strlen (opts_buffer) + 1);
+}
+
 /* Output DIRECTIVE (a C string) followed by a newline.  This is used as
    a get_unnamed_section callback.  */
 
Index: gcc/output.h
===================================================================
--- gcc/output.h.orig	2008-09-17 16:13:10.000000000 +0200
+++ gcc/output.h	2009-11-20 13:50:12.000000000 +0100
@@ -612,6 +612,7 @@ extern void default_emit_except_table_la
 extern void default_internal_label (FILE *, const char *, unsigned long);
 extern void default_file_start (void);
 extern void file_end_indicate_exec_stack (void);
+extern void suse_file_end_indicate_optflags (void);
 extern bool default_valid_pointer_mode (enum machine_mode);
 
 extern void default_elf_asm_output_external (FILE *file, tree,
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c.orig	2009-05-08 13:55:18.000000000 +0200
+++ gcc/toplev.c	2009-11-20 13:50:12.000000000 +0100
@@ -1112,6 +1112,8 @@ compile_file (void)
     }
 #endif
 
+  suse_file_end_indicate_optflags ();
+
   /* This must be at the end.  Some target ports emit end of file directives
      into the assembly file here, and hence we can not output anything to the
      assembly file after this point.  */