This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper


The linker already has a --strip-lto-sections option, and it's on by
default. I'll approve a patch that modifies gold to recognize
.gnu.offload_lto.* sections as part of --strip-lto-sections.

Really, though, you should be setting the SHF_EXCLUDE bit on these
sections. Do that and no special-casing will be necessary.

Generating a linker script on the fly to discard these sections is, to
me, rather hacky. There are better ways to do it.

-cary


On Thu, Oct 9, 2014 at 11:53 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Oct 10, 2014 at 12:07:03AM +0400, Ilya Verbin wrote:
>> On 09 Oct 16:07, Ilya Verbin wrote:
>> > > > +      /* By default linker does not discard .gnu.offload_lto_* sections.  */
>> > > > +      const char *linker_script = make_temp_file ("_linker_script.x");
>> > > > +      FILE *stream = fopen (linker_script, "w");
>> > > > +      if (!stream)
>> > > > +       fatal_error ("fopen %s: %m", linker_script);
>> > > > +      fprintf (stream, "SECTIONS { /DISCARD/ : { *("
>> > > > +                      OFFLOAD_SECTION_NAME_PREFIX "*) } }\n");
>> > > > +      fclose (stream);
>> > > > +      printf ("%s\n", linker_script);
>> > > > +
>> > > > +      goto finish;
>> > > > +    }
>> > >
>> > > Does this work with gold?  Are there any other linkers that support plugins,
>> > > but don't support linker scripts this way?
>> >
>> > Oops, gold does not support scripts, outputted from plugins :(
>> > "error: SECTIONS seen after other input files; try -T/--script"
>> >
>> > Probably, we should update default linker scripts in binutils?
>> > But without latest ld/gold all binaries compiled without -flto and with
>> > offloading will contain intermediate bytecode...
>>
>> Actually, this issue is not due to outputting a script from a plugin,
>> gold just does not support partial linker scripts:
>> https://sourceware.org/bugzilla/show_bug.cgi?id=17451
>>
>> So it seems that discarding .gnu.offload_lto_* sections (like it is done for
>> .gnu.lto_*) in the default ld and gold scripts is the right way?
>
> I must say I'm not very much familiar with the linker plugin API, but it
> surprises me that discarding sections is not something it allows.
> Anyway, can you do the partial linker script for the bfd linker (is there
> a way to determine from the linker plugin API if it is gold or bfd ld?), and
> for gold for the time being perhaps strip the sections in lto-wrapper? and
> feed the ET_REL objects with the sections stripped back to the linker
> through the plugin API?
>
>         Jakub


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