On Mon, May 2, 2022 at 11:08 AM Martin Liška <mli...@suse.cz> wrote:
>
> On 5/2/22 11:03, Richard Biener wrote:
> > In fact I think GCC is correct in its handling and LLVM would need to dup 
> > () the
> > file descriptor.  Was this issue raised with the LLVM folks?
>
> I don't know here.
>
> > I suspect the BFD
> > linker will also not work with LLVM due to this?
>
> I'm not sure BFD is supported by LLVM:
> https://llvm.org/docs/GoldPlugin.html
>
> They explicitly name it Gold plugin.

BFD does

  if (plugin_call_claim_file (&file, &claimed))
    einfo (_("%F%P: %s: plugin reported error claiming file\n"),
           plugin_error_plugin ());

  if (input->fd != -1
      && (!claimed || !bfd_plugin_target_p (ibfd->xvec)))
    {
      /* FIXME: fd belongs to us, not the plugin.  GCC plugin, which
         doesn't need fd after plugin_call_claim_file, doesn't use
         BFD plugin target vector.  Since GCC plugin doesn't call
         release_input_file, we close it here.  LLVM plugin, which
         needs fd after plugin_call_claim_file and calls
         release_input_file after it is done, uses BFD plugin target
         vector.  This scheme doesn't work when a plugin needs fd and
         doesn't use BFD plugin target vector neither.  */
      release_plugin_file_descriptor (input);
    }

so it knows about the problem.  The above suggests that the plugin
could set ->fd to -1 ...

Richard.

>
> Martin
>

Reply via email to