This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper
- From: Cary Coutant <ccoutant at google dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Ilya Verbin <iverbin at gmail dot com>, Richard Biener <rguenther at suse dot de>, Jan Hubicka <hubicka at ucw dot cz>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Thomas Schwinge <thomas at codesourcery dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>, Andrey Turetskiy <andrey dot turetskiy at gmail dot com>
- Date: Fri, 10 Oct 2014 09:51:02 -0700
- Subject: Re: [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper
- Authentication-results: sourceware.org; auth=none
- References: <20141002151457 dot GA59899 at msticlxl57 dot ims dot intel dot com> <20141008102650 dot GV1986 at tucnak dot redhat dot com> <20141009120738 dot GA7420 at msticlxl57 dot ims dot intel dot com> <20141009200703 dot GA56445 at GumBook dot local> <20141010065320 dot GA10376 at tucnak dot redhat dot com>
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