This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Add -frecord-gcc-switches command line switch

Hi Guys,

  This is a resubmission of an old patch which adds a new command line
  switch to gcc:  -frecord-gcc-switches.

  This switch, if used, causes gcc to record details of its command
  line into the object file that it is creating.  This is similar to
  the -fverbose-asm switch, except that the details are actually
  recorded in the object file, not just the assembler file.

  The purpose of this switch is to help in debugging object files and
  binaries.  A programmer asked to look at a binary file which has
  been created with this extra information included will be able to
  see how it was built, and possibly recreate it with assurance that
  they are duplicating the original build process.

  The switch also helps when it is hard to determine exactly what
  command line was used to create an object file.  For example
  because of a complicated build environment.

  The switch is implemented as a target hook so that individual
  backends can choose how the information is to be recorded.  The
  default implementation creates a .note section containing ASCII
  strings, and for ELF, the section is marked as string mergeable, so
  that when multiple object files containing this kind of information
  are linked together, only one copy of each string will be included.

  The feature (if used) does increase the size of object files and
  executables, but, for the default implementation at least, this
  extra size is not included in a loadable section.

  This feature is further documented here:

  Tested without regressions by building an x86_64 native toolchain
  and running the gcc testsuite.

  This submission includes a patch to the HTML gcc documentation
  noting the new feature which I would apply should the main part of
  the patch be accepted.

  OK to apply ?


2006-12-04  Nick Clifton  <>

	* common.opt (record-gcc-switches): New command line switch.
	* target.h (print_switch_type): New enum.
	(print_fn_type): New typedef for a function pointer.
	(struct gcc_target): Add record_gcc_switches and
	gcc_switches_recording_section fields.
	* target-def.h (TARGET_ASM_RECORD_GCC_SWITCHES): Provide a default
	* toplev.c (print_single_switch): Simplify by providing a pointer
	to function that will format and output the switch appropriately.
	(print_switch_values): Likewise.
	(print_to_asm_out_file): New function.
	(print_to_stderr): New function.
	(init_asm_output): If flag_record_gcc_switches is set and the
	target supports recording the switches then emit them into the
	assembler output file.
	* varasm.c (varasm_print_gcc_option): New function.
	(default_record_gcc_switches): New function.  Default handler for
	the record_gcc_switches target hook.
	* doc/tm.texi (TARGET_ASM_RECORD_GCC_SWITCHES): Document the new
	target hook.
	* doc/invoke.texi (-frecord-gcc-switches): 


Attachment: gcc.record-options.patch.bz2
Description: Adds new gcc command line switch: -frecord-gcc-switches

Index: htdocs/gcc-4.3/changes.html
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.3/changes.html,v
retrieving revision 1.5
diff -c -3 -p -r1.5 changes.html
*** htdocs/gcc-4.3/changes.html	21 Nov 2006 20:24:13 -0000	1.5
--- htdocs/gcc-4.3/changes.html	4 Dec 2006 16:20:46 -0000
*** 20,25 ****
--- 20,36 ----
      <li>A new <em>forward propagation</em> pass on RTL was added.  The new pass
        replaces several slower transformations, resulting in compile-time
        improvements as well as better code generation in some cases.</li>
+     <li> A new command line switch <code>-frecord-gcc-switches</code> has been
+     added to GCC.  This switch causes the command line that was used to invoke
+     the compiler to be recorded into the object file that is being created.  The
+     exact format of this recording is target and binary file format dependent,
+     but it usually takes the form of a note section containing ascii text.  This
+     switch is related to the <code>-fverbose-asm</code> switch, but that switch
+     only records the information in the assembler output file as comments, so it
+     never reaches the object file.    
+     </li>
  <h2>New Languages and Language specific improvements</h2>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]