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]

[PATCH] Fix PR46291: broken lto-bootstrap [was Re: Discussion about merging Go frontend]

On 03/11/2010 16:18, H.J. Lu wrote:
> On Wed, Nov 3, 2010 at 2:41 AM, Dave Korn <> wrote:
>> On 03/11/2010 05:29, Dave Korn wrote:
>>> On 03/11/2010 05:10, Dave Korn wrote:
>>>>   :) I see our emails crossed in the ether.  Just preparing a (hopefully
>>>> final!) spin.
>>>   This is underway on the cfarm.  No changes to the previous changelogs with
>>> this revision.
>>  Testing completed without regressions on x86-64-unknown-linux-gnu; committed
>> (just the simpleobj-lto-plugin-take2.diff, not the cygming nor coff patches)
>> at revision 166233.
> I am afraid this caused:

  As mentioned in the audit trail, this patch will fix bootstrap while we
decide how to resolve the ambiguity in the linker plugin interface spec.


2010-11-03  Dave Korn  <>

	* lto-plugin.c (must_close_files): New global bool.
	(claim_file_handler): Respect it.
	(onload): Set it if loaded by GNU LD.

  Now LTO-bootstrapping on x86_64-unknown-linux-gnu.  OK once it completes


Index: lto-plugin/lto-plugin.c
--- lto-plugin/lto-plugin.c	(revision 166233)
+++ lto-plugin/lto-plugin.c	(working copy)
@@ -145,8 +145,16 @@ static char *resolution_file = NULL;
 /* Set by default from, but can be overridden at runtime
    by using -plugin-opt=-sym-style={none,win32,underscore|uscore}
    (in fact, only first letter of style arg is checked.)  */
 static enum symbol_style sym_style = SYM_STYLE;
+/* Until ambiguity in the linker plugin API is resolved, it will be
+   necessary for us to detect which linker is calling us at onload
+   time, and infer from that whether to close the file descriptors
+   passed into the claim_file_handler (LD) or not (GOLD).  */
+static bool must_close_files = false;
 static void
 check (bool gate, enum ld_plugin_level level, const char *text)
@@ -886,7 +894,7 @@ claim_file_handler (const struct ld_plugin_input_f
   if (obj.objfile)
     simple_object_release_read (obj.objfile);
-  if (file->fd >= 0)
+  if (must_close_files && file->fd >= 0)
     close (file->fd);
   return LDPS_OK;
@@ -959,6 +967,9 @@ onload (struct ld_plugin_tv *tv)
 	  add_symbols = p->tv_u.tv_add_symbols;
+	  must_close_files = true;
+	  break;
 	  register_all_symbols_read = p->tv_u.tv_register_all_symbols_read;

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