public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [lto] PATCH: add option for writing LTRANS output file names
@ 2008-09-25 19:37 Ollie Wild
  2008-09-26  0:09 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Ollie Wild @ 2008-09-25 19:37 UTC (permalink / raw)
  To: gcc-patches, Diego Novillo, Rafael Espindola

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

This patch adds a new option, -fltrans-output-list, which specifies a
file to which the names of LTRANS output files are written.  The is
required by the linker driver so it can determine which files to link
into the final executable.

Tested via manual testing and an i686-pc-linux-gnu C/C++/LTO bootstrap.

Ollie


2008-09-25  Ollie Wild  <aaw@google.com>

        * lang.opt (fltrans-output-list=): New option.
        * lto.c (lto_execute_ltrans): Output file names to ltrans_output_list.

2008-09-25  Ollie Wild  <aaw@google.com>

        * doc/invoke.texi (fltrans-output-list): Document new option.

[-- Attachment #2: ltrans-output-list.txt --]
[-- Type: text/plain, Size: 3539 bytes --]

commit 450c7c5d82b8ba17f8e426839dd26bb6c464387c
Author: Ollie Wild <aaw@google.com>
Date:   Wed Sep 24 23:15:52 2008 -0700

    Add -fltrans-output-list.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 780da60..efe4ba1 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -339,7 +339,7 @@ Objective-C and Objective-C++ Dialects}.
 -fno-ira-share-spill-slots -fira-verbose=@var{n} @gol
 -fivopts -fkeep-inline-functions -fkeep-static-consts @gol
 -floop-block -floop-interchange -floop-strip-mine -fltrans -fltrans-driver @gol
--fmerge-all-constants -fmerge-constants -fmodulo-sched @gol
+-fltrans-output-list -fmerge-all-constants -fmerge-constants -fmodulo-sched @gol
 -fmodulo-sched-allow-regmoves -fmove-loop-invariants -fmudflap @gol
 -fmudflapir -fmudflapth -fno-branch-count-reg -fno-default-inline @gol
 -fno-defer-pop -fno-function-cse -fno-guess-branch-probability @gol
@@ -6549,6 +6549,13 @@ corresponding output file ending in .ltrans.o.
 
 Default value points to the ltrans_driver script installed alongside lto1.
 
+@item -fltrans-output-list=@var{file}
+@opindex fltrans-output-list
+This option specifies a file to which the names of LTRANS output files are
+written.  This option is only meaningful in conjunction with @option{-fwpa}.
+
+Disabled by default.
+
 @item -fcprop-registers
 @opindex fcprop-registers
 After register allocation and post-register allocation instruction splitting,
diff --git a/gcc/lto/lang.opt b/gcc/lto/lang.opt
index d20d663..9b9830e 100644
--- a/gcc/lto/lang.opt
+++ b/gcc/lto/lang.opt
@@ -28,6 +28,10 @@ fltrans-driver=
 LTO Joined Var(ltrans_driver)
 Specify an executable for performing local transformations on WPA output.
 
+fltrans-output-list=
+LTO Joined Var(ltrans_output_list)
+Specify a file to which a list of files output by LTRANS is written.
+
 resolution
 LTO Separate
 The resolution file
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 952034d..78d13bc 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -700,6 +700,7 @@ lto_execute_ltrans (char *const *files)
   size_t i;
   int err;
   int status;
+  FILE *ltrans_output_list_stream = NULL;
 
   /* Set the CC environment variable.  */
   env_val = getenv ("COLLECT_GCC");
@@ -729,12 +730,37 @@ lto_execute_ltrans (char *const *files)
   for (i = 0; files[i]; ++i);
   argv = XNEWVEC (char *, i + 2);
 
+  /* Open the LTRANS output list.  */
+  if (ltrans_output_list)
+    {
+      ltrans_output_list_stream = fopen (ltrans_output_list, "w");
+      if (ltrans_output_list_stream == NULL)
+	error ("opening LTRANS output list %s: %m", ltrans_output_list);
+    }
+
   argv_ptr = (const char **)argv;
   *argv_ptr++ = ltrans_driver;
   for (i = 0; files[i]; ++i)
-    *argv_ptr++ = files[i];
+    {
+      *argv_ptr++ = files[i];
+
+      /* Replace the .o suffix with a .ltrans.o suffix and write the resulting
+	 name to the LTRANS output list.  */
+      if (ltrans_output_list_stream)
+	{
+	  size_t len = strlen (files[i]) - 2;
+
+	  if (fwrite (files[i], 1, len, ltrans_output_list_stream) < len
+	      || fwrite (".ltrans.o\n", 1, 10, ltrans_output_list_stream) < 10)
+	    error ("writing to LTRANS output list %s: %m", ltrans_output_list);
+	}
+    }
   *argv_ptr++ = NULL;
 
+  /* Close the LTRANS output list.  */
+  if (ltrans_output_list_stream && fclose (ltrans_output_list_stream))
+    error ("closing LTRANS output list %s: %m", ltrans_output_list);
+
   /* Execute the LTRANS driver.  */
   errmsg = pex_run (pex, PEX_LAST | PEX_SEARCH, argv[0], argv, NULL, NULL,
 		    &err);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [lto] PATCH: add option for writing LTRANS output file names
  2008-09-25 19:37 [lto] PATCH: add option for writing LTRANS output file names Ollie Wild
@ 2008-09-26  0:09 ` Diego Novillo
  0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2008-09-26  0:09 UTC (permalink / raw)
  To: Ollie Wild; +Cc: gcc-patches, Rafael Espindola

On Thu, Sep 25, 2008 at 14:49, Ollie Wild <aaw@google.com> wrote:

> 2008-09-25  Ollie Wild  <aaw@google.com>
>
>        * lang.opt (fltrans-output-list=): New option.
>        * lto.c (lto_execute_ltrans): Output file names to ltrans_output_list.
>
> 2008-09-25  Ollie Wild  <aaw@google.com>
>
>        * doc/invoke.texi (fltrans-output-list): Document new option.
>

OK.

Diego.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-25 23:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25 19:37 [lto] PATCH: add option for writing LTRANS output file names Ollie Wild
2008-09-26  0:09 ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).